SDK Configuration Reference
Environment variables, scope resolution, transport selection, endpoint defaults, and client options for Mubit SDKs.
All Mubit SDKs (Python, Node.js, Rust) share one configuration model: explicit arguments first, then with_options / scope context, then environment variables. The SDK never reads an environment variable at import time; everything is resolved when mubit.init() or Client() runs.
Environment variables
The console shows the first four with every new key; copy them as one block.
| Variable | Meaning | Status in 0.14 |
|---|---|---|
MUBIT_API_KEY | API key in the format mbt_<instance>_<key_id>_<secret> | keep (Rust MUBIT_TOKEN is a deprecated alias) |
MUBIT_ENDPOINT | Base endpoint for HTTP and gRPC; the SDK resolves the protocol | keep |
MUBIT_PROJECT | Default scope: project | keep (MUBIT_PROJECT_ID is a deprecated alias) |
MUBIT_ENV | Default scope: environment (default dev) | keep |
MUBIT_AGENT, MUBIT_USER, MUBIT_RUN_ID | Default scope: agent, user, run id | MUBIT_AGENT and MUBIT_USER new |
MUBIT_HTTP_ENDPOINT, MUBIT_GRPC_ENDPOINT | Protocol-specific endpoint overrides | keep |
MUBIT_TRANSPORT | auto, http or grpc | keep |
MUBIT_ACTOR, MUBIT_PRINCIPAL | x-mubit-actor and x-mubit-principal headers (worker, manager, admin; can only lower the key's kind) | keep |
MUBIT_DISABLED | 1: no-op mode; every helper returns its typed empty value with reason="disabled", no network | new (MUBIT_LOOP_DISABLED is a deprecated alias) |
MUBIT_LOG | warn, info or debug: SDK logging. Python attaches a stderr handler to the mubit logger; JS enables debug() output | new (MUBIT_LOOP_DEBUG is a deprecated alias of MUBIT_LOG=debug) |
MUBIT_ON_ERROR | warn or raise: default failure policy for the global helpers | new |
MUBIT_TIMEOUT_MS | Request timeout (default 30000) | new |
MUBIT_CONNECT_TIMEOUT_MS | Connect timeout, also the gRPC readiness wait before HTTP fallback (default 2000) | new |
MUBIT_MAX_RETRIES | Retries on 429/5xx and transient transport errors (default 2) | new (MUBIT_RETRY_ATTEMPTS is a deprecated alias equal to MUBIT_MAX_RETRIES + 1) |
MUBIT_RETRY_BASE_MS, MUBIT_RETRY_CAP_MS, MUBIT_RETRY_JITTER | Backoff tuning | keep |
MUBIT_CONSOLE_URL | Base URL for the run links the SDK prints at MUBIT_LOG=info | new |
MUBIT_RECALL_MODE | Default recall mode for every recall entry point | keep |
MUBIT_LEARN_EXTRACT, MUBIT_LEARN_CONTEXT_TIMEOUT, MUBIT_LEARN_ATTRIBUTION_TIMEOUT, MUBIT_CONTROL_REVIEW_ENABLED, MUBIT_CONTROL_PROD_VERIFIED_BOOST | Learn-path internals | deprecated; use mubit.init(inject=InjectOptions(...), capture=CaptureOptions(...)) |
MUBIT_API_KEY="mbt_<instance>_<key_id>_<secret>"
MUBIT_ENDPOINT="https://api.mubit.ai"
MUBIT_PROJECT="first-project"
MUBIT_ENV="dev"Scoping
project → env → agent → user → run → step
(thread = conversation id carried on events)Lessons are partitioned by env (MUBIT_ENV, default dev). project and agent label lessons but do not isolate them; what another run sees is decided by the policy's overlay gate. A context() call in a different env returns zero units; the returned ContextBlock.scope shows which project/env was used.
Resolution order per scope field, first wins:
- Explicit call argument (
mubit.run(env="prod"),client.memory.recall(..., run_id=...)) client.with_options(scope=...)ormubit.scope(...)context- The active
run/stepcontext - The
mubit.init()/Client()default scope - Environment (
MUBIT_PROJECT,MUBIT_ENV,MUBIT_AGENT,MUBIT_USER,MUBIT_RUN_ID)
ContextBlock.scope and OutcomeReceipt echo the resolved project, env and agent, so a mismatch is visible in the return value. mubit doctor prints the same resolution as its scope: line.
Write-time visibility is one field, visibility="run" | "agent" | "project" | "global" (replaces lesson_scope and share). session_id is accepted as a deprecated alias: of run_id on memory calls and of thread on mubit.run().
Transport selection
The transport option controls how the SDK communicates with Mubit:
| Value | Behavior |
|---|---|
auto (default) | SDK probes gRPC readiness for connect_timeout and falls back to HTTP |
http | Force HTTP/REST transport |
grpc | Force gRPC transport |
The loop routes (/v2/loop/*) are HTTP in every transport mode.
Endpoint defaults
| Context | HTTP endpoint | gRPC endpoint |
|---|---|---|
| Hosted (production) | https://api.mubit.ai | grpc.api.mubit.ai:443 |
| Hosted (dev) | https://api.dev.mubit.ai | grpc.api.dev.mubit.ai:443 |
| Local | http://127.0.0.1:3000 | 127.0.0.1:50051 |
Both hosted endpoints use TLS. Local endpoints are plaintext.
mubit.init() and Client() default to https://api.mubit.ai. Set MUBIT_ENDPOINT explicitly anyway: the CLI and the deprecated learn path still default to the local address in 0.14, and the SDK prints one warning when a local default is used without MUBIT_ENDPOINT. The four-line .env block from the console sets it.
Client options
Client takes keyword options only; Client(endpoint) positional is accepted until 1.0.
| Option | Type | Default | Description |
|---|---|---|---|
api_key / apiKey | string | MUBIT_API_KEY | API key |
endpoint | string | MUBIT_ENDPOINT | Base endpoint |
transport | string | auto | auto, http or grpc |
timeout / timeoutMs | number | 30 s | Request timeout |
connect_timeout / connectTimeoutMs | number | 2 s | Connect timeout |
max_retries / maxRetries | int | 2 | Retries on 429/5xx |
on_error / onError | "raise", "warn", callable | "raise" | Failure policy (see below) |
scope | Scope | from env | Default project, env, agent, user, run_id, thread |
principal, actor | string | from env | Request headers |
disabled | bool | false | No-op mode |
client.with_options(timeout=..., max_retries=..., scope=..., on_error=...) returns a client with the overrides applied. mubit.init() takes the same options plus agent, env, project, user, run_id, inject=InjectOptions(...), capture=CaptureOptions(...), instrument, console_url and defaults on_error to "warn".
Failure policy
| Setting | Values | Default | Effect |
|---|---|---|---|
on_error on mubit.init() | "warn", "raise", callable | "warn" | warn: one WARNING per endpoint and failure class, then fail open. Reads (context, recall, capabilities) return a typed empty value with degraded=True and a reason; writes (events, outcome, remember) are buffered and retried, and on_error fires on final failure |
on_error on Client() | same | "raise" | Errors mirror the server status table (AuthenticationError, NotFoundError, RateLimitError, …); see Errors |
policy, kill, jobs, proposals, snapshots namespaces | always raise | Control-plane writes are never silently dropped | |
disabled / MUBIT_DISABLED=1 | off | Every helper returns its typed empty value with reason="disabled"; no network |
The legacy fail_open=True / fail_open=False booleans are accepted as aliases of on_error="warn" / "raise" until 1.0.
Next steps
- See Quickstart for the two-run loop.
- See gRPC Transport Guide for gRPC-specific guidance.
- See Migration for every renamed variable and option.