Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust SDKInstallation

Installation

Add brain-db-sdk to a Cargo project, its runtime requirements, and how to reach each tier.

PURPOSE

brain-db-sdk is the published crate for the Rust client in the brain-sdk repo; the import path is brain_db_sdk. One crate carries both tiers. This page covers install, imports and versioning.

Install

cargo add brain-db-sdk
[dependencies]
brain-db-sdk = "0.4"
ParameterTypeRequired
Async runtimecaller-providedrequired

Every verb is an async fn. The crate does not start a runtime; drive the futures from whatever executor your application already runs.

ToolchainMSRV 1.75optional

Cargo.toml declares rust-version = "1.75" and edition = "2021". There are no cargo features — everything on these pages builds unconditionally.

Imports

// Wire tier
use brain_db_sdk::{
    BrainClient, ClientConfig, Auth, Pool,
    EncodeBuilder, RecallBuilder, ForgetBuilder,
    new_id, derive_space_id,
};

// HTTP tier
use brain_db_sdk::http::{BrainHttpClient, BrainHttpError, HttpRetryPolicy};

// Errors and retry
use brain_db_sdk::{BrainError, retry::{with_retry, with_default_retry, RetryPolicy}};

// Wire types — request/response structs, enums, error codes
use brain_db_sdk::wire::types::{
    ErrorCategoryWire, ErrorCodeWire, MemoryKindWire, WaitMode,
};

The crate root carries the clients and their config types, the builders, the pool, the mux and subscription types, the retry combinators and policy, the error types and SDK_VERSION. What it does not carry is the wire payload layer: the request/response structs and the enums (WaitMode, MemoryKindWire, ErrorCodeWire, …) are reached through brain_db_sdk::wire::types, and brain_db_sdk::wire itself re-exports only Frame, FrameError and Opcode.

The HTTP tier's contract types live under brain_db_sdk::http, so they do not collide with the wire types of the same name — PlanStep and Capabilities exist on both tiers with different shapes.

Versioning

The crate is pre-1.0. Minor versions may change shapes; pin an exact version in production.

The crate exports the version it was built as:

println!("brain-db-sdk {}", brain_db_sdk::SDK_VERSION);

SDK_VERSION is env!("CARGO_PKG_VERSION"), so it cannot drift from Cargo.toml — there is no second place to bump. It is safe to branch on or to attach to a bug report. Python spells the same number brain_db_sdk.__version__ and TypeScript SDK_VERSION.

All three SDKs target Brain wire protocol version 1 — the version byte in the BRN0 header, advertised as supported_versions = [1] in HELLO. A server that negotiates any other version returns BrainError::VersionMismatch rather than being best-effort decoded.

Verify the install

use brain_db_sdk::http::BrainHttpClient;

let brain = BrainHttpClient::localhost(std::env::var("BRAIN_API_KEY")?);
println!("{:?}", brain.whoami().await?);
println!("{:?}", brain.capabilities().await?);

whoami is the cheapest round trip that proves the key, the base URL and the network path all work at once.

See also
HTTP clientWire clientStart with encode

Was this page helpful?

Rust SDK

The hand-written Rust client for Brain — two clients over one verb vocabulary, and every operation's reference page.

HTTP client

BrainHttpClient — construction, the builder configuration methods, borrowed inputs, and what the HTTP tier cannot do.

On this page

InstallImportsVersioningVerify the install
Suggest an editOpen in Playground