# Bitrouter

> An open-source agentic LLM gateway & router that cost-optimize your agentic workflows in your way. works with any harness, any model

- **Type:** MCP server
- **Install:** `agentstack add mcp-bitrouter-bitrouter`
- **Verified:** Pending review
- **Seller:** [bitrouter](https://agentstack.voostack.com/s/bitrouter)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [bitrouter](https://github.com/bitrouter)
- **Source:** https://github.com/bitrouter/bitrouter
- **Website:** https://bitrouter.ai

## Install

```sh
agentstack add mcp-bitrouter-bitrouter
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# BitRouter

[](https://github.com/bitrouter/bitrouter/actions)
[](https://crates.io/crates/bitrouter)
[](LICENSE)
[](https://x.com/BitRouterAI)
[](https://discord.gg/G3zVrZDa5C)
[](https://t.me/bitrouterai)
[](https://bitrouter.ai)

Optimize your agent for cost and performance — with every run.
An open-source LLM router that sends routine calls to open models and pays frontier prices only for the calls that earn them. Zero harness changes.

> **Not every agent run needs Claude Opus 4.8 — or even Claude 5.**
> \~80% of agent workloads run just fine on cheaper open-source models without sacrificing performance. Use BitRouter alongside Claude Code (or any coding agent) to reserve your subscription budget for the calls that actually need it. **Enjoy 25% off all open-source model calls on BitRouter Cloud today.**

## Before & After

Without BitRouter, your coding agent routes every call — file reads, summaries, tool calls, scaffolding — through the same frontier model. With BitRouter, routine work goes to open models automatically; frontier models get invoked only when they're justified.

| | Without BitRouter | With BitRouter |
| --- | --- | --- |
| **Routing** | All calls → one frontier model | Routine calls → open models; complex calls → frontier |
| **Cost** | Frontier pricing on every request | Frontier prices only where they're earned |
| **Setup change** | — | One env var |
| **Code change** | — | None |

### Benchmark

| Metric | Without BitRouter | With BitRouter |
| --- | --- | --- |
| **Cost per task** | baseline | — |
| **Task success rate** | baseline | — |
| **Avg. latency** | baseline | — |

## Install

```bash
# 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
```

From source (Cargo)

```bash
cargo install bitrouter
```

## Quick Start

BitRouter is a local proxy between your agent and every LLM provider. One env-var swap — no harness changes required:

```diff
- OPENAI_BASE_URL=https://api.openai.com/v1   # hardwired to one provider, no fallback
+ OPENAI_BASE_URL=http://localhost:4356        # all providers, automatic failover
```

### Local (BYOK)

Set your provider API keys and start:

```bash
export OPENAI_API_KEY=sk-...    # ANTHROPIC_API_KEY / GOOGLE_API_KEY also work
bitrouter start
# Proxy running at http://localhost:4356
```

BitRouter auto-detects any key set in the environment — no config file needed. Point your agent runtime at `http://localhost:4356` and any provider whose key is present is immediately available.

For advanced routing rules, guardrails, or multi-account failover, scaffold a config file:

```bash
bitrouter init          # writes ./bitrouter.yaml (override with `-c `)
bitrouter start
```

### Cloud

Sign in to your BitRouter Cloud account from the terminal — one OAuth account covers every model the gateway offers, no upstream provider keys required:

```bash
bitrouter auth login    # RFC 8628 device flow against api.bitrouter.ai
bitrouter start         # `bitrouter` provider auto-enables once signed in
```

Manage keys, usage, billing, policies, and BYOK from the same CLI — see `bitrouter cloud --help` or [`CLI.md`](CLI.md#cloud-account-management).

### CLI

```bash
bitrouter start / stop / restart               # daemon lifecycle
bitrouter route                         # trace how a model name resolves
bitrouter agents list / check / install        # ACP agent management
bitrouter key sign --user                  # mint a scoped brvk_ API key
bitrouter auth login / logout / whoami         # BitRouter Cloud sign-in
bitrouter cloud keys / usage / billing         # manage cloud account
```

See [`CLI.md`](CLI.md) for flags, config resolution, and examples.

### Agent Skill

BitRouter ships an [Agent Skill](https://agentskills.io) — `/bitrouter` — so AI
coding agents can install, configure, migrate to, and troubleshoot BitRouter on
their own. It lives in this repo at [`skills/bitrouter/`](skills/), kept in sync
with the code.

```bash
bitrouter skills add bitrouter        # via BitRouter's own installer
npx skills add bitrouter/bitrouter    # via the generic skills CLI
```

### Claude Code on your Claude subscription (with telemetry)

Run Claude Code on your **Claude Pro/Max subscription** through BitRouter, with BitRouter in the path purely for side-effects — observability today, optional model rerouting tomorrow. From a freshly-installed `bitrouter`:

**1. Adopt your existing Claude Code session as the `claude-code` subscription provider** (drives the `claude` CLI's own login if you're not signed in yet):

```bash
bitrouter providers login claude-code
```

**2. Turn on full first-party telemetry** (off by default) — create `~/.bitrouter/bitrouter.yaml`:

```yaml
server:
  skip_auth: true          # local daemon: admit credential-less spawn traffic
plugins:
  bitrouter-observe:
    telemetry:
      enabled: true        # nothing is exported unless you opt in
      level: full          # metadata + request/response content (use `metadata` to omit content)
                           # endpoint omitted → defaults to https://telemetry.bitrouter.ai
```

**3. Start the daemon in the background and verify it's up:**

```bash
bitrouter start            # detached; logs to ~/.bitrouter/bitrouter.log
bitrouter status           # running: yes — listen 127.0.0.1:4356
bitrouter observe status   # telemetry exporter endpoint + state
```

**4. Launch an interactive Claude Code session pointed at BitRouter:**

```bash
bitrouter spawn -a claude  # interactive; run `bitrouter stop` when you're done
```

Genuine Claude Code traffic — recognised by its `anthropic-beta: claude-code-*` agent-profile marker — is routed to your subscription; anything else falls through to your other configured providers. Telemetry is attributed to an anonymous install id. *(Optional: run `bitrouter cloud login` first to also serve non-Claude-Code models from your BitRouter Cloud account.)*

## Comparison

|                           | **BitRouter**                               | **OpenRouter**            | **LiteLLM**                    |
| ------------------------- | ------------------------------------------- | ------------------------- | ------------------------------ |
| **Architecture**          | Local-first proxy + optional cloud          | Cloud-only SaaS           | Local proxy (Python)           |
| **Language**              | Rust                                        | Closed-source             | Python                         |
| **Self-hosted**           | Yes                                         | No                        | Yes                            |
| **Agent-native**          | Yes — built for autonomous agent runtimes   | No — human-facing gateway | Partial — SDK-oriented         |
| **Agent protocols**       | MCP + ACP                                   | No                        | MCP                            |
| **Agent guardrails**      | Built-in (inspect, redact, block)           | Yes                       | Yes                            |
| **Cross-protocol routing**| Yes (e.g. OpenAI format → Anthropic upstream)| Provider-specific        | Yes (unified interface)        |
| **Observability**         | CLI + per-request cost tracking + Prometheus| Web dashboard             | Logging + callbacks + WebUI    |
| **Extensibility**         | Trait-based SDK — import and compose crates | API only                  | Python middleware               |
| **Performance**           | ~10ms                                       | ~30ms (cloud)             | ~500ms                         |
| **License**               | Apache 2.0                                  | Proprietary               | Apache 2.0                     |

**TL;DR** — OpenRouter is a cloud API marketplace for humans picking models. LiteLLM is a Python proxy for unifying provider SDKs. BitRouter is a Rust-native proxy purpose-built for autonomous agents — with cross-protocol routing, MCP and ACP support, and guardrails out of the box.

## Features

BitRouter is purpose-built for autonomous agents — every feature is designed for unattended, multi-step execution rather than human-in-the-loop API access.

### Reliability

Agents can't retry a provider outage the way a human can. BitRouter reroutes across providers mid-run, transparently — so a rate-limit at file 140 never makes you re-pay for 139 files of work. Configure fallback chains, round-robin across multiple accounts, or let cross-protocol routing send OpenAI-format requests to an Anthropic or Google upstream automatically.

### Observability

Billed per run. Now visible per run. Every agent, every model, every hop — with cost and latency attributed to the call. Query spend from the CLI without reaching for a dashboard, export to Prometheus or any OTLP backend, or trace exactly how a model name resolves before it hits the upstream with `bitrouter route `.

### Security

One policy at the router — before requests leave your network and before responses reach your agent. Injection and output filtering, private by default. Virtual keys (`brvk_`) scope credentials per agent or user so no agent ever holds an upstream key directly; per-agent spend caps and loop guards keep runaway costs contained.

### Efficiency

Pay open-source prices for the calls that don't need frontier. Route by policy: fall back to a cheaper provider when the primary exceeds a cost threshold, or pin call types to the model with the best price-to-quality ratio for that task. Scoped virtual keys let you cap what each agent or user can spend before it touches your upstream account.

## Supported Providers

| Provider        | Status | Notes                                                          |
| --------------- | ------ | -------------------------------------------------------------- |
| OpenAI          | ✅     | Chat Completions + Responses API                               |
| Anthropic       | ✅     | Messages API + Claude Pro/Max subscription (PKCE)              |
| Google          | ✅     | Generative AI API                                              |
| Amazon Bedrock  | ✅     | Via AWS SDK (opt-in)                                           |
| OpenRouter      | ✅     | Chat Completions + Responses API                               |
| OpenCode Zen    | ✅     | Curated models across Chat Completions, Messages, and Generate Content protocols      |
| OpenCode Go     | ✅     | Low-cost subscription for open coding models                   |
| BitRouter Cloud | ✅     | OAuth sign-in (`bitrouter auth login`); cloud-managed routing  |
| GitHub Copilot  | ✅     | GitHub OAuth device flow (`bitrouter login github-copilot`)    |
| ChatGPT Codex   | ✅     | ChatGPT subscription PKCE (`bitrouter login openai-codex`)     |

**Want to add a provider?** Open an issue or submit a PR. **Interested in a first-party integration?** Email [kelsenliu@bitrouter.ai](mailto:kelsenliu@bitrouter.ai) or [book a meeting](https://cal.com/kelsenliu).

## Supported Harnesses

Any agent runtime that speaks OpenAI or Anthropic APIs works with BitRouter out of the box — set `OPENAI_BASE_URL=http://localhost:4356` and you're done. The following harnesses are tested and supported:

| Harness        | Status | Notes                                                                                       |
| -------------- | ------ | ------------------------------------------------------------------------------------------- |
| Claude Code    | ✅     | [LLM gateway guide](https://code.claude.com/docs/en/llm-gateway)                           |
| OpenAI Codex   | ✅     | [Custom model providers](https://developers.openai.com/codex/config-advanced#custom-model-providers) |
| OpenCode       | ✅     | Via [models.dev](https://github.com/anomalyco/models.dev)                                  |
| Hermes Agent   | ✅     | Native plugin — [hermes-bitrouter-plugin](https://github.com/bitrouter/hermes-bitrouter-plugin) |
| Openclaw       | ✅     | Native plugin — [bitrouter-openclaw](https://github.com/bitrouter/bitrouter-openclaw)      |
| Pi-Agent       | ✅     | [Model configuration guide](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/models.md) |

**Building an open-source agent?** Reach out at [kelsenliu@bitrouter.ai](mailto:kelsenliu@bitrouter.ai) or [book a meeting](https://cal.com/kelsenliu) — we offer **up to 50% off** for you and your community.

The full provider and harness catalog lives at [github.com/bitrouter/provider-registry](https://github.com/bitrouter/provider-registry).

## Documentation

- [`CLI.md`](CLI.md) — full CLI reference with flags and examples
- [`DEVELOPMENT.md`](DEVELOPMENT.md) — workspace architecture and SDK internals
- [`CONTRIBUTING.md`](CONTRIBUTING.md) — contribution workflow, issue reporting, and provider updates
- [`CLAUDE.md`](CLAUDE.md) — guidance for AI coding agents working in this repository
- [`skills/`](skills/) — the `/bitrouter` Agent Skill (source of truth)

## Roadmap

- [x] Core routing engine and provider abstractions
- [x] OpenAI, Anthropic, Google, and Amazon Bedrock adapters
- [x] Zero-config auto-detection from environment variables
- [x] Custom provider support (OpenAI-compatible / Anthropic-compatible)
- [x] Cross-protocol routing (e.g. OpenAI format → Anthropic provider)
- [x] MCP gateway and ACP agent integration
- [x] Multiple accounts per provider — failover + load-balancing
- [x] Virtual key management (`bitrouter key`) backed by SQLite / PostgreSQL / MySQL
- [ ] Telemetry and usage analytics
- [ ] Provider & model routing policy customization

## Star History

[](https://star-history.com/#bitrouter/bitrouter&Date)

## License

Licensed under the [Apache License 2.0](LICENSE).

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [bitrouter](https://github.com/bitrouter)
- **Source:** [bitrouter/bitrouter](https://github.com/bitrouter/bitrouter)
- **License:** Apache-2.0
- **Homepage:** https://bitrouter.ai

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: flagged — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-bitrouter-bitrouter
- Seller: https://agentstack.voostack.com/s/bitrouter
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
