Sandbox
@decolua/9router

AI gateway for Claude Code, Codex, and Cursor

9Router gives your coding tools one local endpoint and sends each request to the best provider you have available. It supports format translation, quota tracking, automatic fallback, and token-saving compression for tool output.

28,339 stars5.1k forksJavaScriptUpdated 6d ago
Tiết kiệm chi phí gọi LLM cho Openclaw với 9Router - Mì AI
Mì AI23k views • 5 months ago

Videos about this repo

Who it's for

Builders who want Claude Code, Codex, Cursor, or Cline to keep working across many AI providers from one setup.

What it delivers

You can keep coding through rate limits and provider changes without reconfiguring each tool.

What it does

RTK token saver

Compresses tool output like `git diff`, `grep`, and `ls` before it reaches the model.

Three-tier fallback

Routes from subscription models to cheap models to free models when a quota runs out.

Format translation

Converts between OpenAI, Claude, Gemini, Cursor, Kiro, and Vertex request shapes.

Quota tracking

Shows live token use and reset timing for connected accounts.

Multi-account routing

Lets one provider use multiple accounts for round-robin load balancing and backup.

Auto token refresh

Refreshes OAuth tokens without asking you to sign in again.

Cloud sync

Keeps router settings in sync across devices.

Self-hosted speech and embeddings

Can point STT, TTS, and embedding connections at your own servers.

How to get it

  1. 11. Install globally
    npm install -g 9router
    9router
  2. 23. Use in your CLI tool
    Claude Code/Codex/OpenClaw/Cursor/Cline Settings:
      Endpoint: http://localhost:20128/v1
      API Key: [copy from dashboard]
      Model: kr/claude-sonnet-4.5
  3. 3This repository package is private (9router-app), so source/Docker execution is the…
    cp .env.example .env
    npm install
    PORT=20128 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run dev
  4. 4Production mode
    npm run build
    PORT=20128 HOSTNAME=0.0.0.0 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run start
  5. 5Run
    Dashboard → Providers → Connect Cursor
    → OAuth login
    → Monthly subscription
    
    Models:
      cu/claude-4.6-opus-max
      cu/claude-4.5-sonnet-thinking
      cu/gpt-5.3-codex
  6. 6Run
    Dashboard → Connect OpenCode Free
    → No login required (passthrough proxy)
    → Models auto-fetched from opencode.ai/zen/v1/models

README

9Router Dashboard

9Router - FREE AI Router & Token Saver

Never stop coding. Save 20-40% tokens with RTK + auto-fallback to FREE & cheap AI models.

Connect All AI Code Tools (Claude Code, Cursor, Antigravity, Copilot, Codex, Gemini, OpenCode, Cline, OpenClaw...) to 40+ AI Providers & 100+ Models.

npm Downloads Docker Pulls GHCR License

decolua%2F9router | Trendshift

🚀 Quick Start💡 Features📖 Setup🌐 Website

🇧🇷 Português (Brasil)🇻🇳 Tiếng Việt🇨🇳 中文🇯🇵 日本語🇷🇺 Русский🇹🇭 ไทย🇮🇷 فارسی🇮🇩 Indonesia🇪🇸 Español🇫🇷 Français


🤔 Why 9Router?

Stop wasting money, tokens and hitting limits:

  • ❌ Subscription quota expires unused every month
  • ❌ Rate limits stop you mid-coding
  • ❌ Tool outputs (git diff, grep, ls...) burn tokens fast
  • ❌ Expensive APIs ($20-50/month per provider)
  • ❌ Manual switching between providers

9Router solves this:

  • RTK Token Saver - Auto-compress tool_result content, save 20-40% tokens per request
  • Maximize subscriptions - Track quota, use every bit before reset
  • Auto fallback - Subscription → Cheap → Free, zero downtime
  • Multi-account - Round-robin between accounts per provider
  • Universal - Works with Claude Code, Codex, Cursor, Cline, any CLI tool

🔄 How It Works

┌─────────────┐
│  Your CLI   │  (Claude Code, Codex, OpenClaw, Cursor, Cline...)
│   Tool      │
└──────┬──────┘
       │ http://localhost:20128/v1
       ↓
┌─────────────────────────────────────────────┐
│           9Router (Smart Router)            │
│  • RTK Token Saver (cut tool_result tokens) │
│  • Format translation (OpenAI ↔ Claude)     │
│  • Quota tracking                           │
│  • Auto token refresh                       │
└──────┬──────────────────────────────────────┘
       │
       ├─→ [Tier 1: SUBSCRIPTION] Claude Code, Codex, GitHub Copilot
       │   ↓ quota exhausted
       ├─→ [Tier 2: CHEAP] GLM ($0.6/1M), MiniMax ($0.2/1M)
       │   ↓ budget limit
       └─→ [Tier 3: FREE] Kiro, OpenCode Free, Vertex ($300 credits)

Result: Never stop coding, minimal cost + 20-40% token savings via RTK

