pip command. This page covers requirements, the full constructor signature, and the environment variables involved.
Requirements
- Python 3.10 or later
langchain>=1.0httpx>=0.27
langchain and httpx are declared as required dependencies and install automatically.
Install the package
Optional dependencies
ImportGraph (Python import graph + blast-radius queries) requires networkx, which is not installed automatically. If you plan to use ImportGraph, install it separately:
The middleware,
CodebaseMemory, E-trace injection, and the local monitor suite have no dependency on networkx. You only need it if you call ImportGraph directly.API key
The SDK requires an API key to authenticate with the ReasonBlocks API. Get yours from the Quickstart page in the ReasonBlocks dashboard. Keys start withrb_live_.
Constructor parameters
Your ReasonBlocks API key. The SDK does not auto-read it from the environment.
Override the rb-api origin. When unset, the underlying HTTP clients fall back to the
REASONBLOCKS_BASE_URL env var, then to the hosted production endpoint. Set this when running rb-api on a self-hosted host or locally.Maximum token count tracked per run. Tracked-only — the FSM does not transition to
SKIP based on budget consumption; the value is exposed via TraceStateManager.get_budget_used() for callers that want to query it.Override
DifficultyFSM thresholds. Recognized keys: fast_threshold, slow_threshold, skip_threshold, hysteresis_margin, fast_window, slow_window, skip_window. Unspecified values keep their defaults. See FSM states.Map FSM state names (
"FAST", "NORMAL", "SLOW", "SKIP") to model identifiers. When the middleware enters a state with a mapping, it overrides the model for that step via request.override(model=...).When
False, E1/E2/E3 injections are not registered, so retrieval calls to rb-api never fire. The monitor steering injection still runs.Stream
run_start / step / run_finish events to rb-api as the run unfolds. Set to False for offline mode — the local step_log still populates.Server-side monitor weight preset. Built-in profiles:
coding (default), pr_review (tuned for read-only review agents), and qa (tuned for question-answering agents). The value is forwarded to /monitors/evaluate and to MonitorSteeringInjection. See Monitor profiles for the per-profile weight tables.Accepted for backward compatibility but currently a no-op. The built-in monitor suite runs server-side and ignores any local list. Custom monitors require a custom injection.
Environment variables
| Variable | Read by | Effect |
|---|---|---|
REASONBLOCKS_BASE_URL | reasonblocks._settings (at import time) | Default base URL for ReasonBlocksAPI, MonitorClient, and CodebaseMemory when base_url is not passed. Falls back to the hosted production endpoint. |
REASONBLOCKS_API_TIMEOUT | reasonblocks._settings (at import time) | HTTP timeout in seconds for the underlying clients. Defaults to 10.0. |
REASONBLOCKS_API_KEY | Not read by the SDK. | Pass it to ReasonBlocks(api_key=...) explicitly. Storing it in this env var and reading it from your own code is the conventional pattern. |
Self-hosted deployments
If you run rb-api yourself, point the SDK at it viabase_url:
REASONBLOCKS_BASE_URL is not set, the underlying clients fall back to the hosted production endpoint baked into reasonblocks._settings.DEFAULT_BASE_URL.

