Router is a drop-in proxy for the Anthropic Messages, OpenAI Chat Completions, and Gemini native APIs that picks a model for every request. You point Claude Code, Codex, opencode, pi, Cursor, or your own application at it, and a cluster scorer derived from the Avengers-Pro paper embeds and scores each request on-box with an in-process ONNX model, then selects from the providers you have enabled. Routing happens per action rather than per turn.
Provider keys stay on your machine, encrypted at rest, and prompts travel from the router straight to the provider you configured. A self-hosted stack is the router on port 8080, the scorer, Postgres for installations, router keys, encrypted bring-your-own keys and usage, and a dashboard; multi-replica deployments add Pub/Sub for cache invalidation. An optional sidecar runs a frozen hidden-Markov-model policy in place of the default cluster scorer. Two credentials are involved and are distinct: the upstream provider key that lives in the environment, and an rk_ router key that clients send as a bearer token.
An installer wires each supported client to the router, at user or project scope, rewriting only a managed block of that client's configuration so the rest is left alone. Because Codex does not load third-party slash-command files, the same directives ship there as native Codex skills. Routing can be switched off and back on per client without discarding the configuration, and the set of models the router may pick is editable from the terminal or the dashboard.
Features
- Per-action routing: a cluster scorer derived from Avengers-Pro selects a model for every upstream request from your enabled providers
- API compatibility: Anthropic Messages, OpenAI Chat Completions, and Gemini generateContent, with streaming, tools, and vision
- Open-weight coverage: DeepSeek, Kimi, GLM, Qwen, Llama, and Mistral through OpenRouter or any OpenAI-compatible endpoint
- Keys stay local: bring-your-own provider keys encrypted at rest, with rk_ router keys authenticating clients separately
- Client installers: one command wires Claude Code, Codex, opencode, or pi at user or project scope and rewrites only the managed config block
- Model pinning and toggles: force and unforce a model, list and enable or disable selectable models, and turn routing off and on per client
- Decision preview: POST /v1/route returns the routing decision without making an upstream call
- Cost reporting: x-router-cost-usd and related headers on non-streamed responses, a weave_cost object on the final streaming usage event, and a per-session cost endpoint
- Analytics export: raw routing decisions as cursor-paginated NDJSON, with a field dictionary and price book for loading into a warehouse
- Observability: OTLP traces out of the box, viewable in the bundled dashboard or sent to an external collector
- Health endpoints: /health for liveness and /readyz for dependency readiness when policy sidecars must be up before traffic arrives
- Optional HMM policy: a companion container runs a frozen hidden-Markov-model routing policy instead of the in-process scorer
Integrates with
Claude Code
Terminal-based agentic coding tool that reads your codebase and runs tasks through natural-language commands
Codex
Lightweight coding agent that runs in your terminal
OpenCode
Open-source AI coding agent that runs in the terminal, an IDE, or a desktop app
Pi
Minimal, self-extensible terminal coding agent and harness with a multi-provider LLM API
