Coding agents
Run supported coding agents through BitRouter interactively, headlessly, or in their native interface.
BitRouter separates the agent harness that drives the loop from the model source that supplies tokens. The same Claude, Codex, OpenCode, or Pi harness can use a hosted model, a subscription, or a model running on your machine.
Choose the interface
| Goal | Command | Interface owner |
|---|---|---|
| Work in BitRouter's conversation | bro code <agent> | BitRouter |
| Run one turn from a script | bro run <agent> "..." | BitRouter, headless |
| Use the harness's own terminal UI | bro launch <agent> | The harness |
| Let another ACP client launch the adapter | bro acp serve <agent> | The ACP client |
bro code codex
bro run claude "Review the current diff" --format quiet
bro launch opencodebro code, bro run, and bro acp serve use ACP adapters. bro launch starts the harness's native interface with process-local routing overrides. It does not rewrite the user's normal harness configuration.
Supported agents
Run bro agents list for the catalog shipped by your installed version. Alpha.31 includes local ACP adapters for Claude, Codex, Gemini CLI, OpenCode, Pi, Hermes, and OpenClaw.
| Friendly id | ACP adapter | Native launch |
|---|---|---|
claude | claude-acp | bro claude or bro launch claude |
codex | codex-acp | bro codex or bro launch codex |
opencode | opencode | bro launch opencode |
pi | pi-acp | bro launch pi |
hermes | hermes-acp | bro launch hermes |
openclaw | openclaw | bro launch openclaw |
gemini-cli | gemini-cli | ACP only in the bundled catalog |
Use bro agents check <agent> before a long task. It verifies that the adapter can initialize and reports whether its model traffic can be routed through BitRouter.
What launch changes
For Claude and Codex, BitRouter passes temporary environment variables or command-line overrides. For OpenCode, Pi, Hermes, and OpenClaw, it writes a generated profile under the working tree's self-ignoring .bitrouter/launch/ directory and points only the child process at it.
bro launch pi --model bitrouter/auto
bro launch codex --check
bro launch claude -- --permission-mode planArguments after -- belong to the harness. BitRouter options such as --model, --base-url, and --check must come before it.
Supported native harnesses also receive the aggregate MCP gateway when they expose a compatible injection mechanism. The launch summary states what was actually routed or injected; Pi and some other harnesses do not expose an MCP injection surface.
Other harnesses
If a harness is not in the catalog, configure it as a normal API client:
| Protocol | Local base URL | Cloud base URL |
|---|---|---|
| OpenAI-compatible | http://127.0.0.1:4356/v1 | https://api.bitrouter.ai/v1 |
| Anthropic-compatible | http://127.0.0.1:4356 | https://api.bitrouter.ai |
Use a provider/model id where the harness accepts a model name. Product-specific configuration keys belong to that harness's documentation; BitRouter only owns the endpoint and routing contract.
Claude Code
Claude Code owns the agent loop and tools. BitRouter supplies its model route, fallback, policy, and metering.
Pick a mode
bro code claude # BitRouter conversation
bro run claude "Summarize this repo" # headless ACP turn
bro claude # Claude Code's native interfacebro launch claude is the generic spelling of bro claude. Both use temporary environment variables for the child process and do not edit Claude Code's user or project settings.
Before launching, verify the executable, daemon, and route:
bro launch claude --checkIf the Claude executable is missing, the launcher can offer Claude's official installer. Use --no-install when an automated environment should fail instead.
Select a Claude model
Pin a daemon-routable model before the -- separator:
bro claude --model bitrouter/auto
bro launch claude --model anthropic/claude-sonnet-4-6Arguments after -- go directly to Claude Code:
bro launch claude -- --permission-mode planConfigure Claude Code manually
Use manual environment variables only when Claude Code must start outside bro launch. Claude Code appends /v1/messages, so the base URL is the host root:
export ANTHROPIC_BASE_URL=http://127.0.0.1:4356
export ANTHROPIC_AUTH_TOKEN=local-placeholder
export ANTHROPIC_MODEL=bitrouter/auto
claudeFor Cloud, use https://api.bitrouter.ai and set ANTHROPIC_AUTH_TOKEN to a BitRouter key. An authenticated self-hosted daemon likewise requires a valid BitRouter key instead of the placeholder.
Use a Claude subscription
The claude-code provider uses a Claude Pro or Max credential instead of an Anthropic API key. It is separate from the standard anthropic provider, but it can be used with the Claude Code harness described above.
Sign in:
bro providers login claude-codeBitRouter adopts a compatible local Claude Code login when possible and otherwise starts the provider's login flow. The stored credential refreshes automatically; no providers: block is required.
Verify the models and route:
bro models --provider claude-code
bro route claude-code:claude-sonnet-4-6Use the provider-qualified id to require the subscription source. A request routed to anthropic:<model> uses ANTHROPIC_API_KEY instead.
Then launch any Claude Code mode normally:
bro start
bro claude
# or: bro code claude
# or: bro run claude "Summarize this repo"Sign out with:
bro providers logout claude-codeThis removes BitRouter's stored subscription credential and route. It does not modify Claude Code's own configuration.
Provider login and BitRouter Cloud login are separate. bro providers login claude-code authenticates the upstream subscription; bro cloud login authenticates your BitRouter account.
Codex
Codex owns the agent loop and tools. BitRouter supplies its model route, fallback, policy, and metering.
Pick a mode
bro code codex # BitRouter conversation
bro run codex "Summarize this repo" # headless ACP turn
bro codex # Codex's native interfacebro launch codex is the generic spelling of bro codex. It injects a temporary bitrouter model provider into the child process and does not edit ~/.codex/config.toml.
Verify the executable, daemon, and route before a long run:
bro launch codex --checkSelect a Codex model
Pin a daemon-routable model with BitRouter's option:
bro codex --model bitrouter/auto
bro launch codex --model openai/gpt-5-codexArguments after -- go directly to Codex. Avoid forwarding Codex -c or --config overrides that replace the injected provider; bro launch rejects known conflicting shapes.
Configure Codex permanently
Use a permanent provider block only when Codex must start outside bro launch:
model_provider = "bitrouter"
[model_providers.bitrouter]
name = "BitRouter"
base_url = "http://127.0.0.1:4356/v1"
wire_api = "responses"
# env_key = "BITROUTER_API_KEY"For Cloud, use https://api.bitrouter.ai/v1, set env_key = "BITROUTER_API_KEY", and export a BitRouter key. An authenticated self-hosted daemon requires the same.
Codex model-provider configuration belongs in the user-level ~/.codex/config.toml. Project-local Codex configuration does not define model providers.
Use a Codex subscription
The openai-codex provider uses a ChatGPT Plus or Pro credential and the Codex Responses backend. It is separate from the standard openai API-key provider, but it can be used with the Codex harness described above.
Sign in:
bro providers login openai-codexBitRouter can import a compatible local Codex login or start the provider's browser flow. For automation that must not open a browser:
bro providers login openai-codex --import-existing --no-browserNo providers: block is required. Verify the models and route:
bro models --provider openai-codex
bro route openai-codex:gpt-5-codexUse the provider-qualified id to require the subscription source. A request routed to openai:<model> uses OPENAI_API_KEY and the public OpenAI API instead.
Then launch any Codex mode normally:
bro start
bro codex
# or: bro code codex
# or: bro run codex "Summarize this repo"Sign out with:
bro providers logout openai-codexThis removes BitRouter's stored subscription credential. It does not sign the Codex CLI out of its own account.
Provider login and BitRouter Cloud login are separate. bro providers login openai-codex authenticates the upstream subscription; bro cloud login authenticates your BitRouter account.
Model sources
A model source is where inference runs and how it is authenticated. BitRouter puts each source behind the same model ids and routing policy, so the calling agent does not need source-specific code.
| Source | Authentication | Setup |
|---|---|---|
| Claude or Codex subscription | Provider OAuth | bro providers login <provider> |
| Built-in BYOK provider | Environment variable or stored key | Export its key or use bro providers login <provider> --api-key ... |
| Custom hosted API | API key | Add a providers: entry |
| Local inference server | Usually loopback; optional key | Add a providers: entry |
Subscription providers do not need a YAML block. Other sources use the same minimal shape:
providers:
my-source:
api_base: https://example.com/v1
api_key: ${MY_SOURCE_API_KEY}
api_protocol:
- "*": chat_completions
models:
- id: example/modelUse the upstream's actual served model id in models. Keep secrets in environment variables rather than committing them to the file.
Verify a source
bro config validate
bro models --provider my-source
bro route my-source:example/model
bro startconfig validatecatches malformed configuration and unsafe upstream URLs.modelsconfirms the source is in the resolved catalog.routepreviews resolution without making an inference request.- The provider-qualified form pins one source; the bare model id lets BitRouter select among every source that serves it.
To combine sources, define a virtual model or fallback chain. A common pattern is local inference first and a hosted source second.
How is this guide?