⚡ Quick Start

1. Install globally:

npm install -g 9router
9router

🎉 Dashboard opens at http://localhost:20128

2. Connect a FREE provider (no signup needed):

Dashboard → Providers → Connect Kiro AI (~50 credits/month free: Claude 4.5 + GLM-5 + MiniMax) or OpenCode Free (no auth) → Done!

3. Use in your CLI tool:

Claude Code/Codex/OpenClaw/Cursor/Cline Settings:
  Endpoint: http://localhost:20128/v1
  API Key: [copy from dashboard]
  Model: kr/claude-sonnet-4.5

That's it! Start coding with FREE AI models.

Alternative: run from source (this repository):

This repository package is private (9router-app), so source/Docker execution is the expected local development path.

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

Production mode:

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

Default URLs:

  • Dashboard: http://localhost:20128/dashboard
  • OpenAI-compatible API: http://localhost:20128/v1

Video Guides

Tiết kiệm chi phí LLM với 9Router
🇻🇳 Tiếng Việt
Tiết kiệm chi phí LLM cho OpenClaw với 9Router
by Mì AI
9Router + Claude Code FREE Unlimited Setup
🇵🇰 اردو / हिन्दी
9Router + Claude Code FREE Unlimited Setup
by Build AI With Hamid
9Router Setup Tutorial
🇺🇸 English
9Router + Claude Code FREE Setup
by Build AI With Hamid
9Router Setup Tutorial
🇺🇸 English
9Router + Claude Code FREE Setup
by Build AI With Hamid
Claude Code FREE Forever
🇺🇸 English
Claude Code FREE Forever — Unlimited Models
by Build AI With Hamid
Claude CLI Free Setup
🇺🇸 English
Claude CLI Free Setup with 9Router 🚀
by CodeVerse Soban
Cài đặt OpenClaw Free A-Z
🇻🇳 Tiếng Việt
Cài Đặt OpenClaw Free Từ A-Z + 9Router
by Mai Gia
FREE OpenClaw with Claude Opus
🇺🇸 English
FREE OpenClaw + Claude Opus 4.6
by Build AI With Hamid
Claude CLI Free Setup
🇮🇩 Indonesia
Koding 24 Jam Anti Rate Limit! Hemat Token AI 65% | Tutorial Quick Setup 9Router 🚀
by Krisswuh
Cara Deploy 9Router di Hugging Face GRATIS Non-Stop! | Alternatif VPS RAM 16GB
🇮🇩 Indonesia
Cara Deploy 9Router di Hugging Face GRATIS Non-Stop! | Alternatif VPS RAM 16GB
by Krisswuh
این شکلی از هر API ای استفاده کن برای هوش مصنوعی
🇮🇷 Persian-فارسی
این شکلی از هر API ای استفاده کن برای هوش مصنوعی
by Matin SenPai
Hướng Dẫn Setup OpenClaw + 9Router: Tạo Bot Zalo AI Tự Động Từ A-Z
🇻🇳 Tiếng Việt
Hướng Dẫn Setup OpenClaw + 9Router: Tạo Bot Zalo AI Tự Động Từ A-Z
by tuanminhhole

🎬 Made a video about 9Router? Submit a Pull Request adding your video to this section — we'll merge it!


🛠️ Supported CLI Tools

9Router works seamlessly with all major AI coding tools:

Claude Code
Claude-Code
OpenClaw
OpenClaw
Codex
Codex
OpenCode
OpenCode
Cursor
Cursor
Antigravity
Antigravity
Cline
Cline
Continue
Continue
Droid
Droid
Roo
Roo
Copilot
Copilot
Kilo Code
Kilo Code
OpenDesign
OpenDesign
jcode
jcode
Grok Build
Grok Build
Devin CLI
Devin CLI
DeepSeek TUI
DeepSeek TUI
Qwen Code
Qwen Code

🌐 Supported Providers

🔐 OAuth Providers

Claude Code
Claude-Code
Antigravity
Antigravity
Codex
Codex
GitHub
GitHub
Cursor
Cursor
Kimchi
Kimchi

🆓 Free Providers

Kiro
Kiro AI
Claude 4.5 + GLM-5 + MiniMax
50 credits/month free
OpenCode Free
OpenCode Free
No auth • Auto-fetch models
Free (model list varies)
Vertex AI
Vertex AI
Gemini 3 Pro + GLM-5 + DeepSeek
$300 credits free

Note: iFlow, Qwen Code and Gemini CLI free tiers were discontinued in 2026. Use Kiro / OpenCode Free / Vertex instead.

Kiro AI moved to a paid model in Sep 2025 — the free tier is now capped at 50 credits/month (plus 500 trial credits for new accounts in the first 30 days). Paid tiers: Pro $20/mo (1,000 credits), Pro+ $40/mo (2,000), Pro Max $100/mo (5,000), Power $200/mo (10,000). OpenCode Free model list fluctuates over time (some models free only for limited promos) — subject to change without notice. Vertex AI: the $300 free credit for new GCP accounts is still valid, but since Mar 2026 the Gemini API endpoint no longer consumes these credits — call the Vertex AI Studio endpoint instead.

