ReasonBlocks supports three agent frameworks: LangChain, the OpenAI Agents SDK, and the Claude Agent SDK / Claude Messages API. The full steering pipeline (FSM + monitors + E-traces + model routing) ships as a LangChain middleware, so this quickstart is LangChain-shaped. For the other two, see the OpenAI Agents guide and the Claude Agent SDK guide — both ship telemetry hooks (where applicable) and the codebase memory tool factories.
Install the SDK
Install ReasonBlocks from PyPI. Python 3.10 or later is required.
langchain>=1.0 and httpx>=0.27 are installed automatically.Get your API key
Log in to the ReasonBlocks dashboard and copy your API key from the Quickstart page. Keys start with
rb_live_.The SDK does not read environment variables for the key — your code passes it to the constructor explicitly. Storing it in an environment variable is still the recommended pattern; just read it yourself:Initialize the client
Import
ReasonBlocks and pass the API key. The client is reusable across runs — create it once at startup, then call rb.middleware() once per agent invocation.Add the middleware to your agent
Pass The middleware hooks four points in the LangChain agent loop:
rb.middleware() in the middleware list when you create your agent.before_agent— emits therun_starttelemetry event.before_model— scores the last step, advances the FSM, evaluates monitors server-side, and queues E-trace injections.wrap_model_call— overrides the model if routing applies, renders queued injections into the system message, and records token usage.after_agent— emits therun_finishtelemetry event.
Tag the run for the dashboard
rb.middleware() accepts identifying metadata. All fields are optional.monitor_runs row in rb-api and surface in the dashboard’s Runs table.When your API key is a per-customer
rb_live_* key bound to an org, rb-api overrides org_id and project_id with the key’s authoritative scope. Most callers can leave them at "default".Complete example
A minimal end-to-end script using a LangChain agent with mock tools:Next steps
Installation options
Constructor parameters and self-hosted base URLs.
How it works
The middleware lifecycle in detail.
Model routing
Map FSM states to model identifiers.
LangChain guide
Full integration walkthrough.

