Overview
9Router is a self-hosted router that sits between your AI coding tools and the providers behind them. It exposes an OpenAI-compatible endpoint on `http://localhost:20128/v1`, so any CLI that accepts a custom base URL — Claude Code, Codex, Cursor, Cline, Copilot, OpenCode, Antigravity, OpenClaw — points at it instead of a vendor, and gets access to 40+ providers and 100+ models behind one key.
Its purpose is to keep you from stalling mid-task. It tracks per-provider quota so a paid subscription is used up before it resets, then falls back through tiers automatically — subscription first, then cheap models, then free ones — with no downtime when one runs out. Multiple accounts per provider are rotated round-robin, tokens are refreshed automatically, and request formats are translated between the OpenAI and Claude shapes so the same downstream tool works against either.
A second lever is RTK, a token saver that compresses `tool_result` content — the git diffs, greps and directory listings that dominate an agent's context — before it is sent, which the project reports as 20-40% fewer tokens per request. A dashboard at the same port handles provider connection, quota views and key management.
What it does
- OpenAI-compatible local endpoint any coding CLI can point at, fronting 40+ providers and 100+ models
- Tiered auto-fallback — subscription, then cheap, then free — so an exhausted quota does not stop a session
- Per-provider quota tracking with automatic token refresh
- RTK token saver that compresses tool_result payloads, reported at 20-40% fewer tokens per request
- Format translation between the OpenAI and Claude request shapes
- Multi-account round-robin per provider
- Web dashboard for providers, quota and keys; npm, Docker and GHCR distributions
Getting started
Install globally, open the dashboard, connect a provider, then repoint your coding CLI at the local endpoint.
Install and start
The dashboard opens at http://localhost:20128.
npm install -g 9router
9routerConnect a provider
In the dashboard, go to Providers and connect one. Kiro AI and OpenCode Free need no signup, so you can verify the path end to end before wiring up a paid account.
Dashboard -> Providers -> ConnectPoint your CLI at the router
Set the base URL and the key from the dashboard in Claude Code, Codex, Cursor, Cline or OpenClaw, then pick a model.
Endpoint: http://localhost:20128/v1
API Key: [copy from dashboard]
Model: kr/claude-sonnet-4.5Or run it from source
Source and Docker are the expected local development paths.
cp .env.example .env
npm install
PORT=20128 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run devProduction mode
Dashboard at /dashboard, OpenAI-compatible API at /v1.
npm run build
PORT=20128 HOSTNAME=0.0.0.0 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run startCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Keep a coding agent running past a provider rate limit by falling back automatically instead of stopping
- Spend a monthly subscription quota fully before it resets, then move to cheaper models
- Cut agent token spend by compressing the tool output that dominates the context window
- Drive several coding CLIs through one endpoint and one key rather than configuring each separately
How 9Router compares
9Router alongside other open-source gateways & routing tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| OmniRoute | ★ 67.7k | A local-first AI gateway that fronts hundreds of model providers with one OpenAI-compatible endpoint, quota-aware auto-fallback, many routing strategies and prompt compression. |
| LiteLLM | ★ 59.1k | A Python SDK and proxy server that gives one OpenAI-compatible API to 100+ LLM providers, with cost tracking, budgets, fallbacks, rate limiting, and an admin UI. |
| Free Claude Code | ★ 55.4k | A local proxy that points Claude Code, Codex, Pi, OpenCode, Cline and other agent CLIs at 50 free, paid, subscription or local model providers, with automatic failover and an admin UI. |
| Kong Gateway | ★ 44.1k | A Lua/NGINX API gateway whose AI Gateway plugins put one universal endpoint in front of OpenAI, Anthropic, Gemini, Bedrock and other providers, with semantic routing, caching and MCP traffic governance. |
| 9Router | ★ 29.2k | Local router for coding CLIs with quota tracking, tiered fallback and token compression |
| Apache APISIX | ★ 17.1k | A cloud-native API gateway whose AI plugins add multi-provider LLM proxying, load balancing, retries and fallbacks, token-based rate limiting, and content moderation. |
| OpenCodex | ★ 15.3k | Local proxy that translates the Codex Responses API to 40+ providers, so Codex CLI, Claude Code and Grok Build can run on any model, with routing combos, failover and account pooling. |
| Portkey AI Gateway | ★ 13k | An LLM gateway that routes calls to 100+ providers through one API and adds logging, tracing, caching, and fallbacks for production AI traffic. |