🔑 API Key Providers (40+)

OpenRouter
OpenRouter
GLM
GLM
Kimi
Kimi
MiniMax
MiniMax
OpenAI
OpenAI
Anthropic
Anthropic
Gemini
Gemini
DeepSeek
DeepSeek
Groq
Groq
xAI
xAI
Mistral
Mistral
Perplexity
Perplexity
Together
Together AI
Fireworks
Fireworks
Cerebras
Cerebras
Cohere
Cohere
NVIDIA
NVIDIA
SiliconFlow
SiliconFlow

...and 20+ more providers including Nebius, Chutes, Hyperbolic, and custom OpenAI/Anthropic compatible endpoints

🏠 Self-hosted Providers

For speech and embeddings served from your own machine — whisper.cpp, faster-whisper, Speaches, Kokoro-FastAPI, openedai-speech, llama.cpp/llama-server, vLLM, Infinity, text-embeddings-inference, or anything else that speaks the OpenAI shape.

ProviderEndpoint usedTypical server
Self-hosted STT/v1/audio/transcriptionswhisper.cpp, faster-whisper
Self-hosted TTS/v1/audio/speechKokoro-FastAPI, openedai-speech
Self-hosted Embedding/v1/embeddingsllama-server, vLLM, Infinity

Every other speech provider is a named cloud service with a fixed endpoint. These three read their address from each connection, so one provider can front several machines and load-balance across them like any other.

Set it on the connection as providerSpecificData.baseUrl:

ProviderGive itResult
Self-hosted STTthe full URL — http://host:8080/v1/audio/transcriptionsused as-is
Self-hosted TTSthe server root — http://host:8880+ /v1/audio/speech
Self-hosted Embeddingthe OpenAI base, /v1 included — http://host:8080/v1+ /embeddings

Mind the /v1 on embeddings. The adapter appends /embeddings, so http://host:8080 resolves to http://host:8080/embeddings and misses the OpenAI route — llama-server answers 501. Give it the same base URL an OpenAI client would use. A full .../v1/embeddings is also accepted, so a value pasted from a curl example works too.

The API key is not checked by most local servers, but the field must be non-empty: it is what gives the connection a credentials record, and baseUrl lives there. Any placeholder works.

Self-hosted Embedding has no cloud fallback by design — a connection saved without a baseUrl is reported as a configuration error rather than quietly falling back to api.openai.com, which would send your input text and API key to a third party under a provider named "Self-hosted".


💡 Key Features

FeatureWhat It DoesWhy It Matters
🚀 RTK Token Saver (RTK ⭐40K)Compress tool outputs (git diff, grep, ls, tree...) before sending to LLMSave 20-40% input tokens per request
🧠 Headroom Token Saver (Headroom)Optional external /v1/compress proxy before provider routingSave more context tokens without changing clients
🪨 Caveman Mode (Caveman ⭐52K)Inject caveman-speak prompt → LLM replies terse, technical substance preservedSave up to 65% output tokens
🐴 Ponytail (Ponytail)Inject "lazy senior dev" prompt → LLM writes minimal, YAGNI-first code (Lite/Full/Ultra)Fewer output tokens, less refactoring
🎯 Smart 3-Tier FallbackAuto-route: Subscription → Cheap → FreeNever stop coding, zero downtime
📊 Real-Time Quota TrackingLive token count + reset countdownMaximize subscription value
🔄 Format TranslationOpenAI ↔ Claude ↔ Gemini ↔ Cursor ↔ Kiro ↔ VertexWorks with any CLI tool
👥 Multi-Account SupportMultiple accounts per providerLoad balancing + redundancy
🔄 Auto Token RefreshOAuth tokens refresh automaticallyNo manual re-login needed
🎨 Custom CombosCreate unlimited model combinationsTailor fallback to your needs
📝 Request LoggingDebug mode with full request/response logsTroubleshoot issues easily
💾 Cloud SyncSync config across devicesSame setup everywhere
📊 **Usag

Files in the repo

Repository payload33 top-level entries
  • .github
  • .vscode
  • cli
  • docs
  • gitbook
  • i18n
  • images
  • open-sse
  • public
  • scripts
  • skills
  • src
  • tests
  • .dockerignore
  • .env.example
  • .gitignore
  • .npmignore
  • captain-definition
  • CHANGELOG.md
  • CLAUDE.md
  • custom-server.js
  • docker-compose.yml
  • DOCKER.md
  • Dockerfile
  • eslint.config.mjs
  • jsconfig.json
  • LICENSE
  • next.config.mjs
  • package.json
  • postcss.config.mjs
  • README.md
  • README.zh-CN.md
  • start.sh

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k