The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Llm Router listing page.
Stop hitting the limit on your Claude Pro or Max plan.
llm-router answers the routine prompts on free and cheap models, so your subscription quota
is still there when you need it at 4pm. No API keys. No change to how you work.
Install in 30 seconds
Works with Claude Code, Codex, and Gemini CLI · No API keys required on Claude Pro/Max
Local-first. No hosted proxy. No account required.
You are on a Claude Pro or Max plan. You have not spent a cent beyond the subscription. And at 3pm you hit the five-hour limit and stop working.
The cause is not that you asked too much. It is that every prompt went to the premium model — "what does this error mean", "reformat this JSON", "is the service up" — and each one drew down the same quota as the architectural question you actually needed it for.
llm-router runs inside your coding tool's own lifecycle. It reads each prompt
before the model does, sends the routine ones to a local or cheap model, and
leaves your seat for the work that needs it. Same workflow, same commands, same
transcript — the model choice changes underneath.
Every other router in this category is a proxy: you point your agent at a local endpoint and it forwards requests using your API keys. That design has a hard limit — a proxy cannot intercept a session authenticated by a subscription, because there is no key to forward.
If you pay per token, a proxy serves you well and there are good ones. If you pay a flat monthly fee and the thing you run out of is quota, a proxy has nothing to offer, and that is the gap this fills.
| Pays per token | Pays a subscription | |
|---|---|---|
| What runs out | your invoice | your five-hour window |
| Needs API keys | yes | no |
| A proxy can help | yes | no — nothing to intercept |
| llm-router helps | yes | yes |
llm-router is benchmarked on RouterArena,
a community leaderboard scoring routers on accuracy versus cost, plus optimality,
robustness and latency.
The claim worth reading is not the badge. docs/ROUTERARENA.md states what was measured, on which split, what it cost to reproduce, and what failed — including that skill-cluster classification never beat simply always picking one model, and that tuning on a proxy split misled by 4.25 points. Rank moves as new routers land; see the live leaderboard for the current standing.
Works with zero API keys on Claude Code Pro/Max subscriptions — routing uses MCP tools that call external models only when beneficial. Add OPENROUTER_API_KEY to unlock the open-weight workhorse pool used by the cost_aggressive policy.
If you already use Claude Code, Codex, or Gemini CLI, keep your existing workflow and let llm-router choose models underneath it.
| Prompt | Routed to |
|---|---|
| "What does this Python error mean?" | Ollama / Gemini Flash / Codex |
| "Refactor this endpoint" | GPT-4o / Gemini Pro |
| "Design a distributed tracing strategy" | o3 / Claude Opus |
The exact chain depends on your configured providers, budget profile, and routing policy.
| Tool | Mode | Savings (this host) |
|---|---|---|
| Claude Code | Full auto-routing via hooks | 60–80% |
| Codex CLI | Manual MCP tools · hooks 🔜 | 30–50% |
| Gemini CLI | Full auto-routing via hooks | 50–70% |
| VS Code / Cursor | Manual MCP tools · hooks 🔜 | 30–50% |
| Any MCP client | Manual MCP tools | Varies |
llm_query.UserPromptSubmit (enabled by default, and its PreToolUse
can even rewrite arguments); Cursor ships beforeSubmitPrompt. Both can block a prompt before
the model sees it, which is the same mechanism Claude Code uses today.The full picture, including what each host genuinely cannot do and which payload fields have been verified against a real run rather than read off a docs page, is in guide/HOST_SUPPORT_MATRIX.md.
See guide/HOST_SUPPORT_MATRIX.md for full details on each host.
enforce: smart + mode: zero_claude makes prompts either complete externally or stop
before native Claude runs — see
guide/GETTING_STARTED.md.
Classification is free for many tasks (regex heuristics catch ~70%) or near-free for ambiguous prompts when using local Ollama or Gemini Flash.
Beyond "send cheap prompts to cheap models":
LLM_ROUTER_SUBSCRIPTION_PROVIDER.llm_image / llm_video / llm_audio, and
llm_orchestrate for multi-step research.okf index is worth running once per repo you work in. Without it the knowledge
store can only learn from answers that were already routed, which is a deadlock —
nothing routes because the model has no context, and the store stays empty because
nothing routed.
Full command reference: guide/GETTING_STARTED.md
20+ providers, free-first. Ollama (local, free) leads the chain; OpenRouter (343 models behind one key) is the biggest single unlock; Gemini and Groq have usable free tiers. Anthropic works via your existing Claude subscription — no API key needed.
Every provider, its models, cost tier and env var: guide/PROVIDERS.md
A policy sets how eagerly the router routes away from your premium model —
conservative (10–15% savings) through balanced (the default, 35–45%) to
cost_aggressive (70–85%, needs OPENROUTER_API_KEY).
All six policies, thresholds and the YAML schema: guide/POLICIES.md
60 tools across routing, analysis, code, media, budget and diagnostics — exposed to any
MCP host. The default consolidated surface shows 11 front-door tools; set
LLM_ROUTER_SLIM=full for all 60.
Every tool with its signature: guide/TOOLS.md
Savings are calculated by comparing actual spend against a baseline of routing every task to Claude Sonnet/Opus.
Methodology:
(baseline - actual) / baselineAssumptions and limitations:
len(text) / 4 approximation, not exact tokenizer countsObserved range: 35–80% savings depending on policy and task mix. The "87%" figure in some docs represents a single-user peak over a specific development period, not a guaranteed outcome.
llm-router runs entirely on your machine. There is no hosted proxy, no telemetry, no account required.
| What | Where | Details |
|---|---|---|
| Your prompts | Sent to configured providers | Exactly like using those providers directly |
| API keys | .env or ~/.llm-router/config.yaml | Local files, never transmitted |
| Usage logs | ~/.llm-router/usage.db | Unencrypted SQLite (filesystem permissions) |
| Classification cache | In-memory | Cleared on process restart |
| Hook scripts | ~/.claude/hooks/ | Local shell scripts, inspectable |
What we do:
~/.llm-router/What you should know:
LLM_ROUTER_DIRECT_EXECUTION — read this before your first runThis is on by default. When enabled, hooks/auto-route.py tries to answer a prompt
locally before Claude Code sees it. For prompts it classifies as needing file work, it runs
a tool-calling agent loop that hands the local model three tools — write_file, edit_file
and run_command — unsupervised, with no confirmation step, for up to 15 iterations.
run_command executes through a shell.
What is actually enforced:
write_file / edit_file are confined to the project root. This works as described.run_command is filtered by a small regex blocklist of top-level destructive patterns.What that blocklist does not stop (measured, not estimated): targeted deletes inside the
project (rm -rf ./src), $HOME deletes via shell expansion, git push --force,
git reset --hard, arbitrary npm/pip install, reads outside the project
(cat ../../.ssh/id_rsa), network exfiltration (curl -X POST … -d @.env), and echoing
API keys. It stops catastrophic system damage — not project damage, credential
disclosure, or exfiltration.
Turn it off:
Routing still works with it disabled; you lose only the local pre-answer path.
Since 13.2.0, a draft that reaches you has passed two grounding checks: it may not
cite a file, or call a function, that exists neither in the material it was given nor
in the indexed repo. A draft that does is discarded and the turn falls through to
Claude. This catches the mechanical way a context-fed answer goes wrong — a confident
reference to a test that was never written. It does not verify that the answer is
correct, and it cannot see invented prose; LLM_ROUTER_GROUNDING_CHECK=off and
LLM_ROUTER_SYMBOL_GROUNDING=off disable them.
See SECURITY.md for the full analysis and the responsible disclosure policy.
Everything is environment variables — no config file required to start:
LLM_ROUTER_OLLAMA_TIMEOUT matters more than it looks. It was 4s before 13.2.0, and
no local model can answer in 4s — measured p50s on an M-series machine are 11-28s, so
every local attempt aborted and fell through to Claude. If you run larger models,
raise it further rather than wondering why nothing routes.
Full reference, config file schema and per-host overrides: guide/GETTING_STARTED.md
Full index: guide/README.md
| Document | Purpose |
|---|---|
| Quick Start (2 min) | Fastest path to working routing |
| Getting Started | Full setup walkthrough |
| Host Support Matrix | Per-host feature comparison |
| Providers | Provider setup and model recommendations |
| Routing Policies | routing.yaml schema and authoring your own policy |
| Tool Reference | All 60 MCP tools with examples |
| Architecture | Internal design and module structure |
| Troubleshooting | Common issues and fixes |
| Testing the Router | Isolation suite for verifying routing health |
| Benchmarks | Model cost/latency/quality table, regenerated by CI |
| Changelog | Release notes (archive) |
llm-router is built for individual developers and small teams: local cost savings, zero
ops overhead, no hosted anything. If you need team-wide policy enforcement, audit export,
SSO or per-org budgets, that is what Chuzom is for.
Contributions welcome. See CONTRIBUTING.md for full guidelines.
-|-----------|
| llm-routing | Current PyPI package (pip install llm-routing) |
| llm-router | CLI command and GitHub repo name |
| claude-code-llm-router | Deprecated legacy package (redirects to llm-routing) |
⭐ If llm-router saved you money, star the repo — it helps other developers discover it.
Issues · Discussions · PyPI · Changelog
MIT License