9router: Route Claude Code, Codex & Cursor to 40+ Free AI Providers

If you’re using more than one AI coding tool, you already know the friction: each one needs its own endpoint, its own API key, its own model configuration. Then you run out of quota in the middle of a refactor and have to change everything manually. 9router solves that.

decolua/9router is a local router that intercepts requests from your AI coding tools — Claude Code, Codex, Cursor, Cline, Copilot, OpenCode, OpenClaw — and forwards them through a single OpenAI-compatible endpoint at http://localhost:20128/v1. You configure the providers and fallback logic once. Each tool talks to the same local address.

What Problem It Solves

Without a routing layer, multi-tool setups are a mess by design. You end up with:

  • Subscription model in Claude Code
  • Custom OpenAI endpoint in Cursor or Codex
  • A different API key in Cline or RooCode
  • Free providers scattered across separate configs with no fallback plan

9router centralizes all of that in a single local gateway. You configure the tool once, and routing, model selection, and fallback happen at the proxy layer — invisible to the tool.

RTK Token Compression

One of the most interesting features of 9router is RTK Token Saver, which compresses tool output before it reaches the model. Commands like git diff, grep, ls, tree, and log dumps are the biggest token consumers in a coding session. Depending on the project, RTK can reduce input tokens by 20% to 40% on many requests.

Important caveat: Compression works on patterns in tool output, not on semantic content. For critical logs, full file reads, or anything where output fidelity matters, test it before relying on it in production. Response quality can vary.

Automatic Fallback

9router lets you stack providers in priority order:

  1. Subscription model (e.g. cc/claude-opus-4-7)
  2. Economical API (e.g. glm/glm-5.1)
  3. Free tier (e.g. kr/claude-sonnet-4-5)

When the first tier hits a rate limit or runs out of quota, the router falls back to the next. No manual switching, no interrupted sessions.

Important: Fallback means different models. Claude Opus and a free GLM tier aren’t equivalent. For work where consistency matters — large refactors, migrations, protocol design — stick with a fixed model and switch manually when needed. Automatic fallback is more useful for exploratory or lower-criticality work.

Free Providers: Read the Fine Print

The README highlights Kiro, OpenCode Free, and Google Vertex as currently free options. But free tiers change. Before routing real workloads through any free provider, verify:

  • Is the free quota still available?
  • Does it have regional restrictions? (Relevant for LatAm devs — Vertex and others have geographic limitations)
  • Does it allow automated/programmatic access, or is it for direct use only?
  • Can high volume trigger account bans?

9router handles routing. It doesn’t protect you from upstream policy violations.

Multi-Account Rotation and Request Logging

Beyond fallback, 9router supports multi-account key rotation — useful if you manage multiple API accounts to stay under per-account rate limits. All requests are logged in the local dashboard at http://localhost:20128/dashboard, where you can see which provider handled each request, token usage, and errors.

The May 10 update included a bun:sqlite adapter and bulk API key import, which makes managing large credential sets a lot less tedious.

Quick Setup

npm install -g 9router
9router

Requires Node.js >=18.0.0. Then configure your tool to point to http://localhost:20128/v1 with the API key the dashboard generates.

For Codex CLI:

export OPENAI_BASE_URL="http://localhost:20128"
export OPENAI_API_KEY="your-9router-api-key"
codex "your prompt"

For VPS or LAN deployment, the defaults aren’t secure. You need to configure JWT_SECRET, INITIAL_PASSWORD, API_KEY_SECRET, and put authentication in front of the dashboard before exposing it outside localhost. Don’t skip this.

The Complementary Project: OmniRoute

It’s worth knowing about diegosouzapw/OmniRoute: it covers 160+ providers and combines RTK with an additional compression technique called Caveman to reach ~95% context compression. It’s a different philosophy — OmniRoute trades some output predictability for maximum provider breadth. Worth evaluating if 9router’s 40+ providers don’t cover your setup.

Who It’s For

9router is a good fit if you already use multiple AI coding tools, manage multiple provider accounts, or burn through paid quotas faster than you’d like. The value multiplies when you have Claude Code for complex reasoning, a cheaper API for boilerplate code, and a free tier for quick queries — all routing through the same local endpoint without manual switching.

If you use a single tool with a single subscription, this adds complexity without much benefit.

The project is MIT and in active development.