# Repository Briefing: ypollak2/llm-router
> Source: https://repoforai.com/repo/ypollak2/llm-router (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/ypollak2/llm-router
- **Category**: Coding, Skills & MCP (AI 编程 / Skills / MCP)
- **Primary Language**: Python
- **License**: MIT
- **Engineering Health**: A+ (88/100 · Maintenance 35/35 · Adoption 13/25 · Releases 20/20 · License 20/20)
- **Latest Release**: v16.2.0 (2026-12-02) — https://github.com/ypollak2/llm-router/releases
- **Review Snapshot**: 2026-12-01 (Note: v16.2.0 on 2026-12-02 shipped after this review; verify latest release notes)
- **Deployment / Stack Signals**: MCP, CLI, Local AI
- **Momentum**: 134 ★ total (+1 24h / +3 7d) · 17 forks
- **Topics**: `ai-routing`, `anthropic`, `claude`, `claude-code`, `cost-optimization`, `gemini`, `litellm`, `llm`, `llm-router`, `mcp-server`, `model-router`, `ollama`
- **When to Use**: Best for: Individual developers and small teams that want to test free or local drafts for routine coding prompts, or add budgeted routing to a Python agent without deploying a separate service. Skip if: You need identical behavior across IDEs, guaranteed subscription savings, or an organization-wide gateway with mandatory data controls and centrally enforced budgets.

## Overview
```text
### Architecture & Core Mechanics
llm-router is a Python routing engine with host lifecycle hooks, an MCP server, and an in-process SDK. On hosts with prompt hooks, a regex heuristic assigns a route when it has enough signal and uses the default otherwise. An eligible prompt can go to a free or local model for a draft before escalating through the provider chain. The draft is an unverified hint by default, not a replacement for the host model's turn. The project’s grounding check rejects drafts that cite files or functions absent from both the available context and the indexed repository.

Routing and enforcement are separate: the default smart mode can hold selected tool calls until routing completes, while LLM_ROUTER_ENFORCE=off removes that gate. MCP clients get 12 tools by default, with the consolidated surface defined in src/llm_router/tool_surface.py. Python callers can use Router.run or Router.arun without a separate server. This distinction matters when selecting a host: Pi is MCP-only, and the Copilot extension in VS Code adds capabilities but does not perform cost routing.

### Key Capabilities & Differentiators
Ollama, OpenRouter, Gemini, and Groq are among the available backends. YAML policies range from conservative through balanced (the default) to cost_aggressive. Circuit breakers skip failing or rate-limited providers, and the Python SDK can enforce a dollar budget. Beyond text, the tool surface includes image, video, and audio calls and a multi-step orchestration tool. Session summaries report provider cost, tier mix, and p50/p95/p99 latency. The measured heuristic confidently classified 788 of 1,571 prompts in one run; that is coverage, not classification accuracy or acceptance rate.

On covered routes such as the text router, gateway, and streaming, a detected secret sends the request directly to loopback Ollama or causes a refusal. The protected path bypasses the HTTP proxy, semantic cache, judge queue, and cloud fallback; a cloud: prefix can override the decision for one request. This is entrypoint-specific, not a system-wide data-loss prevention control. The Claude Code proxy logs detections without enforcing this rule, and opt-in cloud classifiers and some direct-execution paths are also outside it.

### Trade-offs & Limitations
A conventional provider API proxy is simpler when the host already sends API-key traffic to a configurable endpoint and only needs model selection and failover. llm-router is more useful when a subscription workflow can use host hooks or MCP, but host capabilities vary and a draft can add latency without avoiding the premium turn. Savings reports compare actual spend with a counterfactual at API list prices, separating verified from unverified estimates and showing their sample counts. They do not measure cash saved on a flat subscription. RouterArena results were graded with the project's own harness and have not been independently verified.

The most consequential workstation default is direct execution: a local model can write or edit files and run commands. Path rules and static command checks are not an OS sandbox. For an initial rollout, disable this via LLM_ROUTER_DIRECT_EXECUTION=false unless you have reviewed the execution boundary. MIT licensing allows commercial use, but the local deployment does not itself supply organization-wide policy enforcement, SSO, or per-organization budgets.

### Hardware & Deployment Guide
Use Python 3.11+ and install the llm-routing package. Run llm-router install for Claude Code or select a host with --host, then use llm-router doctor to check setup and llm-router status to see whether requests are being routed. The subscription-plus-local path does not require additional provider API keys; adding cloud credentials expands the provider pool. The router runs on the workstation, but cloud routes still require network access. Daily KPI scheduling requires consent.

The documented setup-local path for a Mac with at least 48 GB of RAM is opt-in; it downloads about 22 GB and keeps about 22 GB loaded in memory. The separate install --proxy-default step points Claude Code at the proxy with the local model. v16.1.2 added ownership checks for the 127.0.0.1:11435 listener around setup. v16.1.3 sets OLLAMA_NUM_PARALLEL=1 and OLLAMA_CONTEXT_LENGTH=131072 for launchd and systemd services to avoid multiplying KV-cache memory across parallel slots. The v16.1.1 loopback forward proxy for Claude Code Remote Control remains a beta, opt-in path.
```

## Key Capabilities
```text
- Integration: Host lifecycle hooks can draft before the host model runs; MCP-only clients gain callable tools, not equivalent interception.
- Routing policy: The default balanced policy tries eligible free or local models first, while circuit breakers skip failing or rate-limited providers.
- Developer interface: The default MCP surface exposes 12 tools, and Python callers can use Router.run or Router.arun with a dollar budget that raises BudgetExceeded when spent.
- Measurement: Status and savings reports separate verified and unverified estimates, each with its own sample count; the baseline is API list price, not a subscription bill.
- Data handling: Covered text entrypoints route detected secrets directly to loopback Ollama or refuse the request by default; the rule is not universal across entrypoints.
- Local operations: v16.1.3 sets Ollama concurrency to one and context length to 131,072 tokens for the managed runner to prevent extra parallel slots from multiplying KV-cache memory.
```

## Quick Start / Clone
```bash
pip install llm-routing        # installs the `llm-router` command
llm-router install             # wire up Claude Code (default host)
llm-router doctor               # check provider connectivity and setup
llm-router status               # verify it's routing — est. savings vs baseline
```
