Skip to main content

Brain Python SDK

Install with python -m pip install aex-brain==2.3.0. Requires Python 3.11+; there are no runtime dependencies. Import the client from brain and generated TypedDict definitions from brain.types. The wheel includes PEP 561 type data.

import os
from contextlib import closing
from brain import Brain, Model

brain = Brain('http://127.0.0.1:8080', os.environ['BRAIN_API_KEY'])
session = brain.create(harness='pi', model=Model('openai/gpt-4.1-mini'), tools=[])
message = brain.send(session['id'], {'type': 'user.message', 'text': 'Hello!'})
with closing(brain.observe(session['id'])) as events:
    for event in events:
        if event['type'] == 'assistant.message':
            print(event['data']['text'])
        if event.get('input_id') != message['id']:
            continue
        if event['type'] == 'session.error':
            raise RuntimeError(event['data']['message'])
        if event['type'] == 'session.status' and event['data']['status'] == 'idle':
            break

This is a synchronous client. timeout=30 configures the socket timeout, including stream reads. Requests are never automatically retried. BrainError preserves the HTTP status, server error code, and request ID. Closing the observer does not stop execution; call interrupt(session_id) for that.

Pass tools=[Tool(...)] to create() to run Python functions in your client. Select installed tools with ManagedTool(name). Supply private model credentials with Model(name, ApiKey(key)) or CredentialReference(reference); the server needs independent encryption keys.

The SDK owns the SSE/HTTP connection. Keep the process alive, honor context.cancelled, and call dispose() on shutdown. Use rebind() after recovery; callbacks are never automatically replayed.

Pin the package and matching server image commit recorded by the release workflow. SDK reference · Server setup

Metadata

Release files for aex-brain 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aex-brain 2.3.0
File Size Uploaded Provenance
aex_brain-2.3.0.tar.gz 9.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aex-brain 2.3.0
File Interpreter ABI Platform
aex_brain-2.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 kB

Release files / aex_brain-2.3.0.tar.gz

Download URL aex_brain-2.3.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2cbdc1071fdf97df2e5202cda2a87c208ffc77f3a3252a65694577da637ef8b4
BLAKE2b-256 checksum
How to use checksums
6f7c6119e8db624ff854afa770480c057977e5a8ba66a34c13e2899a74040137
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / aex_brain-2.3.0-py3-none-any.whl

Download URL aex_brain-2.3.0-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87446378f3fb673ad65fa4090f0a3cc223ce1cc7797d8ef50909b37f1256b246
BLAKE2b-256 checksum
How to use checksums
a6fa092404137004fe9c074220d930987d0aaf2f1452a51c6b55e0b180e232fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for aex-brain 2.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aex_brain-2.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page