The self-improving LLM router that optimize your agentic workflows with every runs, works with any harnesses, any models, any loops.
bitrouter is an established Rust project in the AI payments / x402 ecosystem, focused on acp, agent-guardrails, agent-harness, agent-observability. It currently has 208 GitHub stars and 13 forks, and sits alongside related tools like agent-apprenticeship, agent-apprenticeship, internet-court-skill, os-moda, skills, AIephant-AI-Agent-Gateway.
The self-improving LLM router that optimizes your agentic workflows with every run, works with any harnesses, any models, any loops.
You're tokenmaxxing in production. Every step of every loop bills at frontier prices — file reads, tool calls, sub-agent hops, retries. Most don't need it. BitRouter routes each call, tool, and agent to the cheapest path that still reaches the goal, and tightens that routing as the loop runs.
Cost is live today — latency and accuracy are next.
An agentic loop consumes three things. Other routers govern only the first. BitRouter makes all three routable, observable, and governed:
Optimizing a loop isn't just model selection — it's choosing the model, the tool, and the sub-agent that best serve the loop's objective at every step that gets it to its goal.
BitRouter wraps your agentic loop in a second loop. Each loop gets its own policy spec — bitrouter.yaml — declaring how its calls, tools, and agents route. The routing key is context-aware and lives as code: it's the step in the loop, not just the model name — so "plan on the flagship, do routine file reads on something cheap" is one declarative table.
# bitrouter.yaml — context-aware routing as code, keyed on the loop's step
policy_table:
tiers: # a tier name → the model it routes to
cheap: moonshotai/kimi-k2.6
flagship: gpt-5.5
fingerprints: # the agentic-loop step → which tier handles it
opening: flagship # first turn → plan on the strong model
after_read_file: cheap # routine file read → downgrade
midstream: cheap
default_tier: flagship # anything unmapped stays safe
tool_use_tier: flagship # guardrail: a tool call is never
tool_safe_tiers: [flagship] # stranded on a tool-blind model
adequacy:
enabled: true # a downgrade that starts failing…
escalation_tier: flagship # …escalates itself back up
Against that spec BitRouter runs a continuous act → observe → evaluate → learn cycle — and every step is a component it already ships:
adequacy: self-escalates a downgrade that starts failing; across runs the optimizer publishes an evolved, resolved policy-lock.yaml (an npm-style manifest/lock split, git-owned) — or you edit the table by hand.You choose what the loop optimizes for — cost, latency, or accuracy — and the spec sharpens the longer it runs in production.
Today cost is the validated objective: on Terminal-Bench 2.1, gpt-5.5 with BitRouter cut cost 32.8% at near-parity accuracy (−1.1 pp), by offloading routine steps to a cheaper model. Latency and accuracy objectives — and more base models — are landing next.
| Base model | Cost vs baseline | Latency vs baseline | Accuracy vs baseline |
|---|---|---|---|
gpt-5.5 |
**−32.8%**¹ | coming soon | coming soon |
gpt-5.6 |
coming soon | coming soon | coming soon |
claude-opus-4.8 |
coming soon | coming soon | coming soon |
claude-sonnet-5 |
coming soon | coming soon | coming soon |
claude-fable-5 |
coming soon | coming soon | coming soon |
¹ Cost-optimization run on Terminal-Bench 2.1: −32.8% zero-cache imputed cost (audited range 28.6–32.8% by cache share) at near-parity accuracy, −1.1 pp (76.1% vs 77.3%, within single-attempt noise).
This is a mechanism study under a modified protocol, not a Terminal-Bench leaderboard submission — read the experiment limitations before citing the numbers. Full reports live in benchmarks/; complete traces, tool calls, usage, policy decisions, configs, and checksums are in the BitRouterAI/benchmarks dataset.
Every gateway below routes model calls. BitRouter is the only one that also makes tools and agents routable, and optimizes the whole loop rather than a single call.
| BitRouter | OpenRouter | LiteLLM | TensorZero | Portkey | Bifrost | |
|---|---|---|---|---|---|---|
| Routable primitives | Models + tools + agents (MCP + ACP) | Models | Models + tools (MCP) | Models | Models + tools (MCP) | Models + tools (MCP) |
| Routing key | The loop step (last tool called) | Model name | Model + request tags | Model name | Model + metadata | Model name |
| Optimizes | The loop, multi-objective (cost today) | Static routing | Static routing | The model | Static routing | Static routing |
All but OpenRouter are open-source and self-hostable; BitRouter and TensorZero are Rust.
policy-lock.yaml you can read, diff, and revert — auto-tuning you fully own, never a black box.# macOS / Linux
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/bitrouter/bitrouter/releases/latest/download/bitrouter-installer.sh | sh
# Homebrew
brew install bitrouter/tap/bitrouter
# npm
npm install -g bitrouter
cargo install bitrouter
BitRouter is a local proxy between your agent and every LLM provider. One env-var swap — no harness changes required:
- OPENAI_BASE_URL=https://api.openai.com/v1 # hardwired to one provider, no fallback
+ OPENAI_BASE_URL=http://localhost:4356/v1 # all providers, automatic failover
BitRouter runs as a local daemon — start it with your own keys or a Cloud sign-in.
Bring your own keys (BYOK) — auto-detected from the environment, no config file needed:
export OPENAI_API_KEY=sk-... # ANTHROPIC_API_KEY / GEMINI_API_KEY also work
bitrouter start # proxy running at http://localhost:4356
Or sign in to BitRouter Cloud — use browser OAuth interactively or store an existing API key in CI:
bitrouter cloud login # RFC 8628 device flow against api.bitrouter.ai
bitrouter cloud login --api-key "$BITROUTER_API_KEY" # non-interactive CI login
bitrouter start # `bitrouter` provider auto-enables once signed in
The same credential also drives a gh api-style raw client—no daemon required:
bitrouter cloud api /v1/models
bitrouter cloud api /v1/chat/completions --input request.json
Point your agent runtime at http://localhost:4356 and any available provider is live. For advanced routing rules, guardrails, or multi-account failover, scaffold a config with bitrouter init (writes ./bitrouter.yaml).
bitrouter start / stop / restart # daemon lifecycle
bitrouter route <model> # trace how a model name resolves
bitrouter key sign --user <id> # mint a scoped brvk_ API key
bitrouter cloud keys / usage / billing # manage your cloud account
bitrouter cloud api /v1/models # call Cloud APIs directly
See docs/CLI.md for the full command reference, flags, and config resolution.
BitRouter ships an Agent Skill — /bitrouter — so AI
coding agents can install, configure, migrate to, and troubleshoot BitRouter on
their own. It lives in this repo at skills/bitrouter/, kept in sync
with the code.
bitrouter skills add bitrouter # via BitRouter's own installer
npx skills add bitrouter/bitrouter # via the generic skills CLI
Use BitRouter from any MCP client — it exposes complete, list_models, and status as MCP tools (the origin server, distinct from the MCP gateway that proxies your own MCP servers):
bitrouter mcp serve # stdio → local daemon at 127.0.0.1:4356
bitrouter mcp install --client claude # print the Claude/Cursor mcpServers config block
Add --transport http to target the multi-tenant cloud backend.
BitRouter exposes an OpenAI- and Anthropic-compatible HTTP API on http://localhost:4356, so any SDK or client works unchanged. The full endpoint reference and OpenAPI spec live in bitrouter/bitrouter-docs (rendered at bitrouter.ai).
Ready-made policy specs for common agentic workflows — a starting point that routes well out of the box, before you tune it for your own loop. Coming soon in templates/.
BitRouter routes to a model, not a provider. Each family below is served by many providers — its own lab, hyperscalers (AWS Bedrock, Alibaba Cloud), gateways (OpenRouter, OpenCode), and serverless clouds — and BitRouter picks the cheapest route per call. Bring your own key to any of them, or use one BitRouter Cloud account with no keys at all.
| Lab | Latest models |
|---|---|
| DeepSeek | DeepSeek V4 Pro / Flash |
| Alibaba | Qwen3.7 Max / Plus |
| Moonshot | Kimi K2.7 Code / K2.6 |
| Z.ai | GLM-5.2 / 5.1 |
| MiniMax | MiniMax M3 / M2.7 |
| Xiaomi | MiMo V2.5 Pro / V2.5 |
| StepFun | Step 3.7 Flash / 3.5 Flash |
Plus every frontier model from OpenAI, Anthropic, Google, and xAI — over your own keys, a subscription sign-in (Claude Pro/Max, GitHub Copilot, ChatGPT Codex), or BitRouter Cloud. Full catalog in the registry/.
Any agent runtime that speaks OpenAI or Anthropic APIs works with BitRouter out of the box — set OPENAI_BASE_URL=http://localhost:4356/v1 and you're done. The following harnesses are tested and supported:
| Harness | Status | Notes |
|---|---|---|
| Claude Code | ✅ | LLM gateway guide |
| OpenAI Codex | ✅ | bitrouter launch --agent codex or custom model providers |
| OpenCode | ✅ | Via models.dev |
| Hermes Agent | ✅ | Native plugin — hermes-bitrouter-plugin |
| OpenClaw | ✅ | Native plugin — bitrouter-openclaw |
| Pi-Agent | ✅ | Model configuration guide |
The full provider and harness catalog lives in github.com/bitrouter/bitrouter/registry.
Beyond the gateways above, the production controls for running agents unattended:
brvk_) scoped per agent or user — no agent holds an upstream keyTry BitRouter Cloud → or reach out directly:
Want a first-party provider integration, or building an open-source agent/harness? Email kelsenliu@bitrouter.ai or book a meeting — open-source builders get up to 50% off for you and your community.
docs/DEVELOPMENT.md — workspace architecture and SDK internalsCONTRIBUTING.md — contribution workflow, issue reporting, and provider updatesCLAUDE.md — guidance for AI coding agents working in this repositoryskills/ — the /bitrouter Agent Skill (source of truth)Licensed under the Apache License 2.0.
The living ecosystem where AI agents complete tasks through workflow loops, improve through iterative execution, are evaluated by mentor agents or humans in the loop, and turn completed work into reusable work experience and data to improve future agents.
The living ecosystem where AI agents complete tasks through workflow loops, improve through iterative execution, are evaluated by mentor agents or humans in the loop, and turn completed work into reusable work experience and data to improve future agents.
The trust layer for agent-to-agent commerce — natural-language mandates, ERC-7710 delegated permissions, x402 payments, escrow, and dispute resolution as one open, catch-all Agent Skill / Claude Code plugin.
An operating system built for AI agents — talk to your NixOS server instead of SSH-ing in. Typed, audited tool access with atomic rollback on every change. Research-grade; run it on a disposable box, not production.
AI Agent Skills for ChainStream — on-chain data, DeFi trading, x402 micropayments. 80+ API endpoints, 18 MCP tools, 4 SDK languages. ClawHub published.
Alephant is an open-source AI Agent Gateway for routing, tracking, and controlling LLM usage across AI agents, members, and workflows, and for publishing agent capabilities as paid endpoints with x402 and MPP payment rails.
A curated list of awesome agentic commerce resources — protocols, MCP servers, tools, apps, APIs and services for AI agents that shop, sell and transact. For store owners, developers, agencies and marketers.
Agentic commerce is the shift from people clicking buy buttons to AI agents acting, deciding, negotiating, and transacting on behalf of users. This repository documents that shift.
Skills & plugins for agentic commerce : UCP, ACP, AP2, A2A, WebMCP, Magento 2, BigCommerce, WooCommerce
The open-source toolkit for building AI commerce agents using UCP and ACP protocols
A neutral landscape analysis of AI agent payment protocols (x402, MPP, L402, Google AP2, Visa TAP + ICC, Mastercard Agent Pay, Amex ACE, Google/Shopify UCP, OpenAI ACP, and others). Maintained by Genesis Software Group, Copenhagen. Updated April 2026. CC BY 4.0.
A curated list of awesome Agentic commerce, Universal Commerce Protocol (UCP), Agentic payments protocol (AP2) resources, tools, and implementations.