CerebeCerebe Docs

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 cerebe

Quick 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 management

Async 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 exit

Error 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

ParameterEnvironment VariableDefault
api_keyCEREBE_API_KEY— (required)
projectCEREBE_PROJECT""
base_urlCEREBE_BASE_URLhttps://api.cerebe.ai
timeout30.0
max_retries3

Auto-Retry

The SDK automatically retries on:

  • 429 (Rate Limited) — respects Retry-After header
  • 5xx (Server Error) — exponential backoff

Client errors (400, 401, 404, 422) are never retried.

Requirements

  • Python 3.10+
  • Dependencies: httpx, pydantic, typing-extensions

On this page