Python SDK
Install and use the Cerebe Python SDK.
Python SDK
The official Python SDK for Cerebe. Provides both sync (Cerebe) and async (AsyncCerebe) clients.
Installation
pip install cerebeQuick Start
from cerebe import AsyncCerebe
# Reads CEREBE_API_KEY from environment
client = AsyncCerebe()
# Or pass explicitly
client = AsyncCerebe(
api_key="ck_live_...",
base_url="https://api.cerebe.ai", # default
)Resources
The client provides resource-based access to all Cerebe services:
client.memory # Memory operations
client.knowledge # Knowledge graph
client.storage # File storage
client.meta_learning # PLRE and pattern analysis
client.llm # OpenAI-compatible chat
client.prompts # Prompt managementAsync Context Manager
async with AsyncCerebe(api_key="...") as client:
result = await client.memory.search(
query="user preferences",
session_id="session_abc",
)
# Client automatically closed on exitError Handling
from cerebe import AsyncCerebe, AuthenticationError, RateLimitError
try:
result = await client.memory.search(...)
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")Configuration
| Parameter | Environment Variable | Default |
|---|---|---|
api_key | CEREBE_API_KEY | — (required) |
project | CEREBE_PROJECT | "" |
base_url | CEREBE_BASE_URL | https://api.cerebe.ai |
timeout | — | 30.0 |
max_retries | — | 3 |
Auto-Retry
The SDK automatically retries on:
- 429 (Rate Limited) — respects
Retry-Afterheader - 5xx (Server Error) — exponential backoff
Client errors (400, 401, 404, 422) are never retried.
Requirements
- Python 3.10+
- Dependencies:
httpx,pydantic,typing-extensions