Installation
The AICP Python SDK requires Python 3.9+ and uses httpx for HTTP transport.
Install
pip install aicp
Sync client
from aicp import AICPClient
client = AICPClient(
api_key="aicp-...",
base_url="https://your-gateway",
timeout=30.0,
)
Async client
from aicp import AsyncAICPClient
client = AsyncAICPClient(
api_key="aicp-...",
base_url="https://your-gateway",
)
Constructor parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | None | Bearer token. Can be set later with set_api_key(). |
base_url | str | http://localhost:3000 | AICP gateway base URL. |
timeout | float | 30.0 | Request timeout in seconds. |
Context manager (sync)
The sync client holds an open httpx connection pool. Use it as a context manager to ensure it is closed properly:
with AICPClient(api_key="aicp-...", base_url="https://your-gateway") as client:
response = client.chat.complete(
model="auto",
messages=[{"role": "user", "content": "Hello!"}],
)