Favicon of 9router

9router

A self-hosted gateway routing AI coding tools to 40+ providers with free-tier fallback and token compression to cut costs.

9router website screenshot
9router GitHub repository preview

9Router is a self-hosted AI gateway built for developers who run coding assistants like Claude Code, Cursor, Codex, Cline, Copilot, or Antigravity and want to stop burning subscription quota or paying for API calls they don't need to. It sits between your CLI tool and the model provider, exposing an OpenAI-compatible endpoint at http://localhost:20128/v1 that any of these tools can point to. It's aimed at solo developers and teams who use multiple AI coding tools and want a single place to manage providers, track quota, and fall back to free or cheap models when a paid tier runs out.

The project is written in JavaScript (a Next.js app) and ships as an npm package, a Docker image, and a source checkout. It maintains a dashboard for connecting providers, viewing quota usage, and copying API keys for your CLI tools.

Key features

  • RTK Token Saver: compresses tool_result content (git diff, grep, ls output, etc.) before it reaches the model, cutting token usage by roughly 20-40% per request.
  • Tiered auto-fallback: routes requests through subscription providers first, then cheap providers (GLM, MiniMax), then free providers (Kiro, OpenCode Free, Vertex AI) once quota runs out, so a coding session doesn't stop mid-task.
  • Multi-account round-robin: rotates between multiple accounts for a single provider to spread usage and avoid hitting a single account's rate limit.
  • Format translation: converts between OpenAI and Claude request/response formats, so tools built for one API shape can talk to providers built for the other.
  • Broad tool compatibility: works with Claude Code, Codex, Cursor, Cline, Copilot, Antigravity, OpenCode, Continue, Droid, Roo, Kilo Code, Grok Build, Devin CLI, DeepSeek TUI, Qwen Code, and other CLI-based coding assistants.
  • 40+ provider support: connects to OAuth providers (Claude Code, Codex, GitHub, Cursor, Antigravity), free providers (Kiro AI, OpenCode Free, Vertex AI), and 40+ API-key providers (OpenRouter, GLM, and others).
  • Local dashboard: a web UI for connecting providers, tracking credits/quota, and copying endpoint config into your CLI tool.

Ideal use cases

9Router fits developers juggling several AI coding tools who don't want to manually swap API keys every time a subscription or free tier runs dry. It's a good match if you already have accounts with Claude Code, Codex, or GitHub Copilot and want to squeeze full value out of them before falling back to cheaper or free alternatives. Teams running high-volume tool calls (lots of git diffs, file listings, grep output) benefit from the token compression, since that overhead adds up quickly across a coding session.

It's not a fit if you need a guaranteed-uptime, provider-backed service for production inference, since free-tier providers can change terms or disappear without notice (the README itself notes several free tiers were discontinued or capped over time). It's also not the right tool if you just want a single provider's official CLI with no routing logic, or if you're uncomfortable running a local service (or Docker container) that proxies your API traffic.

Installation

The quickest path is via npm:

npm install -g 9router
9router

This opens the dashboard at http://localhost:20128. From there, connect a free provider like Kiro AI or OpenCode Free (no signup required for the latter), copy the generated API key, and point your CLI tool's settings at:

Endpoint: http://localhost:20128/v1
API Key: [from dashboard]
Model: kr/claude-sonnet-4.5

To run from source (the repository itself, since the npm package 9router-app is private):

cp .env.example .env
npm install
PORT=20128 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run dev

For a production build:

npm run build
PORT=20128 HOSTNAME=0.0.0.0 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run start

A Docker image is also published (decolua/9router on Docker Hub and GHCR) for containerized deployment. Default endpoints after setup are the dashboard at /dashboard and the OpenAI-compatible API at /v1.

Frequently asked questions

Share:

Stars
31K
Forks
6.2K
Last commit
4 days ago
Repository age
10 months
License
MIT
Self-hosted
No
Activity score
85/100
View Repository
Ad
Favicon

 

  
 

Similar to 9router

Favicon

 

  
 
Favicon

 

  
 
Favicon