Skip to main content

Installation

The AICP Python SDK requires Python 3.9+ and uses httpx for HTTP transport.

GitHub

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

ParameterTypeDefaultDescription
api_keystr | NoneNoneBearer token. Can be set later with set_api_key().
base_urlstrhttp://localhost:3000AICP gateway base URL.
timeoutfloat30.0Request 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!"}],
)