Skip to main content

Official Python SDK for Cerebrio — agentic AI knowledge infrastructure

Project description

cerebrio-py

Official Python SDK for Cerebrio — agentic AI knowledge infrastructure.

PyPI version Python versions License

Install

pip install cerebrio-py
# or with uv:
uv add cerebrio-py

Requires Python 3.12+.

Quickstart

from cerebrio import CerebrioClient
from cerebrio.contracts.dtos.common import EntityScope
from cerebrio.contracts.enums.common import EpistemicScope
from uuid import uuid4

# Authenticate with either a JWT or an API key (cb_<actor_short>_<secret>)
client = CerebrioClient(
    base_url="https://api.thecerebrio.ai",
    bearer_token="cb_xxxxxxxx_xxxxxxxxxxxxxxxx",
)

# Health probe (the only unauthenticated route)
print(client.health())  # {'status': 'healthy', 'checks': {'database': 'ok'}}

# Who am I?
me = client.actors.me()
print(me.actor_id, me.default_workspace_id, len(me.workspaces), "workspaces")

# Remember something
scope = EntityScope(scope=EpistemicScope.PRIVATE, actor_id=me.actor_id)
response = client.memory.remember(
    text="Marie Curie discovered radium in 1898.",
    scope=scope,
)
print(response.results[0].outcome)  # WriteOutcome.CREATED

# Recall semantically
from cerebrio.contracts.dtos.recall_request import SemanticRecallRequest
result = client.memory.recall(
    SemanticRecallRequest(scope=scope, query="who discovered radium?", limit=5)
)
for hit in result.entities:
    print(hit.id, hit.description)

Namespaces

The client exposes one sub-namespace per capability tree, mirroring https://api.thecerebrio.ai/core/docs:

Namespace Surface
client.memory remember, recall, upload, forget, maintain, promote
client.decisions trace, precedents
client.actors me, list, create, get, patch, audit, credentials, permissions, suspend, restore, deprovision, .api_keys (issue/list/revoke), .invitations (list/accept/decline)
client.governance .policies, .role_assignments, .relationships, list_authorized
client.orgs CRUD + .members (list/add/update_role/remove)
client.workspaces CRUD + .members
client.projects CRUD + .members
client.health() Liveness probe (unauthenticated)

Authentication

Every route except /health requires Authorization: Bearer <token>. Token can be:

  • a JWT issued by your IdP (Logto / Auth0 / etc. depending on your Cerebrio deployment)
  • a cerebrio API key in the format cb_<actor_short>_<secret> (issued via client.actors.api_keys.issue(...))
# Construct with a token:
client = CerebrioClient(base_url=..., bearer_token="<jwt-or-cb-key>")
# or use the api_key alias:
client = CerebrioClient(base_url=..., api_key="cb_xxx_yyy")

# Rotate at runtime:
client.set_bearer_token("<new-jwt>")

Compatibility

See COMPATIBILITY.md for the SDK ↔ server version matrix.

SDK Server (cerebrio-core) Status
0.1.0 v2.9.x (Phase 34 actor identity + Phase 35 space hierarchy) First release

What's coming in 0.2.0

Gated on cerebrio-core shipping v2.10.0 (Phase 36 — console launch surface):

  • client.memory.list_entities() / get_entity() / get_relationships()
  • client.decisions.list_traces() / get_trace()
  • client.actors.api_keys.revoke_admin() (admin-side key revoke)

Security disclosure

During the SDK sync audit we surfaced four authorization gaps in the server (not in this SDK):

Bug Severity Surface
BUG-067 P0 /governance/v1/* — token holders can rewrite RBAC/ReBAC
BUG-068 P0 /actors/v1/* (non-/me) — token holders can create/PATCH/suspend any actor
BUG-069 P0 /decisions/v1/traceactor_id taken from body, audit-trail forgery
BUG-070 P1 /decisions/v1/precedents — cross-tenant precedent leak

These are server-side and tracked in cerebrio-sapience backlog. The SDK itself does not amplify them. Once the server fixes ship, SDK callers will receive 403 where appropriate — no SDK code change required.

Development

git clone https://github.com/avinash-singh-io/cerebrio-py.git
cd cerebrio-py
uv venv && uv pip install -e ".[dev]"
uv run pytest                       # 54 unit tests
uv run mypy --strict src/cerebrio   # type check
uv run ruff check src tests         # lint

Contributing

Bug reports and PRs welcome via GitHub Issues.

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cerebrio_py-0.2.0.tar.gz (56.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cerebrio_py-0.2.0-py3-none-any.whl (74.4 kB view details)

Uploaded Python 3

File details

Details for the file cerebrio_py-0.2.0.tar.gz.

File metadata

  • Download URL: cerebrio_py-0.2.0.tar.gz
  • Upload date:
  • Size: 56.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cerebrio_py-0.2.0.tar.gz
Algorithm Hash digest
SHA256 78380ccb330341e4d568de18fe1b957b10c24ae4f777de72f931c279bbdd66c9
MD5 b307e825e11beca7b291171f3957ffb2
BLAKE2b-256 351f6ec7ceb5614b01758baf1f53a3deab97c43aac650abdd1af3c0a4f4a5c93

See more details on using hashes here.

Provenance

The following attestation bundles were made for cerebrio_py-0.2.0.tar.gz:

Publisher: release.yml on avinash-singh-io/cerebrio-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cerebrio_py-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cerebrio_py-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 74.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cerebrio_py-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b6ed7fb8073c9f71ad70289afe412e8f4dac4945d07116bb037858b063a9a63
MD5 f57a657a14a1e0539ec0f553e587ca30
BLAKE2b-256 e21bde6652ff27b7f1312e0588f0fde682d94dffd3123c340109b67b44e8d10c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cerebrio_py-0.2.0-py3-none-any.whl:

Publisher: release.yml on avinash-singh-io/cerebrio-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page