Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content
Platform

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.

VariableMeaningStatus in 0.14
MUBIT_API_KEYAPI key in the format mbt_<instance>_<key_id>_<secret>keep (Rust MUBIT_TOKEN is a deprecated alias)
MUBIT_ENDPOINTBase endpoint for HTTP and gRPC; the SDK resolves the protocolkeep
MUBIT_PROJECTDefault scope: projectkeep (MUBIT_PROJECT_ID is a deprecated alias)
MUBIT_ENVDefault scope: environment (default dev)keep
MUBIT_AGENT, MUBIT_USER, MUBIT_RUN_IDDefault scope: agent, user, run idMUBIT_AGENT and MUBIT_USER new
MUBIT_HTTP_ENDPOINT, MUBIT_GRPC_ENDPOINTProtocol-specific endpoint overrideskeep
MUBIT_TRANSPORTauto, http or grpckeep
MUBIT_ACTOR, MUBIT_PRINCIPALx-mubit-actor and x-mubit-principal headers (worker, manager, admin; can only lower the key's kind)keep
MUBIT_DISABLED1: no-op mode; every helper returns its typed empty value with reason="disabled", no networknew (MUBIT_LOOP_DISABLED is a deprecated alias)
MUBIT_LOGwarn, info or debug: SDK logging. Python attaches a stderr handler to the mubit logger; JS enables debug() outputnew (MUBIT_LOOP_DEBUG is a deprecated alias of MUBIT_LOG=debug)
MUBIT_ON_ERRORwarn or raise: default failure policy for the global helpersnew
MUBIT_TIMEOUT_MSRequest timeout (default 30000)new
MUBIT_CONNECT_TIMEOUT_MSConnect timeout, also the gRPC readiness wait before HTTP fallback (default 2000)new
MUBIT_MAX_RETRIESRetries 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_JITTERBackoff tuningkeep
MUBIT_CONSOLE_URLBase URL for the run links the SDK prints at MUBIT_LOG=infonew
MUBIT_RECALL_MODEDefault recall mode for every recall entry pointkeep
MUBIT_LEARN_EXTRACT, MUBIT_LEARN_CONTEXT_TIMEOUT, MUBIT_LEARN_ATTRIBUTION_TIMEOUT, MUBIT_CONTROL_REVIEW_ENABLED, MUBIT_CONTROL_PROD_VERIFIED_BOOSTLearn-path internalsdeprecated; use mubit.init(inject=InjectOptions(...), capture=CaptureOptions(...))
.env
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:

  1. Explicit call argument (mubit.run(env="prod"), client.memory.recall(..., run_id=...))
  2. client.with_options(scope=...) or mubit.scope(...) context
  3. The active run / step context
  4. The mubit.init() / Client() default scope
  5. 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:

ValueBehavior
auto (default)SDK probes gRPC readiness for connect_timeout and falls back to HTTP
httpForce HTTP/REST transport
grpcForce gRPC transport

The loop routes (/v2/loop/*) are HTTP in every transport mode.

from mubit import Client
 
# From environment (default)
client = Client()
 
# Force gRPC
client = Client(transport="grpc")
 
# Force HTTP with an explicit key and endpoint
client = Client(
    api_key="mbt_...",
    transport="http",
    endpoint="https://custom.api.mubit.ai",
)

Endpoint defaults

ContextHTTP endpointgRPC endpoint
Hosted (production)https://api.mubit.aigrpc.api.mubit.ai:443
Hosted (dev)https://api.dev.mubit.aigrpc.api.dev.mubit.ai:443
Localhttp://127.0.0.1:3000127.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.

OptionTypeDefaultDescription
api_key / apiKeystringMUBIT_API_KEYAPI key
endpointstringMUBIT_ENDPOINTBase endpoint
transportstringautoauto, http or grpc
timeout / timeoutMsnumber30 sRequest timeout
connect_timeout / connectTimeoutMsnumber2 sConnect timeout
max_retries / maxRetriesint2Retries on 429/5xx
on_error / onError"raise", "warn", callable"raise"Failure policy (see below)
scopeScopefrom envDefault project, env, agent, user, run_id, thread
principal, actorstringfrom envRequest headers
disabledboolfalseNo-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

SettingValuesDefaultEffect
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 namespacesalways raiseControl-plane writes are never silently dropped
disabled / MUBIT_DISABLED=1offEvery 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