Python SDK for the Cerebe Cognitive Services Platform
Project description
cerebe
Python SDK for the Cerebe Cognitive Services Platform — memory, knowledge graphs, meta-learning, and agent tooling.
Installation
pip install cerebe
Quick Start
from cerebe import Cerebe
client = Cerebe(api_key="ck_live_xxx", project="proj_xxx")
# Store a memory
client.memory.add(
"User prefers dark mode",
"sess_123",
type="semantic",
importance=0.8,
)
# Search memories
results = client.memory.search("user preferences", "sess_123")
print(results.data)
Async
from cerebe import AsyncCerebe
async with AsyncCerebe(api_key="ck_live_xxx") as client:
results = await client.memory.search("user preferences", "sess_123")
Every method available on Cerebe has an identical async counterpart on AsyncCerebe.
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str |
— | Required. Your Cerebe API key |
project |
str |
"" |
Project identifier |
base_url |
str |
https://api.cerebe.ai |
API base URL |
timeout |
float |
30.0 |
Request timeout (seconds) |
max_retries |
int |
3 |
Max retries on 429/5xx |
Environment variable fallbacks: CEREBE_API_KEY, CEREBE_PROJECT, CEREBE_BASE_URL.
API Reference
Memory — client.memory
| Method | Description |
|---|---|
add(content, session_id, ...) |
Store a memory |
search(query, session_id, ...) |
Semantic similarity search |
get(memory_id) |
Get a memory by ID |
update(memory_id, ...) |
Update memory properties |
delete(memory_id) |
Delete a memory |
session(session_id, ...) |
Get all memories for a session |
relationships(source, target, type) |
Create memory relationship |
query_tune(session_id, message) |
Tune query for retrieval |
harvest(session_id, transcript, ...) |
Extract memories from transcript |
consolidate(entity_id, ...) |
Merge near-duplicate memories |
Memory types: episodic, semantic, procedural, sequential, execution_history, plan, tool_reliability, working, declarative
# Store with full options
client.memory.add(
"Learned quadratic formula today",
"sess_123",
type="episodic",
importance=0.9,
entity_id="user_42",
metadata={"subject": "math"},
)
# Search with filters
results = client.memory.search(
"math concepts",
"sess_123",
types=["episodic", "semantic"],
min_importance=0.5,
limit=10,
)
# Harvest memories from conversation
client.memory.harvest(
"sess_123",
"User: I find visual explanations helpful...",
entity_id="user_42",
)
Knowledge — client.knowledge
| Method | Description |
|---|---|
ingest(content, ...) |
Add content to the knowledge graph |
query(query, ...) |
Query the knowledge graph |
entities(...) |
List entities |
visualize(query, ...) |
Get graph visualization data |
client.knowledge.ingest(
"Photosynthesis converts light energy to chemical energy",
entity_id="biology_101",
source="textbook",
)
graph = client.knowledge.query("photosynthesis", depth=3)
Storage — client.storage
| Method | Description |
|---|---|
upload(content, filename, content_type) |
Upload file (base64) |
presigned_upload(file_name, file_type, ...) |
Get presigned upload URL |
get(upload_id) |
Get file metadata |
get_url(upload_id) |
Get ephemeral download URL |
file_url(file_id) |
Get download URL by file ID |
check_hash(content_hash) |
Deduplication check |
analyze_content(upload_id, ...) |
Analyze file content |
extract(url, ...) |
Extract content from URL |
# Get presigned upload URL
result = client.storage.presigned_upload(
file_name="essay.pdf",
file_type="application/pdf",
file_size=102400,
content_hash="sha256_abc123",
tenant_id="tenant_1",
)
# Analyze uploaded content
client.storage.analyze_content("up_123", context="student_homework")
Meta-Learning — client.meta_learning
| Method | Description |
|---|---|
analyze(user_id, ...) |
Analyze learning patterns |
profile(user_id) |
Get learner profile |
plre_transition(user_id, session_id, ...) |
Trigger PLRE phase transition |
plre_state(user_id, ...) |
Get current PLRE state |
profile = client.meta_learning.profile("user_42")
state = client.meta_learning.plre_state("user_42", session_id="sess_123")
Agents — client.agents
| Method | Description |
|---|---|
ingest_trace(content, session_id, ...) |
Store agent execution trace |
set_working_memory(content, session_id, ...) |
Set session working memory |
get_working_memory(session_id) |
Get session working memory |
# Ingest an agent trace
client.agents.ingest_trace(
"Called search tool with query 'quadratic formula'",
"sess_123",
metadata={"tool": "search", "latency_ms": 120},
)
# Set working memory with TTL
client.agents.set_working_memory(
"Current task: help user with algebra homework",
"sess_123",
ttl_seconds=3600,
)
Sessions — client.sessions
| Method | Description |
|---|---|
list() |
List all sessions |
get(session_id) |
Get session details |
update(session_id, cognitive_state) |
Update cognitive state |
delete(session_id) |
Delete a session |
cleanup() |
Clean up expired sessions |
Graph — client.graph
| Method | Description |
|---|---|
traverse(...) |
Traverse from a starting entity |
temporal(entity_id, as_of_date) |
Temporal entity view |
neighbors(entity_id) |
Get immediate neighbors |
Error Handling
from cerebe import Cerebe
from cerebe._errors import (
AuthenticationError,
NotFoundError,
RateLimitError,
ValidationError,
ServerError,
)
client = Cerebe(api_key="ck_live_xxx")
try:
client.memory.get("mem_nonexistent")
except NotFoundError:
print("Memory not found")
except RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
except AuthenticationError:
print("Invalid API key")
| Error Class | HTTP Status | Description |
|---|---|---|
AuthenticationError |
401 | Invalid or missing API key |
NotFoundError |
404 | Resource not found |
ValidationError |
400, 422 | Invalid request parameters |
RateLimitError |
429 | Rate limit exceeded |
ServerError |
5xx | Server-side error |
Retries
The SDK automatically retries on:
- 429 (Rate Limited) — respects
Retry-Afterheader - 5xx (Server Error) — exponential backoff
Set max_retries=0 to disable.
Type Safety
The SDK is fully typed with py.typed marker (PEP 561).
Works with mypy, pyright, and IDE autocomplete.
from cerebe.resources.memory import MemoryType
memory_type: MemoryType = "semantic" # type-checked literal
Requirements
- Python >= 3.10
- httpx >= 0.25.0
- pydantic >= 2.0.0
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cerebe-0.4.2.tar.gz.
File metadata
- Download URL: cerebe-0.4.2.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4a2ff346546d790d4eb3b48f6a9c7e48a4b1a558633e789683ef5a3bf7825d4
|
|
| MD5 |
d1df48482e05a5d5a8b299a0c45cd522
|
|
| BLAKE2b-256 |
219f11e3a98d7aab6bcdbfb31e88e87d9ed4f60d9458e322002b54e66e249f06
|
Provenance
The following attestation bundles were made for cerebe-0.4.2.tar.gz:
Publisher:
sdk-release.yml on momentiq-ai/cerebe-platform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cerebe-0.4.2.tar.gz -
Subject digest:
b4a2ff346546d790d4eb3b48f6a9c7e48a4b1a558633e789683ef5a3bf7825d4 - Sigstore transparency entry: 1284154191
- Sigstore integration time:
-
Permalink:
momentiq-ai/cerebe-platform@c2306f1bce3cde3591c2a347c434135317278f8a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/momentiq-ai
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@c2306f1bce3cde3591c2a347c434135317278f8a -
Trigger Event:
push
-
Statement type:
File details
Details for the file cerebe-0.4.2-py3-none-any.whl.
File metadata
- Download URL: cerebe-0.4.2-py3-none-any.whl
- Upload date:
- Size: 28.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
269807ed7121bc509783fd89a2e9c561fe12e28aba2e98f37883f612e0636413
|
|
| MD5 |
27c97a5c60f70a2a17b5b5fdacc26acc
|
|
| BLAKE2b-256 |
5d8d00ae842538721f4084910d720ef27ed1e7da5105eac3882a117e651dadf0
|
Provenance
The following attestation bundles were made for cerebe-0.4.2-py3-none-any.whl:
Publisher:
sdk-release.yml on momentiq-ai/cerebe-platform
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cerebe-0.4.2-py3-none-any.whl -
Subject digest:
269807ed7121bc509783fd89a2e9c561fe12e28aba2e98f37883f612e0636413 - Sigstore transparency entry: 1284154387
- Sigstore integration time:
-
Permalink:
momentiq-ai/cerebe-platform@c2306f1bce3cde3591c2a347c434135317278f8a -
Branch / Tag:
refs/heads/main - Owner: https://github.com/momentiq-ai
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
sdk-release.yml@c2306f1bce3cde3591c2a347c434135317278f8a -
Trigger Event:
push
-
Statement type: