CMDOP Python SDK
The `cmdop` Python SDK provides a client for interacting with CMDOP agents, enabling programmatic control over agent execution and data exchange. It is currently at version 2026.4.7.2 and follows an agile release cadence, often aligning with platform updates.
Common errors
-
cmdop.errors.AuthenticationError: Missing or invalid API key
cause The provided API key is either missing, incorrect, or has expired.fixSet the `CMDOP_API_KEY` environment variable with a valid key, or pass it directly to the `Agent` constructor: `agent = Agent(api_key="your_valid_key")`. -
TypeError: Agent() missing 1 required positional argument: 'api_key'
cause The `Agent` class was initialized without the required `api_key` argument, and the `CMDOP_API_KEY` environment variable was also not found.fixEither set the `CMDOP_API_KEY` environment variable before running your script, or explicitly pass the API key when creating the `Agent` instance: `from cmdop import Agent; agent = Agent(api_key="YOUR_API_KEY")`. -
cmdop.errors.ConnectionError: Could not connect to the CMDOP API: [Errno 111] Connection refused
cause The Python client could not establish a network connection to the CMDOP API server. This could be due to network issues, an incorrect endpoint, or the API server being unavailable.fixCheck your internet connection. If behind a proxy, ensure proxy settings are correctly configured for your Python environment. Verify that the CMDOP API status page indicates no outages. If using a custom endpoint, ensure it's correct.
Warnings
- gotcha The `api_key` parameter for `Agent` initialization is mandatory. If not provided or if the `CMDOP_API_KEY` environment variable is not set, it will lead to an `AuthenticationError` or `TypeError`.
- breaking The library requires Python 3.10 or newer. Users on older Python versions will encounter installation failures or runtime errors.
- gotcha Network connectivity issues or incorrect API endpoint configuration can result in `ConnectionError` exceptions, preventing successful interaction with the CMDOP service.
Install
-
pip install cmdop
Imports
- Agent
from cmdop import Agent
Quickstart
import os
from cmdop import Agent
# Ensure CMDOP_API_KEY is set as an environment variable
# e.g., export CMDOP_API_KEY="your_api_key_here"
api_key = os.environ.get("CMDOP_API_KEY")
if not api_key:
print("Warning: CMDOP_API_KEY environment variable is not set. Using a placeholder.")
print("Please set it for actual API interaction.")
api_key = "sk-fake-api-key"
try:
agent = Agent(api_key=api_key)
response = agent.execute("What is the capital of France?")
print(f"Agent Response: {response}")
except Exception as e:
print(f"An error occurred: {e}")