For AI agents, the documentation index lists all pages. Append .md to a documentation URL for Markdown, or request text/markdown.

Skip to Content

Coding agents

Connect existing agents to BitRouter, choose gateway routes in native model controls, and distinguish persistent setup from launch and ACP.

12 min readEdit this page

BitRouter separates the agent harness that drives the loop from the model source that supplies tokens. Connect the agent you already use, then select its BitRouter route in the native model controls. The harness retains its sessions, history, compaction, tools, permissions, and schedules.

Persistent native connections

bro connect is documented here from BitRouter PR #1016, currently a development CLI capability. Use a build containing that command and check bro connect --help. These instructions do not establish availability in an older installed binary or replace the separately captured CLI reference.

bro connect configures a persistent native provider. No self-driving extension, separate classifier, or BitRouter-managed agent session is required. After setup, open the native application normally and select the connected route.

bro connect

Choose a client in the menu, review the destination files, and confirm the connection. For a local gateway, prepare working inference sources first with Quickstart. Setup can start that local gateway after confirmation. It does not install the native client.

ClientDirect setupConfiguration scope
DeepSeek Harnessbro connect deepseek-harnessSelected initialized profiles in one Harness home
Hermes Agentbro connect hermesThe selected home/current profile, or explicitly named profiles
OpenClawbro connect openclawOne Gateway state root and its agent catalogs
OpenCodebro connect opencodeOne native configuration file
Pibro connect piOne Pi agent directory

These five adapters add an independent BitRouter provider and retain existing startup defaults. Select BitRouter in the native picker after the required reload. Codex and Claude are also available in the connector menu; their client-specific configuration and restoration differ.

BitRouter is the provider; Automatos is its default router model. The default gateway wire ID is bitrouter/automatos. --model chooses another exact ID already advertised by the target gateway's /v1/models; it does not create a model, strategy, or alias. Display labels and native selection IDs can differ from the wire ID, as described in each client guide.

Connect an existing gateway

For Cloud or another existing gateway, supply its root URL or /v1 URL and its gateway credential. For example, after replacing the model placeholder with an exact ID advertised by your Cloud endpoint:

export BITROUTER_API_KEY='your-bitrouter-gateway-key'
bro connect hermes --base-url https://api.bitrouter.ai \
  --model 'exact-advertised-model-id' --dry-run
bro connect hermes --base-url https://api.bitrouter.ai \
  --model 'exact-advertised-model-id'

The explicit endpoint path configures the native client without reading a local BitRouter config or starting a daemon. Remote URLs require HTTPS; HTTP is allowed on loopback. The saved gateway credential is separate from upstream provider keys. For unattended writes, choose an explicit client and add --yes.

The default bitrouter/automatos must also be advertised before setup succeeds. Availability depends on the chosen gateway configuration and deployment. A callable selector that is absent from /v1/models does not pass this connector's catalog check.

Request context and routing

The connected client sends its normal model request: the selected wire ID, submitted conversation context, and supported tool declarations/results. BitRouter can apply the selected route to that request. The harness determines what is submitted after its own context loading and compaction.

Persistent connection does not export the complete native session store or install a lifecycle observer. It does not itself configure tool permissions, context-profile switching, automatic approvals, or workload learning. Optional self-driving extensions have a separate host-side resource-management role and are not prerequisites for model routing.

Strategies and workflows

Define model combinations and routing behavior in BitRouter using Strategies and Virtual Models. Select a registered gateway route through the harness's own agent, profile, session, or job model settings. The harness remains the owner of those workflow bindings.

For these five independent-provider clients, repeat --model to register an ordered collection of exact advertised selectors under one provider. The first retains the existing primary alias/display-name behavior; additional entries use their exact IDs as labels. Duplicate IDs and conflicting native keys are refused. Setup and --check validate every ID. Codex and Claude retain their single-model connector contract.

For example, if the gateway advertises both IDs, register them together:

bro connect hermes --model bitrouter/automatos --model team/background

Then choose a registered route in the native workflow settings. Hermes' cron defaults/per-job pins and OpenClaw's per-job model overrides remain harness-owned; bro connect does not provide a workflow-binding wizard or rewrite those settings. See the Hermes and OpenClaw guides.

A label such as background or flex does not activate an inference type. The selected gateway must implement the intended policy and support its model/protocol requirements. See Inference Types for the market capacity types.

