### Get your API key
Sign in to the [MuBit console](https://console.mubit.ai) and create a key from **Settings → API keys**. Keys look like `mbt___` — three segments separated by underscores. The instance segment routes your call to the right region; the key id is safe to log; the secret is not.
```bash title=".env"
MUBIT_API_KEY="mbt___"
MUBIT_ENDPOINT="https://api.mubit.ai"
```
The SDK reads both env vars on `Client()`. Set `MUBIT_TRANSPORT="grpc"` if you need lower latency from a backend service — see [gRPC Transport](/sdk/grpc-transport).
### Install
```bash
pip install mubit-sdk python-dotenv
```
```bash
npm install @mubit-ai/sdk dotenv
```
```bash
cargo add mubit-sdk dotenvy tokio --features tokio/full
```
```bash
bun add @mubit-ai/sdk # Bun
pnpm add @mubit-ai/sdk # pnpm
yarn add @mubit-ai/sdk # Yarn
deno add npm:@mubit-ai/sdk # Deno
```
### Authenticate and make your first call
The script below stores a memory in one session and recalls it from a second session — proving cross-session memory works without any local cache. The right-hand terminal runs this exact flow.
```python title="v1_support.py"
import os
from dotenv import load_dotenv
import mubit
load_dotenv()
client = mubit.Client(endpoint=os.environ["MUBIT_ENDPOINT"])
client.set_api_key(os.environ["MUBIT_API_KEY"])
client.remember(
session_id="support:taylor:s1",
agent_id="support-agent",
user_id="taylor-1",
content="Taylor prefers concise written updates on Friday afternoons; no phone calls.",
intent="lesson",
lesson_scope="global",
)
answer = client.recall(
session_id="support:taylor:s2",
agent_id="support-agent",
user_id="taylor-1",
query="how does Taylor like updates?",
entry_types=["lesson"],
)
print(answer["final_answer"])
```
```js title="v1_support.mjs"
import "dotenv/config";
import { Client } from "@mubit-ai/sdk";
const client = new Client({ endpoint: process.env.MUBIT_ENDPOINT });
client.setApiKey(process.env.MUBIT_API_KEY);
await client.remember({
session_id: "support:taylor:s1",
agent_id: "support-agent",
user_id: "taylor-1",
content: "Taylor prefers concise written updates on Friday afternoons; no phone calls.",
intent: "lesson",
lesson_scope: "global",
});
const answer = await client.recall({
session_id: "support:taylor:s2",
agent_id: "support-agent",
user_id: "taylor-1",
query: "how does Taylor like updates?",
entry_types: ["lesson"],
});
console.log(answer.final_answer);
```
```rust title="src/main.rs"
use mubit_sdk::{Client, ClientConfig, RecallOptions, RememberOptions};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let client = Client::connect(ClientConfig::from_env()?).await?;
let mut r = RememberOptions::new(
"Taylor prefers concise written updates on Friday afternoons; no phone calls."
);
r.session_id = Some("support:taylor:s1".into());
r.agent_id = Some("support-agent".into());
r.user_id = Some("taylor-1".into());
r.intent = Some("lesson".into());
r.lesson_scope = Some("global".into());
client.remember(r).await?;
let mut q = RecallOptions::new("how does Taylor like updates?");
q.session_id = Some("support:taylor:s2".into());
q.agent_id = Some("support-agent".into());
q.user_id = Some("taylor-1".into());
q.entry_types = vec!["lesson".into()];
let answer = client.recall(q).await?;
println!("{}", answer["final_answer"]);
Ok(())
}
```
```bash
curl -X POST https://api.mubit.ai/v2/control/remember \
-H "Authorization: Bearer $MUBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "support:taylor:s1",
"agent_id": "support-agent",
"user_id": "taylor-1",
"content": "Taylor prefers concise written updates on Friday afternoons; no phone calls.",
"intent": "lesson",
"lesson_scope": "global"
}'
curl -X POST https://api.mubit.ai/v2/control/recall \
-H "Authorization: Bearer $MUBIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "support:taylor:s2",
"agent_id": "support-agent",
"user_id": "taylor-1",
"query": "how does Taylor like updates?",
"entry_types": ["lesson"]
}'
```
A successful `recall` returns roughly:
```json
{
"final_answer": "Taylor prefers to receive updates in a concise written format delivered on Friday afternoons, and explicitly dislikes receiving phone calls.",
"confidence": 1.0,
"mode": "agent_routed",
"evidence": [
{ "id": "f7bfcb26-…", "score": 1.0, "content": "Taylor prefers concise written updates on Friday afternoons; no phone calls." }
]
}
```
Didn't work? See [Troubleshooting](/sdk/troubleshooting). The two most common causes are a stale `MUBIT_API_KEY` and an HTTP/gRPC endpoint mismatch.
**Cross-session footgun:** facts (`intent="fact"`) are session-local. To recall a memory in a different session keyed by `user_id`, store it as a `lesson` with `lesson_scope="global"` — that's why the example above uses `intent="lesson"`. See [SDK helpers](/sdk/sdk-helpers#cross-session-recall) for the full set.
### Pick your path
Most readers want the drop-in. Switch only when you outgrow it.
`mubit.learn.init()` auto-instruments your existing `anthropic` / `openai` / `litellm` / `google-genai` calls. Lessons inject before the call, reflection runs on session end.
Call `remember`, `recall`, `get_context`, `archive`, `dereference` yourself when you want explicit control over sessions, agents, and metadata.
Plug MuBit into the framework's own memory interface. CrewAI, LangGraph, LangChain, LlamaIndex, ADK, Agno, Vercel AI SDK, MCP.
#### Drop-in: `mubit.learn`
```python title="learn_quickstart.py"
import os
import mubit.learn
import anthropic
mubit.learn.init(
api_key=os.environ["MUBIT_API_KEY"],
agent_id="code-reviewer",
auto_reflect=True,
)
# Existing Anthropic call now learns: lessons inject pre-call, reflection runs on session end.
resp = anthropic.Anthropic().messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=300,
messages=[{"role": "user", "content": "Review this diff..."}],
)
```
`mubit.learn.init()` patches `anthropic.Anthropic`, `openai.OpenAI`, LiteLLM, and Google GenAI client classes in place. See [LLM provider support](/sdk/llm-providers) for the full matrix and per-provider notes.
### Production checklist
Wire these up before you ship.
* **Errors and error codes** → [/api-reference/errors](/api-reference/errors)
* **Retries and idempotency** → [/sdk/retries](/sdk/retries)
* **Rate limits and headers** → [/sdk/rate-limits](/sdk/rate-limits)
* **Webhooks** (delivery + signing) → [/sdk/webhooks](/sdk/webhooks)
* **Authentication and key rotation** → [/sdk/authentication](/sdk/authentication)
* **Observability and audit trail** → [/sdk/activity-audit](/sdk/activity-audit)
### What to do next
* Inspect the full helper surface in [SDK helpers](/sdk/sdk-helpers) — `remember`, `recall`, `get_context`, `archive`, `dereference`.
* Add multi-agent coordination with [register\_agent + handoff + feedback](/recipes/multi-agent-shared-state).
* Use [temporal queries](/sdk/sdk-methods#temporal-queries) to filter by when events happened, not when they were ingested.
* Plug into your framework via [Framework integrations](/sdk/framework-integrations).
* Browse the full control surface at [Control HTTP reference](/api-reference/control-http).
Live capture from `mubit_run/v1_support.py` against `api.mubit.ai`. Switch language with the buttons in the title bar.
import { CardGroup, Card, Note, Warning, Tip, Steps, Step, Frame, Accordion, Tabs, Tab, MubitTerminal, PageHeader } from '@components'