# Brain Docs Brain is a typed-schema memory layer for AI agents. Text goes in through `encode`, passes a four-stage write path, and is stored as four record types — Memory, Entity, Statement, Relation — with provenance, confidence and bi-temporal validity. A Statement carries one of three kinds (`Fact | Preference | Event`), and the kind is the contract for what a later conflicting claim may do to it. `recall` fans out to three retrievers — semantic, lexical and entity-graph — fuses their ranks with Reciprocal Rank Fusion (k=60), applies a filter chain, and returns a single answer, a set, or an explicit none rather than a fabricated hit. Membership is decided by a relevance band over the whole filtered pool, never a top-K cut. A cross-encoder reranker exists but SHIPS DISABLED and is absent from the published image. Brain is ONE Rust binary: memory-mapped vector arena, WAL, redb metadata, in-RAM HNSW, a lexical index and bundled embeddings. There is no Postgres, no pgvector and no external datastore to operate. Identity is derived from API keys; every operation produces a `trace_id`. > The companion `llms-full.txt` contains every page concatenated as > markdown. Use this index to navigate; use `llms-full.txt` to ingest. ## Concepts - [Architecture](https://docs.arc-labs.ai/concepts/architecture) — Brain is one Rust binary with a strict one-way crate graph — an mmap arena, a WAL, redb, HNSW, tantivy, and bundled models, sharded thread-per-core. No external database. - [Entities](https://docs.arc-labs.ai/concepts/entities) — The entity graph backing Brain — canonical nouns with a stable EntityId, resolved per tenant, that statements are about and relations connect. - [Identity by key](https://docs.arc-labs.ai/concepts/identity-by-key) — How API keys carry tenancy in Brain — a key is bound to a (namespace, space, permissions) scope at creation, and the server derives every request's scope from it. - [Concepts](https://docs.arc-labs.ai/concepts) — Mental models for Brain — typed memory, the write/read pipelines, identity-by-key, the entity graph, and the single-binary architecture. - [Namespaces, spaces and sessions](https://docs.arc-labs.ai/concepts/namespaces) — Two isolation axes and one grouping — a namespace is the tenant wall, a space is the isolation unit that scales to a million per org, and a session is explicitly not a boundary. - [Policies](https://docs.arc-labs.ai/concepts/policies) — The knobs Brain exposes — the four enable/disable categories, per-request recall filters, and worker tuning — and where each one applies. - [Write pipeline](https://docs.arc-labs.ai/concepts/write-pipeline) — How encode works — a synchronous fast path (validate → embed → reserve → persist) split from asynchronous derivation by the WAL-fsync acknowledgement barrier. ## API Reference - [API keys](https://docs.arc-labs.ai/api/api-keys) — The admin plane for minting brain_… data-plane keys — POST/GET/DELETE /v1/api-keys on the brain-server admin listener, gated on the operator admin token over loopback. - [Authentication](https://docs.arc-labs.ai/api/authentication) — The two accepted headers, how the resolver differs between self-host and the managed gateway, what a key binds, and the whoami probe. - [Errors](https://docs.arc-labs.ai/api/errors) — The error envelope, all fifteen codes the edge emits with their statuses, how Brain's nine categories map onto them, and what is safe to retry. - [REST API overview](https://docs.arc-labs.ai/api) — Base URLs, authentication, the response and error shapes, and a reference page for every one of Brain's 60 data-plane and broker routes — plus the two health probes. - [Pagination](https://docs.arc-labs.ai/api/pagination) — Which routes page and which do not, the opaque cursor contract, and the two kinds of incompleteness Brain reports. - [Rate limits and request bounds](https://docs.arc-labs.ai/api/rate-limits) — The two independent limits — the edge's plan metering and Brain's own back-pressure — plus the body cap and request timeout. - [POST /llm/ns/{namespace}/anthropic/v1/messages](https://docs.arc-labs.ai/api/broker/anthropic-messages) — Relay a message request to Anthropic using the namespace's stored credential. - [POST /llm/ns/{namespace}/openai/v1/chat/completions](https://docs.arc-labs.ai/api/broker/openai-chat-completions) — Relay a chat completion to OpenAI using the namespace's stored credential. - [GET /llm/ns/{namespace}/resolve](https://docs.arc-labs.ai/api/broker/resolve-provider) — Resolve which provider and model a namespace's stored credential selects. - [DELETE /v1/llm-credential](https://docs.arc-labs.ai/api/credentials/delete-llm-credential) — Remove the namespace's provider key, and learn whether there was one to remove. - [GET /v1/llm-credential](https://docs.arc-labs.ai/api/credentials/get-llm-credential) — See which provider key is installed — provider, model and fingerprint, never the key. - [PUT /v1/llm-credential](https://docs.arc-labs.ai/api/credentials/put-llm-credential) — Register or replace the namespace's provider key — verified with the provider before it is stored. - [POST /v1/llm-credential/test](https://docs.arc-labs.ai/api/credentials/test-llm-credential) — Check a candidate key without storing it — safe against a namespace that already works. - [POST /v1/llm-credential/verify](https://docs.arc-labs.ai/api/credentials/verify-llm-credential) — Re-check the stored key — a key that worked at registration can be revoked later. - [POST /v1/entities](https://docs.arc-labs.ai/api/entities/create-entity) — Create an entity with a canonical name, aliases and a schema-declared type. - [GET /v1/entities/{id}](https://docs.arc-labs.ai/api/entities/get-entity) — Read one entity — its canonical name, aliases, mention count and merge lineage. - [GET /v1/entities](https://docs.arc-labs.ai/api/entities/list-entities) — Enumerate entities by type and name prefix — cursor-paged, with a required type filter. - [POST /v1/entities/{id}/merge](https://docs.arc-labs.ai/api/entities/merge-entities) — Fold one entity into another, with an audit id and a grace period you must read. - [POST /v1/entities/{id}/rename](https://docs.arc-labs.ai/api/entities/rename-entity) — Change an entity's canonical name, optionally keeping the old one as an alias. - [POST /v1/entities/resolve](https://docs.arc-labs.ai/api/entities/resolve-entity) — Ask Brain which entity a surface form means — the four outcomes, and why Ambiguous writes nothing. - [DELETE /v1/entities/{id}](https://docs.arc-labs.ai/api/entities/tombstone-entity) — Retire an entity — it leaves listings but its id keeps resolving. - [POST /v1/entities/{id}/unmerge](https://docs.arc-labs.ai/api/entities/unmerge-entity) — Reverse a merge inside its grace period — addressed by the merged id, not the survivor's. - [PUT /v1/entities/{id}](https://docs.arc-labs.ai/api/entities/update-entity) — Replace an entity's canonical name, aliases and attributes. - [GET /v1/capabilities](https://docs.arc-labs.ai/api/introspection/capabilities) — Which optional capabilities are enabled on this shard, and the vector dimension you must match. - [GET /v1/whoami](https://docs.arc-labs.ai/api/introspection/whoami) — The namespace, space and permissions the credential carries — the cheapest round trip that proves a key. - [POST /v1/memories/vector](https://docs.arc-labs.ai/api/memory/encode-vector) — Store a memory with an embedding you computed yourself, bypassing Brain's embedder. - [POST /v1/memories](https://docs.arc-labs.ai/api/memory/encode) — Store a memory from text — the write verb, its wait modes, and the deduplication result. - [DELETE /v1/memories](https://docs.arc-labs.ai/api/memory/forget) — Remove a memory — the soft tombstone, the hard zero, and why a repeat call is safe. - [GET /v1/graph](https://docs.arc-labs.ai/api/memory/graph-fetch) — A cursor-paged node and edge view of the space, for drawing — not a query. - [POST /v1/links](https://docs.arc-labs.ai/api/memory/link) — Assert a typed memory-to-memory edge, alongside the ones the write pipeline infers. - [GET /v1/memories/{id}/inspect](https://docs.arc-labs.ai/api/memory/memory-inspect) — See everything the write pipeline derived from one memory — vector, keyword fields, HyPE questions, graph and edges. - [GET /v1/memories](https://docs.arc-labs.ai/api/memory/memory-list) — Enumerate the memories in a space, cursor-paged, with filters for kind, time, salience and text. - [POST /v1/recall](https://docs.arc-labs.ai/api/memory/recall) — Retrieve memories for a cue — the Single / Many / None answer shape, scope, and the retrieval trace. - [DELETE /v1/links](https://docs.arc-labs.ai/api/memory/unlink) — Remove a memory-to-memory edge. Removing one that is not there is a success, not an error. - [POST /v1/procedural/materialize](https://docs.arc-labs.ai/api/reasoning/materialize-procedural) — Render remembered directives into a system-prompt block, with the ids that went into it. - [POST /v1/plan](https://docs.arc-labs.ai/api/reasoning/plan) — Walk from a start state to a goal across the memory graph, and get the steps back. - [POST /v1/query/explain](https://docs.arc-labs.ai/api/reasoning/query-explain) — See the plan Brain would run for a query, and its estimated cost — without running it. - [POST /v1/query/trace](https://docs.arc-labs.ai/api/reasoning/query-trace) — Run a query and get back what actually happened, with the measured latency. - [POST /v1/reason](https://docs.arc-labs.ai/api/reasoning/reason) — Draw inferences from an observation, with both the supporting and the contradicting evidence. - [POST /v1/relations](https://docs.arc-labs.ai/api/relations/create-relation) — Assert a typed, directed, time-bounded edge between two entities — and the cardinality rule that can reject it. - [GET /v1/relations/{id}](https://docs.arc-labs.ai/api/relations/get-relation) — Read one relation, including its symmetry flag and its place in the supersession chain. - [GET /v1/entities/{id}/relations](https://docs.arc-labs.ai/api/relations/list-relations) — List an entity's relations in either direction — one HTTP verb, two wire verbs. - [POST /v1/relations/{id}/supersede](https://docs.arc-labs.ai/api/relations/supersede-relation) — Replace a relation with a new version, keeping the chain readable. - [DELETE /v1/relations/{id}](https://docs.arc-labs.ai/api/relations/tombstone-relation) — Retire a relation with no replacement. There is no retract equivalent — and here is why. - [POST /v1/entities/{id}/traverse](https://docs.arc-labs.ai/api/relations/traverse-relations) — Walk the relation graph outward from an entity and get paths back — with a truncation flag you must check. - [DELETE /v1/schema/{kind}/{name}](https://docs.arc-labs.ai/api/schema/drop-schema) — Remove one declaration — and find out how many live rows still depend on it. - [GET /v1/schema](https://docs.arc-labs.ai/api/schema/get-schema) — Read the active schema document, or a specific version of it. - [GET /v1/extractors](https://docs.arc-labs.ai/api/schema/list-extractors) — The extractors bound to the active schema, and the extractor ids you attribute claims to. - [GET /v1/schemas](https://docs.arc-labs.ai/api/schema/list-schemas) — Every schema version in the namespace, and whether each one kept its source text. - [PUT /v1/schema](https://docs.arc-labs.ai/api/schema/replace-schema) — Replace the schema wholesale — and read the count of live rows it destroyed. - [POST /v1/schema](https://docs.arc-labs.ai/api/schema/upload-schema) — Publish a new schema version, with a dry run and an explicit opt-in for breaking changes. - [POST /v1/schema/validate](https://docs.arc-labs.ai/api/schema/validate-schema) — Check a schema document without storing it — with line, column and span for each error. - [POST /v1/sessions](https://docs.arc-labs.ai/api/spaces/create-session) — Create a session inside the caller's space, with an id you choose. - [POST /v1/spaces](https://docs.arc-labs.ai/api/spaces/create-space) — Provision the caller's space. Idempotent — the created flag says whether this call made it. - [DELETE /v1/sessions/{id}](https://docs.arc-labs.ai/api/spaces/delete-session) — Remove a session and its memories — tombstoned by default, zeroed with hard. - [DELETE /v1/spaces](https://docs.arc-labs.ai/api/spaces/delete-space) — Erase the caller's space and everything under it — hard, immediate and safe to retry. - [GET /v1/sessions](https://docs.arc-labs.ai/api/spaces/list-sessions) — The sessions in the caller's space, with their titles and memory counts. - [GET /v1/spaces](https://docs.arc-labs.ai/api/spaces/list-spaces) — The spaces in the caller's namespace — and the cross-shard completeness flag you must check. - [POST /v1/statements](https://docs.arc-labs.ai/api/statements/create-statement) — Write a typed claim — subject, predicate, object — and learn what it automatically superseded. - [GET /v1/statements/{id}](https://docs.arc-labs.ai/api/statements/get-statement) — Read one statement — and the supersession-following default that can hand you a different one. - [GET /v1/statements](https://docs.arc-labs.ai/api/statements/list-statements) — Query statements by subject, predicate, kind and confidence — cursor-paged. - [POST /v1/statements/{id}/retract](https://docs.arc-labs.ai/api/statements/retract-statement) — Tombstone a claim and schedule its bytes to be zeroed — and read the deadline it returns. - [GET /v1/statements/{id}/history](https://docs.arc-labs.ai/api/statements/statement-history) — Every version in a statement's supersession chain, oldest to newest. - [POST /v1/statements/{id}/supersede](https://docs.arc-labs.ai/api/statements/supersede-statement) — Correct a claim by writing its replacement — the old version stays readable and the chain records the order. - [DELETE /v1/statements/{id}](https://docs.arc-labs.ai/api/statements/tombstone-statement) — Mark a claim not-current with no replacement — this was never true. - [GET /v1/subscribe](https://docs.arc-labs.ai/api/streams/subscribe) — Open a live feed of what is landing in a space, and resume it exactly by log position. ## TypeScript SDK - [Errors](https://docs.arc-labs.ai/sdk-typescript/errors) — Both error taxonomies — the wire BrainError hierarchy with its nine categories and the eighty-odd codes, and the HTTP tier's BrainHttpError. - [HTTP client](https://docs.arc-labs.ai/sdk-typescript/http-client) — BrainHttpClient — construction, Bearer auth, base URL, timeouts, the camelCase-to-snake_case seam, and the full verb map. - [TypeScript SDK](https://docs.arc-labs.ai/sdk-typescript) — The hand-written TypeScript client for Brain — two clients over one verb vocabulary, and every operation's reference page. - [Installation](https://docs.arc-labs.ai/sdk-typescript/installation) — Install @brain-db/sdk, its one dependency, the runtime floor, and how to import each tier. - [Pagination](https://docs.arc-labs.ai/sdk-typescript/pagination) — Cursor-based enumeration on the HTTP tier, frame-based streaming on the wire, and the terminator each one uses. - [Retries](https://docs.arc-labs.ai/sdk-typescript/retries) — Both retry layers — the HTTP client's built-in policy with its idempotent-only verb list, and the wire tier's backoff primitives. - [Wire client](https://docs.arc-labs.ai/sdk-typescript/wire-client) — BrainClient over the BRN0 protocol — connect, ClientConfig, the two auth methods, act_as, multiplexing, the connection pool, and the id helpers. - [deleteLlmCredential](https://docs.arc-labs.ai/sdk-typescript/credentials/delete-llm-credential) — Remove the namespace's provider key, and learn whether there was one to remove. - [getLlmCredential](https://docs.arc-labs.ai/sdk-typescript/credentials/get-llm-credential) — See which provider key is installed — provider, model and fingerprint, never the key. - [putLlmCredential](https://docs.arc-labs.ai/sdk-typescript/credentials/put-llm-credential) — Register or replace the namespace's provider key — verified with the provider before it is stored. - [testLlmCredential](https://docs.arc-labs.ai/sdk-typescript/credentials/test-llm-credential) — Check a candidate key without storing it — safe against a namespace that already works. - [verifyLlmCredential](https://docs.arc-labs.ai/sdk-typescript/credentials/verify-llm-credential) — Re-check the stored key — a key that worked at registration can be revoked later. - [createEntity](https://docs.arc-labs.ai/sdk-typescript/entities/create-entity) — Create an entity with a canonical name, aliases and a schema-declared type. - [getEntity](https://docs.arc-labs.ai/sdk-typescript/entities/get-entity) — Read one entity — its canonical name, aliases, mention count and merge lineage. - [listEntities](https://docs.arc-labs.ai/sdk-typescript/entities/list-entities) — Enumerate entities by type and name prefix — cursor-paged, with a required type filter. - [mergeEntities](https://docs.arc-labs.ai/sdk-typescript/entities/merge-entities) — Fold one entity into another, with an audit id and a grace period you must read. - [renameEntity](https://docs.arc-labs.ai/sdk-typescript/entities/rename-entity) — Change an entity's canonical name, optionally keeping the old one as an alias. - [resolveEntity](https://docs.arc-labs.ai/sdk-typescript/entities/resolve-entity) — Ask Brain which entity a surface form means — the four outcomes, and why Ambiguous writes nothing. - [tombstoneEntity](https://docs.arc-labs.ai/sdk-typescript/entities/tombstone-entity) — Retire an entity — it leaves listings but its id keeps resolving. - [unmergeEntity](https://docs.arc-labs.ai/sdk-typescript/entities/unmerge-entity) — Reverse a merge inside its grace period — addressed by the merged id, not the survivor's. - [updateEntity](https://docs.arc-labs.ai/sdk-typescript/entities/update-entity) — Replace an entity's canonical name, aliases and attributes. - [capabilities](https://docs.arc-labs.ai/sdk-typescript/introspection/capabilities) — Which optional capabilities are enabled on this shard, and the vector dimension you must match. - [ping](https://docs.arc-labs.ai/sdk-typescript/introspection/ping) — A connection-level liveness check that works while streams are in flight. - [whoami](https://docs.arc-labs.ai/sdk-typescript/introspection/whoami) — The namespace, space and permissions the credential carries — the cheapest round trip that proves a key. - [encodeVector](https://docs.arc-labs.ai/sdk-typescript/memory/encode-vector) — Store a memory with an embedding you computed yourself, bypassing Brain's embedder. - [encode](https://docs.arc-labs.ai/sdk-typescript/memory/encode) — Store a memory from text — the write verb, its wait modes, and the deduplication result. - [forget](https://docs.arc-labs.ai/sdk-typescript/memory/forget) — Remove a memory — the soft tombstone, the hard zero, and why a repeat call is safe. - [graphFetch](https://docs.arc-labs.ai/sdk-typescript/memory/graph-fetch) — A cursor-paged node and edge view of the space, for drawing — not a query. - [link](https://docs.arc-labs.ai/sdk-typescript/memory/link) — Assert a typed memory-to-memory edge, alongside the ones the write pipeline infers. - [memoryInspect](https://docs.arc-labs.ai/sdk-typescript/memory/memory-inspect) — See everything the write pipeline derived from one memory — vector, keyword fields, HyPE questions, graph and edges. - [memoryList](https://docs.arc-labs.ai/sdk-typescript/memory/memory-list) — Enumerate the memories in a space, cursor-paged, with filters for kind, time, salience and text. - [recall](https://docs.arc-labs.ai/sdk-typescript/memory/recall) — Retrieve memories for a cue — the Single / Many / None answer shape, scope, and the retrieval trace. - [unlink](https://docs.arc-labs.ai/sdk-typescript/memory/unlink) — Remove a memory-to-memory edge. Removing one that is not there is a success, not an error. - [materializeProcedural](https://docs.arc-labs.ai/sdk-typescript/reasoning/materialize-procedural) — Render remembered directives into a system-prompt block, with the ids that went into it. - [plan](https://docs.arc-labs.ai/sdk-typescript/reasoning/plan) — Walk from a start state to a goal across the memory graph, and get the steps back. - [queryExplain](https://docs.arc-labs.ai/sdk-typescript/reasoning/query-explain) — See the plan Brain would run for a query, and its estimated cost — without running it. - [queryTrace](https://docs.arc-labs.ai/sdk-typescript/reasoning/query-trace) — Run a query and get back what actually happened, with the measured latency. - [reason](https://docs.arc-labs.ai/sdk-typescript/reasoning/reason) — Draw inferences from an observation, with both the supporting and the contradicting evidence. - [createRelation](https://docs.arc-labs.ai/sdk-typescript/relations/create-relation) — Assert a typed, directed, time-bounded edge between two entities — and the cardinality rule that can reject it. - [getRelation](https://docs.arc-labs.ai/sdk-typescript/relations/get-relation) — Read one relation, including its symmetry flag and its place in the supersession chain. - [listRelations](https://docs.arc-labs.ai/sdk-typescript/relations/list-relations) — List an entity's relations in either direction — one HTTP verb, two wire verbs. - [supersedeRelation](https://docs.arc-labs.ai/sdk-typescript/relations/supersede-relation) — Replace a relation with a new version, keeping the chain readable. - [tombstoneRelation](https://docs.arc-labs.ai/sdk-typescript/relations/tombstone-relation) — Retire a relation with no replacement. There is no retract equivalent — and here is why. - [traverseRelations](https://docs.arc-labs.ai/sdk-typescript/relations/traverse-relations) — Walk the relation graph outward from an entity and get paths back — with a truncation flag you must check. - [dropSchema](https://docs.arc-labs.ai/sdk-typescript/schema/drop-schema) — Remove one declaration — and find out how many live rows still depend on it. - [getSchema](https://docs.arc-labs.ai/sdk-typescript/schema/get-schema) — Read the active schema document, or a specific version of it. - [listExtractors](https://docs.arc-labs.ai/sdk-typescript/schema/list-extractors) — The extractors bound to the active schema, and the extractor ids you attribute claims to. - [listSchemas](https://docs.arc-labs.ai/sdk-typescript/schema/list-schemas) — Every schema version in the namespace, and whether each one kept its source text. - [replaceSchema](https://docs.arc-labs.ai/sdk-typescript/schema/replace-schema) — Replace the schema wholesale — and read the count of live rows it destroyed. - [uploadSchema](https://docs.arc-labs.ai/sdk-typescript/schema/upload-schema) — Publish a new schema version, with a dry run and an explicit opt-in for breaking changes. - [validateSchema](https://docs.arc-labs.ai/sdk-typescript/schema/validate-schema) — Check a schema document without storing it — with line, column and span for each error. - [createSession](https://docs.arc-labs.ai/sdk-typescript/spaces/create-session) — Create a session inside the caller's space, with an id you choose. - [createSpace](https://docs.arc-labs.ai/sdk-typescript/spaces/create-space) — Provision the caller's space. Idempotent — the created flag says whether this call made it. - [deleteSession](https://docs.arc-labs.ai/sdk-typescript/spaces/delete-session) — Remove a session and its memories — tombstoned by default, zeroed with hard. - [deleteSpace](https://docs.arc-labs.ai/sdk-typescript/spaces/delete-space) — Erase the caller's space and everything under it — hard, immediate and safe to retry. - [listSessions](https://docs.arc-labs.ai/sdk-typescript/spaces/list-sessions) — The sessions in the caller's space, with their titles and memory counts. - [listSpaces](https://docs.arc-labs.ai/sdk-typescript/spaces/list-spaces) — The spaces in the caller's namespace — and the cross-shard completeness flag you must check. - [createStatement](https://docs.arc-labs.ai/sdk-typescript/statements/create-statement) — Write a typed claim — subject, predicate, object — and learn what it automatically superseded. - [getStatement](https://docs.arc-labs.ai/sdk-typescript/statements/get-statement) — Read one statement — and the supersession-following default that can hand you a different one. - [listStatements](https://docs.arc-labs.ai/sdk-typescript/statements/list-statements) — Query statements by subject, predicate, kind and confidence — cursor-paged. - [retractStatement](https://docs.arc-labs.ai/sdk-typescript/statements/retract-statement) — Tombstone a claim and schedule its bytes to be zeroed — and read the deadline it returns. - [statementHistory](https://docs.arc-labs.ai/sdk-typescript/statements/statement-history) — Every version in a statement's supersession chain, oldest to newest. - [supersedeStatement](https://docs.arc-labs.ai/sdk-typescript/statements/supersede-statement) — Correct a claim by writing its replacement — the old version stays readable and the chain records the order. - [tombstoneStatement](https://docs.arc-labs.ai/sdk-typescript/statements/tombstone-statement) — Mark a claim not-current with no replacement — this was never true. - [cancelStream](https://docs.arc-labs.ai/sdk-typescript/streams/cancel-stream) — Stop an in-flight multiplexed stream server-side — abandoning the call does not. - [subscribe](https://docs.arc-labs.ai/sdk-typescript/streams/subscribe) — Open a live feed of what is landing in a space, and resume it exactly by log position. - [txnAbort](https://docs.arc-labs.ai/sdk-typescript/transactions/txn-abort) — Discard a transaction's writes without waiting for its timeout. - [txnBegin](https://docs.arc-labs.ai/sdk-typescript/transactions/txn-begin) — Open a transaction with an id you generate, and a timeout the server may lower. - [txnCommit](https://docs.arc-labs.ai/sdk-typescript/transactions/txn-commit) — Apply a transaction's writes atomically, and check that every write actually joined it. ## Python SDK - [Errors](https://docs.arc-labs.ai/sdk-python/errors) — Both taxonomies — the wire BrainError hierarchy with its typed server subclasses, and the HTTP tier's BrainHttpError. - [HTTP client](https://docs.arc-labs.ai/sdk-python/http-client) — BrainHttpClient — construction, Bearer auth, flat keyword arguments, and what the HTTP tier cannot do. - [Python SDK](https://docs.arc-labs.ai/sdk-python) — The hand-written Python client for Brain — two clients over one verb vocabulary, and every operation's reference page. - [Installation](https://docs.arc-labs.ai/sdk-python/installation) — Install brain-db-sdk, its zero dependencies, the Python floor, and how to import each of the three tiers. - [Pagination](https://docs.arc-labs.ai/sdk-python/pagination) — Cursor-based enumeration on the HTTP tier, frame-based streaming on the wire, and the terminator each one uses. - [Retries](https://docs.arc-labs.ai/sdk-python/retries) — Both retry layers — the HTTP client's automatic policy with its idempotent-only verb list, and the wire tier's with_retry combinator. - [Sync vs async](https://docs.arc-labs.ai/sdk-python/sync-vs-async) — Three tiers, two of them transports for the same protocol — how AsyncBrainClient differs from BrainClient, and why you pick one per program. - [Wire client](https://docs.arc-labs.ai/sdk-python/wire-client) — BrainClient over the BRN0 protocol — connect, ClientConfig, the two auth methods, act_as, multiplexing, the pool, and the id helpers. - [create_entity](https://docs.arc-labs.ai/sdk-python/entities/create-entity) — Create an entity with a canonical name, aliases and a schema-declared type. - [get_entity](https://docs.arc-labs.ai/sdk-python/entities/get-entity) — Read one entity — its canonical name, aliases, mention count and merge lineage. - [list_entities](https://docs.arc-labs.ai/sdk-python/entities/list-entities) — Enumerate entities by type and name prefix — cursor-paged, with a required type filter. - [merge_entities](https://docs.arc-labs.ai/sdk-python/entities/merge-entities) — Fold one entity into another, with an audit id and a grace period you must read. - [rename_entity](https://docs.arc-labs.ai/sdk-python/entities/rename-entity) — Change an entity's canonical name, optionally keeping the old one as an alias. - [resolve_entity](https://docs.arc-labs.ai/sdk-python/entities/resolve-entity) — Ask Brain which entity a surface form means — the four outcomes, and why Ambiguous writes nothing. - [tombstone_entity](https://docs.arc-labs.ai/sdk-python/entities/tombstone-entity) — Retire an entity — it leaves listings but its id keeps resolving. - [unmerge_entity](https://docs.arc-labs.ai/sdk-python/entities/unmerge-entity) — Reverse a merge inside its grace period — addressed by the merged id, not the survivor's. - [update_entity](https://docs.arc-labs.ai/sdk-python/entities/update-entity) — Replace an entity's canonical name, aliases and attributes. - [capabilities](https://docs.arc-labs.ai/sdk-python/introspection/capabilities) — Which optional capabilities are enabled on this shard, and the vector dimension you must match. - [ping](https://docs.arc-labs.ai/sdk-python/introspection/ping) — A connection-level liveness check that works while streams are in flight. - [whoami](https://docs.arc-labs.ai/sdk-python/introspection/whoami) — The namespace, space and permissions the credential carries — the cheapest round trip that proves a key. - [encode_vector](https://docs.arc-labs.ai/sdk-python/memory/encode-vector) — Store a memory with an embedding you computed yourself, bypassing Brain's embedder. - [encode](https://docs.arc-labs.ai/sdk-python/memory/encode) — Store a memory from text — the write verb, its wait modes, and the deduplication result. - [forget](https://docs.arc-labs.ai/sdk-python/memory/forget) — Remove a memory — the soft tombstone, the hard zero, and why a repeat call is safe. - [graph_fetch](https://docs.arc-labs.ai/sdk-python/memory/graph-fetch) — A cursor-paged node and edge view of the space, for drawing — not a query. - [link](https://docs.arc-labs.ai/sdk-python/memory/link) — Assert a typed memory-to-memory edge, alongside the ones the write pipeline infers. - [memory_inspect](https://docs.arc-labs.ai/sdk-python/memory/memory-inspect) — See everything the write pipeline derived from one memory — vector, keyword fields, HyPE questions, graph and edges. - [memory_list](https://docs.arc-labs.ai/sdk-python/memory/memory-list) — Enumerate the memories in a space, cursor-paged, with filters for kind, time, salience and text. - [recall](https://docs.arc-labs.ai/sdk-python/memory/recall) — Retrieve memories for a cue — the Single / Many / None answer shape, scope, and the retrieval trace. - [unlink](https://docs.arc-labs.ai/sdk-python/memory/unlink) — Remove a memory-to-memory edge. Removing one that is not there is a success, not an error. - [materialize_procedural](https://docs.arc-labs.ai/sdk-python/reasoning/materialize-procedural) — Render remembered directives into a system-prompt block, with the ids that went into it. - [plan](https://docs.arc-labs.ai/sdk-python/reasoning/plan) — Walk from a start state to a goal across the memory graph, and get the steps back. - [query_explain](https://docs.arc-labs.ai/sdk-python/reasoning/query-explain) — See the plan Brain would run for a query, and its estimated cost — without running it. - [query_trace](https://docs.arc-labs.ai/sdk-python/reasoning/query-trace) — Run a query and get back what actually happened, with the measured latency. - [reason](https://docs.arc-labs.ai/sdk-python/reasoning/reason) — Draw inferences from an observation, with both the supporting and the contradicting evidence. - [create_relation](https://docs.arc-labs.ai/sdk-python/relations/create-relation) — Assert a typed, directed, time-bounded edge between two entities — and the cardinality rule that can reject it. - [get_relation](https://docs.arc-labs.ai/sdk-python/relations/get-relation) — Read one relation, including its symmetry flag and its place in the supersession chain. - [list_relations](https://docs.arc-labs.ai/sdk-python/relations/list-relations) — List an entity's relations in either direction — one HTTP verb, two wire verbs. - [supersede_relation](https://docs.arc-labs.ai/sdk-python/relations/supersede-relation) — Replace a relation with a new version, keeping the chain readable. - [tombstone_relation](https://docs.arc-labs.ai/sdk-python/relations/tombstone-relation) — Retire a relation with no replacement. There is no retract equivalent — and here is why. - [traverse_relations](https://docs.arc-labs.ai/sdk-python/relations/traverse-relations) — Walk the relation graph outward from an entity and get paths back — with a truncation flag you must check. - [drop_schema](https://docs.arc-labs.ai/sdk-python/schema/drop-schema) — Remove one declaration — and find out how many live rows still depend on it. - [get_schema](https://docs.arc-labs.ai/sdk-python/schema/get-schema) — Read the active schema document, or a specific version of it. - [list_extractors](https://docs.arc-labs.ai/sdk-python/schema/list-extractors) — The extractors bound to the active schema, and the extractor ids you attribute claims to. - [list_schemas](https://docs.arc-labs.ai/sdk-python/schema/list-schemas) — Every schema version in the namespace, and whether each one kept its source text. - [replace_schema](https://docs.arc-labs.ai/sdk-python/schema/replace-schema) — Replace the schema wholesale — and read the count of live rows it destroyed. - [upload_schema](https://docs.arc-labs.ai/sdk-python/schema/upload-schema) — Publish a new schema version, with a dry run and an explicit opt-in for breaking changes. - [validate_schema](https://docs.arc-labs.ai/sdk-python/schema/validate-schema) — Check a schema document without storing it — with line, column and span for each error. - [create_session](https://docs.arc-labs.ai/sdk-python/spaces/create-session) — Create a session inside the caller's space, with an id you choose. - [create_space](https://docs.arc-labs.ai/sdk-python/spaces/create-space) — Provision the caller's space. Idempotent — the created flag says whether this call made it. - [delete_session](https://docs.arc-labs.ai/sdk-python/spaces/delete-session) — Remove a session and its memories — tombstoned by default, zeroed with hard. - [delete_space](https://docs.arc-labs.ai/sdk-python/spaces/delete-space) — Erase the caller's space and everything under it — hard, immediate and safe to retry. - [list_sessions](https://docs.arc-labs.ai/sdk-python/spaces/list-sessions) — The sessions in the caller's space, with their titles and memory counts. - [list_spaces](https://docs.arc-labs.ai/sdk-python/spaces/list-spaces) — The spaces in the caller's namespace — and the cross-shard completeness flag you must check. - [create_statement](https://docs.arc-labs.ai/sdk-python/statements/create-statement) — Write a typed claim — subject, predicate, object — and learn what it automatically superseded. - [get_statement](https://docs.arc-labs.ai/sdk-python/statements/get-statement) — Read one statement — and the supersession-following default that can hand you a different one. - [list_statements](https://docs.arc-labs.ai/sdk-python/statements/list-statements) — Query statements by subject, predicate, kind and confidence — cursor-paged. - [retract_statement](https://docs.arc-labs.ai/sdk-python/statements/retract-statement) — Tombstone a claim and schedule its bytes to be zeroed — and read the deadline it returns. - [statement_history](https://docs.arc-labs.ai/sdk-python/statements/statement-history) — Every version in a statement's supersession chain, oldest to newest. - [supersede_statement](https://docs.arc-labs.ai/sdk-python/statements/supersede-statement) — Correct a claim by writing its replacement — the old version stays readable and the chain records the order. - [tombstone_statement](https://docs.arc-labs.ai/sdk-python/statements/tombstone-statement) — Mark a claim not-current with no replacement — this was never true. - [cancel_stream](https://docs.arc-labs.ai/sdk-python/streams/cancel-stream) — Stop an in-flight multiplexed stream server-side — abandoning the call does not. - [subscribe](https://docs.arc-labs.ai/sdk-python/streams/subscribe) — Open a live feed of what is landing in a space, and resume it exactly by log position. - [txn_abort](https://docs.arc-labs.ai/sdk-python/transactions/txn-abort) — Discard a transaction's writes without waiting for its timeout. - [txn_begin](https://docs.arc-labs.ai/sdk-python/transactions/txn-begin) — Open a transaction with an id you generate, and a timeout the server may lower. - [txn_commit](https://docs.arc-labs.ai/sdk-python/transactions/txn-commit) — Apply a transaction's writes atomically, and check that every write actually joined it. - [delete_llm_credential](https://docs.arc-labs.ai/sdk-python/credentials/delete-llm-credential) — Remove the namespace's provider key, and learn whether there was one to remove. - [get_llm_credential](https://docs.arc-labs.ai/sdk-python/credentials/get-llm-credential) — See which provider key is installed — provider, model and fingerprint, never the key. - [put_llm_credential](https://docs.arc-labs.ai/sdk-python/credentials/put-llm-credential) — Register or replace the namespace's provider key — verified with the provider before it is stored. - [test_llm_credential](https://docs.arc-labs.ai/sdk-python/credentials/test-llm-credential) — Check a candidate key without storing it — safe against a namespace that already works. - [verify_llm_credential](https://docs.arc-labs.ai/sdk-python/credentials/verify-llm-credential) — Re-check the stored key — a key that worked at registration can be revoked later. ## Rust SDK - [Errors](https://docs.arc-labs.ai/sdk-rust/errors) — Both taxonomies — the wire BrainError enum with its nine categories and eighty-odd codes, and the HTTP tier's BrainHttpError. - [HTTP client](https://docs.arc-labs.ai/sdk-rust/http-client) — BrainHttpClient — construction, the builder configuration methods, borrowed inputs, and what the HTTP tier cannot do. - [Rust SDK](https://docs.arc-labs.ai/sdk-rust) — The hand-written Rust client for Brain — two clients over one verb vocabulary, and every operation's reference page. - [Installation](https://docs.arc-labs.ai/sdk-rust/installation) — Add brain-db-sdk to a Cargo project, its runtime requirements, and how to reach each tier. - [Pagination](https://docs.arc-labs.ai/sdk-rust/pagination) — Cursor-based enumeration on the HTTP tier, frame-based streaming on the wire, and the terminator each one uses. - [Retries](https://docs.arc-labs.ai/sdk-rust/retries) — Both retry layers — the HTTP client's automatic policy with its idempotent-only verb list, and the wire tier's with_retry combinator. - [Wire client](https://docs.arc-labs.ai/sdk-rust/wire-client) — BrainClient over the BRN0 protocol — connect, ClientConfig, the two auth methods, act_as, multiplexing, the pool, and the id helpers. - [delete_llm_credential](https://docs.arc-labs.ai/sdk-rust/credentials/delete-llm-credential) — Remove the namespace's provider key, and learn whether there was one to remove. - [get_llm_credential](https://docs.arc-labs.ai/sdk-rust/credentials/get-llm-credential) — See which provider key is installed — provider, model and fingerprint, never the key. - [put_llm_credential](https://docs.arc-labs.ai/sdk-rust/credentials/put-llm-credential) — Register or replace the namespace's provider key — verified with the provider before it is stored. - [test_llm_credential](https://docs.arc-labs.ai/sdk-rust/credentials/test-llm-credential) — Check a candidate key without storing it — safe against a namespace that already works. - [verify_llm_credential](https://docs.arc-labs.ai/sdk-rust/credentials/verify-llm-credential) — Re-check the stored key — a key that worked at registration can be revoked later. - [create_entity](https://docs.arc-labs.ai/sdk-rust/entities/create-entity) — Create an entity with a canonical name, aliases and a schema-declared type. - [get_entity](https://docs.arc-labs.ai/sdk-rust/entities/get-entity) — Read one entity — its canonical name, aliases, mention count and merge lineage. - [list_entities](https://docs.arc-labs.ai/sdk-rust/entities/list-entities) — Enumerate entities by type and name prefix — cursor-paged, with a required type filter. - [merge_entities](https://docs.arc-labs.ai/sdk-rust/entities/merge-entities) — Fold one entity into another, with an audit id and a grace period you must read. - [rename_entity](https://docs.arc-labs.ai/sdk-rust/entities/rename-entity) — Change an entity's canonical name, optionally keeping the old one as an alias. - [resolve_entity](https://docs.arc-labs.ai/sdk-rust/entities/resolve-entity) — Ask Brain which entity a surface form means — the four outcomes, and why Ambiguous writes nothing. - [tombstone_entity](https://docs.arc-labs.ai/sdk-rust/entities/tombstone-entity) — Retire an entity — it leaves listings but its id keeps resolving. - [unmerge_entity](https://docs.arc-labs.ai/sdk-rust/entities/unmerge-entity) — Reverse a merge inside its grace period — addressed by the merged id, not the survivor's. - [update_entity](https://docs.arc-labs.ai/sdk-rust/entities/update-entity) — Replace an entity's canonical name, aliases and attributes. - [capabilities](https://docs.arc-labs.ai/sdk-rust/introspection/capabilities) — Which optional capabilities are enabled on this shard, and the vector dimension you must match. - [ping](https://docs.arc-labs.ai/sdk-rust/introspection/ping) — A connection-level liveness check that works while streams are in flight. - [whoami](https://docs.arc-labs.ai/sdk-rust/introspection/whoami) — The namespace, space and permissions the credential carries — the cheapest round trip that proves a key. - [encode_vector](https://docs.arc-labs.ai/sdk-rust/memory/encode-vector) — Store a memory with an embedding you computed yourself, bypassing Brain's embedder. - [encode](https://docs.arc-labs.ai/sdk-rust/memory/encode) — Store a memory from text — the write verb, its wait modes, and the deduplication result. - [forget](https://docs.arc-labs.ai/sdk-rust/memory/forget) — Remove a memory — the soft tombstone, the hard zero, and why a repeat call is safe. - [graph_fetch](https://docs.arc-labs.ai/sdk-rust/memory/graph-fetch) — A cursor-paged node and edge view of the space, for drawing — not a query. - [link](https://docs.arc-labs.ai/sdk-rust/memory/link) — Assert a typed memory-to-memory edge, alongside the ones the write pipeline infers. - [memory_inspect](https://docs.arc-labs.ai/sdk-rust/memory/memory-inspect) — See everything the write pipeline derived from one memory — vector, keyword fields, HyPE questions, graph and edges. - [memory_list](https://docs.arc-labs.ai/sdk-rust/memory/memory-list) — Enumerate the memories in a space, cursor-paged, with filters for kind, time, salience and text. - [recall](https://docs.arc-labs.ai/sdk-rust/memory/recall) — Retrieve memories for a cue — the Single / Many / None answer shape, scope, and the retrieval trace. - [unlink](https://docs.arc-labs.ai/sdk-rust/memory/unlink) — Remove a memory-to-memory edge. Removing one that is not there is a success, not an error. - [materialize_procedural](https://docs.arc-labs.ai/sdk-rust/reasoning/materialize-procedural) — Render remembered directives into a system-prompt block, with the ids that went into it. - [plan](https://docs.arc-labs.ai/sdk-rust/reasoning/plan) — Walk from a start state to a goal across the memory graph, and get the steps back. - [query_explain](https://docs.arc-labs.ai/sdk-rust/reasoning/query-explain) — See the plan Brain would run for a query, and its estimated cost — without running it. - [query_trace](https://docs.arc-labs.ai/sdk-rust/reasoning/query-trace) — Run a query and get back what actually happened, with the measured latency. - [reason](https://docs.arc-labs.ai/sdk-rust/reasoning/reason) — Draw inferences from an observation, with both the supporting and the contradicting evidence. - [create_relation](https://docs.arc-labs.ai/sdk-rust/relations/create-relation) — Assert a typed, directed, time-bounded edge between two entities — and the cardinality rule that can reject it. - [get_relation](https://docs.arc-labs.ai/sdk-rust/relations/get-relation) — Read one relation, including its symmetry flag and its place in the supersession chain. - [list_relations](https://docs.arc-labs.ai/sdk-rust/relations/list-relations) — List an entity's relations in either direction — one HTTP verb, two wire verbs. - [supersede_relation](https://docs.arc-labs.ai/sdk-rust/relations/supersede-relation) — Replace a relation with a new version, keeping the chain readable. - [tombstone_relation](https://docs.arc-labs.ai/sdk-rust/relations/tombstone-relation) — Retire a relation with no replacement. There is no retract equivalent — and here is why. - [traverse_relations](https://docs.arc-labs.ai/sdk-rust/relations/traverse-relations) — Walk the relation graph outward from an entity and get paths back — with a truncation flag you must check. - [drop_schema](https://docs.arc-labs.ai/sdk-rust/schema/drop-schema) — Remove one declaration — and find out how many live rows still depend on it. - [get_schema](https://docs.arc-labs.ai/sdk-rust/schema/get-schema) — Read the active schema document, or a specific version of it. - [list_extractors](https://docs.arc-labs.ai/sdk-rust/schema/list-extractors) — The extractors bound to the active schema, and the extractor ids you attribute claims to. - [list_schemas](https://docs.arc-labs.ai/sdk-rust/schema/list-schemas) — Every schema version in the namespace, and whether each one kept its source text. - [replace_schema](https://docs.arc-labs.ai/sdk-rust/schema/replace-schema) — Replace the schema wholesale — and read the count of live rows it destroyed. - [upload_schema](https://docs.arc-labs.ai/sdk-rust/schema/upload-schema) — Publish a new schema version, with a dry run and an explicit opt-in for breaking changes. - [validate_schema](https://docs.arc-labs.ai/sdk-rust/schema/validate-schema) — Check a schema document without storing it — with line, column and span for each error. - [create_session](https://docs.arc-labs.ai/sdk-rust/spaces/create-session) — Create a session inside the caller's space, with an id you choose. - [create_space](https://docs.arc-labs.ai/sdk-rust/spaces/create-space) — Provision the caller's space. Idempotent — the created flag says whether this call made it. - [delete_session](https://docs.arc-labs.ai/sdk-rust/spaces/delete-session) — Remove a session and its memories — tombstoned by default, zeroed with hard. - [delete_space](https://docs.arc-labs.ai/sdk-rust/spaces/delete-space) — Erase the caller's space and everything under it — hard, immediate and safe to retry. - [list_sessions](https://docs.arc-labs.ai/sdk-rust/spaces/list-sessions) — The sessions in the caller's space, with their titles and memory counts. - [list_spaces](https://docs.arc-labs.ai/sdk-rust/spaces/list-spaces) — The spaces in the caller's namespace — and the cross-shard completeness flag you must check. - [create_statement](https://docs.arc-labs.ai/sdk-rust/statements/create-statement) — Write a typed claim — subject, predicate, object — and learn what it automatically superseded. - [get_statement](https://docs.arc-labs.ai/sdk-rust/statements/get-statement) — Read one statement — and the supersession-following default that can hand you a different one. - [list_statements](https://docs.arc-labs.ai/sdk-rust/statements/list-statements) — Query statements by subject, predicate, kind and confidence — cursor-paged. - [retract_statement](https://docs.arc-labs.ai/sdk-rust/statements/retract-statement) — Tombstone a claim and schedule its bytes to be zeroed — and read the deadline it returns. - [statement_history](https://docs.arc-labs.ai/sdk-rust/statements/statement-history) — Every version in a statement's supersession chain, oldest to newest. - [supersede_statement](https://docs.arc-labs.ai/sdk-rust/statements/supersede-statement) — Correct a claim by writing its replacement — the old version stays readable and the chain records the order. - [tombstone_statement](https://docs.arc-labs.ai/sdk-rust/statements/tombstone-statement) — Mark a claim not-current with no replacement — this was never true. - [cancel_stream](https://docs.arc-labs.ai/sdk-rust/streams/cancel-stream) — Stop an in-flight multiplexed stream server-side — abandoning the call does not. - [subscribe](https://docs.arc-labs.ai/sdk-rust/streams/subscribe) — Open a live feed of what is landing in a space, and resume it exactly by log position. - [txn_abort](https://docs.arc-labs.ai/sdk-rust/transactions/txn-abort) — Discard a transaction's writes without waiting for its timeout. - [txn_begin](https://docs.arc-labs.ai/sdk-rust/transactions/txn-begin) — Open a transaction with an id you generate, and a timeout the server may lower. - [txn_commit](https://docs.arc-labs.ai/sdk-rust/transactions/txn-commit) — Apply a transaction's writes atomically, and check that every write actually joined it. ## Recipes - [Tune salience decay](https://docs.arc-labs.ai/cookbook/decay-tuning) — Run the salience-decay worker on a faster cadence for a deployment whose memories go stale quickly — and understand why that changes what recall filters, not how it ranks. - [Walk the entity graph](https://docs.arc-labs.ai/cookbook/graph-from-chats) — Encode a transcript, list the entities the pipeline extracted, and walk the relation graph with /v1/entities and /v1/graph. - [Identity from a session JWT](https://docs.arc-labs.ai/cookbook/identity-from-jwt) — SSR pattern — verify your app's session JWT, derive the caller's (namespace, space), and run each request under that scope with act_as. - [Recipes](https://docs.arc-labs.ai/cookbook) — Copy-runnable Brain recipes — one concrete problem each, in TypeScript and Python, with the failure modes the happy path leaves out. - [Manual rate-limit backoff](https://docs.arc-labs.ai/cookbook/rate-limit-backoff) — Catch a 429 / 503, honor Retry-After, and retry — taking over from the SDK's built-in auto-retry when you need to. - [Session summary](https://docs.arc-labs.ai/cookbook/session-summary) — At session end, recall the salient memories, summarize them with your LLM, and encode the summary back as one durable memory. - [Support bot with memory](https://docs.arc-labs.ai/cookbook/support-bot-with-memory) — A minimal chatbot loop that encodes the user turn, recalls prior context before responding, and encodes the assistant reply back. ## Migration - [Migrating from mem0](https://docs.arc-labs.ai/migration/from-mem-ai) — Verb mapping, the identity model, and the differences that are not renames — the answer verdict, supersession, and where Brain is deliberately stricter. - [Migrating from supermemory](https://docs.arc-labs.ai/migration/from-supermemory) — Two retrieval paths collapsing into one, an ingestion pipeline you now own, container tags becoming a credential, and what isLatest turns into. - [Migrating from Zep](https://docs.arc-labs.ai/migration/from-zep) — Zep and Brain both build a bi-temporal knowledge graph, so this is the closest architectural port of the three — and the differences that remain are the ones worth understanding before you move. - [Switching to Brain](https://docs.arc-labs.ai/migration) — Moving from another memory layer — what ports mechanically, the four concepts that have no equivalent elsewhere, how Brain actually differs from mem0, Zep and supermemory, and a cutover plan that does not require trusting it on day one.