Manage a connection

For these five independent-provider clients, replace hermes with the intended client and retain any custom --instance:

bro connect hermes --dry-run
bro connect hermes --status
bro connect hermes --check
bro connect hermes --update
bro connect hermes --remove
  • --dry-run previews files and effects without starting a daemon or writing configuration.
  • --status checks saved configuration offline. --check also verifies the exact gateway model using the saved credential. Neither submits inference or tool calls, and neither proves that a running client has reloaded.
  • --update replaces the managed provider. Supplying model flags replaces the complete selector list; omitting them preserves it. Supply the full remaining list to drop a selector. Other omitted settings retain the saved connection; an omitted key is reused only for an unchanged endpoint. An update can restore the earlier native startup selection, so reselect BitRouter afterward if desired.
  • --remove removes owned settings and restores earlier selections only where the connected model is still selected. Later unrelated preferences remain. Saved job/session bindings are not migrated when routes are removed, so change those bindings in the native harness as needed. Edits to owned fields are conflicts to resolve before retrying.

Close config-writing clients during updates or removal. Private connection receipts contain restoration data and credentials; keep them private. For Desktop/Web attached to a different backend, configure that backend on its own host. Each client guide describes reload requirements and state outside the connector's ownership.

After a catalog check, verify inference separately: select BitRouter in the native client, send a small request, exercise any required tool roundtrip, and inspect request receipts. Native default context/cost metadata is not proof of route capacity, actual pricing, or model quality.

Choose the interface

GoalCommandInterface owner
Add a persistent native provider (development CLI)bro connect <client>Native client configuration; BitRouter gateway routing
Run one turn from a scriptbro run <agent> "..."BitRouter, headless
Use the harness's own terminal UIbro launch <agent>The harness
Let another ACP client launch the adapterbro acp serve <agent>The ACP client
bro codex
bro run claude "Review the current diff" --format quiet
bro launch opencode

bro connect changes persistent native configuration. bro run and bro acp serve use ACP adapters. bro launch starts the harness's native interface with process-local routing overrides and leaves normal harness configuration in place. These are separate capabilities; connecting or launching a native client does not create a BRO Goal.

The captured command reference documents the released ACP conversation interface. Check native launch and ACP connectivity separately for the adapter and version you use.

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 idACP adapterNative launch
claudeclaude-acpbro claude or bro launch claude
codexcodex-acpbro codex or bro launch codex
opencodeopencodebro launch opencode
pipi-acpbro launch pi
hermeshermes-acpbro launch hermes
openclawopenclawbro launch openclaw
gemini-cligemini-cliACP 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

See bro [harness] for the shared setup workflow, launch configuration, and command options.

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 plan

Arguments 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:

ProtocolLocal base URLCloud base URL
OpenAI-compatiblehttp://127.0.0.1:4356/v1https://api.bitrouter.ai/v1
Anthropic-compatiblehttp://127.0.0.1:4356https://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 run claude "Summarize this repo"   # headless ACP turn
bro claude                              # Claude Code's native interface

bro 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 --check

If 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-6

Arguments after -- go directly to Claude Code:

bro launch claude -- --permission-mode plan

Configure 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
claude

For 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

Use BYOK & Subscriptions for login, explicit subscription routes, and logout. The subscription source is independent of the harness interface.

Codex

Codex owns the agent loop and tools. BitRouter supplies its model route, fallback, policy, and metering.

Pick a mode

bro run codex "Summarize this repo"   # headless ACP turn
bro codex                              # Codex's native interface

bro 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 --check

Select a Codex model

Pin a daemon-routable model with BitRouter's option:

bro codex --model bitrouter/auto
bro launch codex --model openai/gpt-5-codex

Arguments 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

Use BYOK & Subscriptions for login, explicit subscription routes, and logout. The subscription source is independent of the harness interface.

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.

SourceAuthenticationSetup
Claude or Codex subscriptionProvider OAuthbro providers login <provider>
Built-in BYOK providerEnvironment variable or stored keyExport its key or use bro providers login <provider> --api-key ...
Custom hosted APIAPI keyAdd a providers: entry
Local inference serverUsually loopback; optional keyAdd 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/model

Use 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 start
  • config validate catches malformed configuration and unsafe upstream URLs.
  • models confirms the source is in the resolved catalog.
  • route previews 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?

On this page