decolua/9router
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.
š Quick Start ⢠š” Features ⢠š Setup ⢠š Website
š»š³ Tiįŗæng Viį»t ā¢ šØš³ äøę ā¢ šÆšµ ę„ę¬čŖ
š¤ 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
|
|
ā” Quick Start
1. Install globally:
|
|
š Dashboard opens at http://localhost:20128
2. Connect a FREE provider (no signup needed):
Dashboard ā Providers ā Connect Kiro AI (free Claude unlimited) or OpenCode Free (no auth) ā Done!
3. Use in your CLI tool:
|
|
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.
|
|
Production mode:
|
|
Default URLs:
- Dashboard:
http://localhost:20128/dashboard - OpenAI-compatible API:
http://localhost:20128/v1
Video Guides
šŗšø English 9Router + Claude Code FREE Setup by Build AI With Hamid |
š»š³ Tiįŗæng Viį»t Tiįŗæt kiį»m chi phĆ LLM cho OpenClaw vį»i 9Router by MƬ AI |
šŗšø English Claude Code FREE Forever ā Unlimited Models by Build AI With Hamid |
šŗšø English Claude CLI Free Setup with 9Router š by CodeVerse Soban |
š»š³ Tiįŗæng Viį»t CĆ i Äįŗ·t OpenClaw Free Từ A-Z + 9Router by Mai Gia |
šŗšø English FREE OpenClaw + Claude Opus 4.6 by Build AI With Hamid |
š¬ 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 |
![]() OpenClaw |
![]() Codex |
![]() OpenCode |
![]() Cursor |
![]() Antigravity |
![]() Cline |
![]() Continue |
![]() Droid |
![]() Roo |
![]() Copilot |
![]() Kilo Code |
š Supported Providers
š OAuth Providers
![]() Claude-Code |
![]() Antigravity |
![]() Codex |
![]() GitHub |
![]() Cursor |
š Free Providers
![]() Kiro AI Claude 4.5 + GLM-5 + MiniMax Unlimited FREE |
![]() OpenCode Free No auth ⢠Auto-fetch models Unlimited FREE |
![]() Vertex AI Gemini 3 Pro + GLM-5 + DeepSeek $300 credits free |
Note: iFlow, Qwen and Gemini CLI free tiers were discontinued in 2026. Use Kiro / OpenCode Free / Vertex instead.
š API Key Providers (40+)
![]() OpenRouter |
![]() GLM |
![]() Kimi |
![]() MiniMax |
![]() OpenAI |
![]() Anthropic |
![]() Gemini |
![]() DeepSeek |
![]() Groq |
![]() xAI |
![]() Mistral |
![]() Perplexity |
![]() Together AI |
![]() Fireworks |
![]() Cerebras |
![]() Cohere |
![]() NVIDIA |
SiliconFlow |
...and 20+ more providers including Nebius, Chutes, Hyperbolic, and custom OpenAI/Anthropic compatible endpoints
š” Key Features
| Feature | What It Does | Why It Matters |
|---|---|---|
| š RTK Token Saver (RTK ā40K) | Compress tool outputs (git diff, grep, ls, tree…) before sending to LLM |
Save 20-40% input tokens per request |
| šŖØ Caveman Mode (Caveman ā52K) | Inject caveman-speak prompt ā LLM replies terse, technical substance preserved | Save up to 65% output tokens |
| šÆ Smart 3-Tier Fallback | Auto-route: Subscription ā Cheap ā Free | Never stop coding, zero downtime |
| š Real-Time Quota Tracking | Live token count + reset countdown | Maximize subscription value |
| š Format Translation | OpenAI ā Claude ā Gemini ā Cursor ā Kiro ā Vertex | Works with any CLI tool |
| š„ Multi-Account Support | Multiple accounts per provider | Load balancing + redundancy |
| š Auto Token Refresh | OAuth tokens refresh automatically | No manual re-login needed |
| šØ Custom Combos | Create unlimited model combinations | Tailor fallback to your needs |
| š Request Logging | Debug mode with full request/response logs | Troubleshoot issues easily |
| š¾ Cloud Sync | Sync config across devices | Same setup everywhere |
| š Usage Analytics | Track tokens, cost, trends over time | Optimize spending |
| š Deploy Anywhere | Localhost, VPS, Docker, Cloudflare Workers | Flexible deployment options |
š Feature Details
š RTK Token Saver
Tool outputs (git diff, grep, find, ls, tree, log dumps…) often eat 30-50% of your prompt budget. RTK detects them and applies smart, lossless compression before the request hits the LLM:
- Filters:
git-diff,git-status,grep,find,ls,tree,dedup-log,smart-truncate,read-numbered,search-list - Auto-detect: No config needed ā RTK peeks the first 1KB of each
tool_resultand picks the right filter. - Safe by design: If a filter fails, throws, or makes output bigger, RTK silently keeps the original text. Errors never break your request.
- Universal: Works across all formats (OpenAI, Claude, Gemini, Cursor, Kiro, OpenAI Responses) because it runs before any format translation.
- Default ON: Toggle anytime in Dashboard ā Endpoint settings.
|
|
šÆ Smart 3-Tier Fallback
Create combos with automatic fallback:
|
|
š Real-Time Quota Tracking
- Token consumption per provider
- Reset countdown (5-hour, daily, weekly)
- Cost estimation for paid tiers
- Monthly spending reports
š Format Translation
Seamless translation between formats:
- OpenAI ā Claude ā Gemini ā Cursor ā Kiro ā Vertex ā Antigravity ā Ollama ā OpenAI Responses
- Your CLI tool sends OpenAI format ā 9Router translates ā Provider receives native format
- Works with any tool that supports custom OpenAI endpoints
š„ Multi-Account Support
- Add multiple accounts per provider
- Auto round-robin or priority-based routing
- Fallback to next account when one hits quota
š Auto Token Refresh
- OAuth tokens automatically refresh before expiration
- No manual re-authentication needed
- Seamless experience across all providers
šØ Custom Combos
- Create unlimited model combinations
- Mix subscription, cheap, and free tiers
- Name your combos for easy access
- Share combos across devices with Cloud Sync
š Request Logging
- Enable debug mode for full request/response logs
- Track API calls, headers, and payloads
- Troubleshoot integration issues
- Export logs for analysis
š¾ Cloud Sync
- Sync providers, combos, and settings across devices
- Automatic background sync
- Secure encrypted storage
- Access your setup from anywhere
Cloud Runtime Notes
- Prefer server-side cloud variables in production:
BASE_URL(internal callback URL used by sync scheduler)CLOUD_URL(cloud sync endpoint base)
NEXT_PUBLIC_BASE_URLandNEXT_PUBLIC_CLOUD_URLare still supported for compatibility/UI, but server runtime now prioritizesBASE_URL/CLOUD_URL.- Cloud sync requests now use timeout + fail-fast behavior to avoid UI hanging when cloud DNS/network is unavailable.
š Usage Analytics
- Track token usage per provider and model
- Cost estimation and spending trends
- Monthly reports and insights
- Optimize your AI spending
š” IMPORTANT - Understanding Dashboard Costs:
The “cost” displayed in Usage Analytics is for tracking and comparison purposes only. 9Router itself never charges you anything. You only pay providers directly (if using paid services).
Example: If your dashboard shows “$290 total cost” while using iFlow models, this represents what you would have paid using paid APIs directly. Your actual cost = $0 (iFlow is free unlimited).
Think of it as a “savings tracker” showing how much you’re saving by using free models or routing through 9Router!
š Deploy Anywhere
- š» Localhost - Default, works offline
- āļø VPS/Cloud - Share across devices
- š³ Docker - One-command deployment
- š Cloudflare Workers - Global edge network
š° Pricing at a Glance
| Tier | Provider | Cost | Quota Reset | Best For |
|---|---|---|---|---|
| š TOKEN SAVER | RTK (built-in) | FREE | Always on | Save 20-40% tokens on EVERY request |
| š³ SUBSCRIPTION | Claude Code (Pro/Max) | $20-200/mo | 5h + weekly | Already subscribed |
| Codex (Plus/Pro) | $20-200/mo | 5h + weekly | OpenAI users | |
| GitHub Copilot | $10-19/mo | Monthly | GitHub users | |
| Cursor IDE | $20/mo | Monthly | Cursor users | |
| š° CHEAP | GLM-5.1 / GLM-4.7 | $0.6/1M | Daily 10AM | Budget backup |
| MiniMax M2.7 | $0.2/1M | 5-hour rolling | Cheapest option | |
| Kimi K2.5 | $9/mo flat | 10M tokens/mo | Predictable cost | |
| š FREE | Kiro AI | $0 | Unlimited | Claude 4.5 + GLM-5 + MiniMax free |
| OpenCode Free | $0 | Unlimited | No auth, auto-fetch models | |
| Vertex AI | $300 credits | New GCP accounts | Gemini 3 Pro + DeepSeek + GLM-5 |
š” Pro Tip: RTK + Kiro AI + OpenCode Free combo = $0 cost + 20-40% token savings!
š Understanding 9Router Costs & Billing
9Router Billing Reality:
ā
9Router software = FREE forever (open source, never charges)
ā
Dashboard “costs” = Display/tracking only (not actual bills)
ā
You pay providers directly (subscriptions or API fees)
ā
FREE providers stay FREE (iFlow, Kiro, Qwen = $0 unlimited)
ā 9Router never sends invoices or charges your card
How Cost Display Works:
The dashboard shows estimated costs as if you were using paid APIs directly. This is not billing - it’s a comparison tool to show your savings.
Example Scenario:
|
|
Payment Rules:
- Subscription providers (Claude Code, Codex): Pay them directly via their websites
- Cheap providers (GLM, MiniMax): Pay them directly, 9Router just routes
- FREE providers (iFlow, Kiro, Qwen): Genuinely free forever, no hidden charges
- 9Router: Never charges anything, ever
šÆ Use Cases
Case 1: “I have Claude Pro subscription”
Problem: Quota expires unused, rate limits during heavy coding
Solution:
|
|
Case 2: “I want zero cost”
Problem: Can’t afford subscriptions, need reliable AI coding
Solution:
|
|
Case 3: “I need 24/7 coding, no interruptions”
Problem: Deadlines, can’t afford downtime
Solution:
|
|
Case 4: “I want FREE AI in OpenClaw”
Problem: Need AI assistant in messaging apps (WhatsApp, Telegram, Slack…), completely free
Solution:
|
|
ā Frequently Asked Questions
š Why does my dashboard show high costs?
The dashboard tracks your token usage and displays estimated costs as if you were using paid APIs directly. This is not actual billing - it’s a reference to show how much you’re saving by using free models or existing subscriptions through 9Router.
Example:
- Dashboard shows: “$290 total cost”
- Reality: You’re using iFlow (FREE unlimited)
- Your actual cost: $0.00
- What $290 means: Amount you saved by using free models instead of paid APIs!
The cost display is a “savings tracker” to help you understand your usage patterns and optimization opportunities.
š³ Will I be charged by 9Router?
No. 9Router is free, open-source software that runs on your own computer. It never charges you anything.
You only pay:
- ā Subscription providers (Claude Code $20/mo, Codex $20-200/mo) ā Pay them directly on their websites
- ā Cheap providers (GLM, MiniMax) ā Pay them directly, 9Router just routes your requests
- ā 9Router itself ā Never charges anything, ever
9Router is a local proxy/router. It doesn’t have your credit card, can’t send invoices, and has no billing system. It’s completely free software.
š Are FREE providers really unlimited?
Yes! The current FREE providers (Kiro, OpenCode Free, Vertex) are genuinely free with no hidden charges.
These are free services offered by those respective companies:
- Kiro AI: Free unlimited Claude 4.5 + GLM-5 + MiniMax via AWS Builder ID / Google / GitHub OAuth
- OpenCode Free: No-auth passthrough proxy, models auto-fetched from
opencode.ai/zen/v1/models - Vertex AI: $300 free credits for new Google Cloud accounts (90 days)
9Router just routes your requests to them - there’s no “catch” or future billing. They’re truly free services, and 9Router makes them easy to use with fallback support.
Discontinued free tiers (no longer recommended):
- ā iFlow: Was free unlimited, now changed to paid (2026)
- ā Qwen Code: Free OAuth tier discontinued by Alibaba on 2026-04-15
- ā Gemini CLI: Still works, but using it with non-CLI tools (Claude, Codex, Cursor…) may result in account bans ā only use if you stick to Gemini CLI itself
š° How do I minimize my actual AI costs?
Free-First Strategy:
-
Start with 100% free combo:
1 2 31. gc/gemini-3-flash (180K/month free from Google) 2. if/kimi-k2-thinking (unlimited free from iFlow) 3. qw/qwen3-coder-plus (unlimited free from Qwen)Cost: $0/month
-
Add cheap backup only if you need it:
14. glm/glm-4.7 ($0.6/1M tokens)Additional cost: Only pay for what you actually use
-
Use subscription providers last:
- Only if you already have them
- 9Router helps maximize their value through quota tracking
Result: Most users can operate at $0/month using only free tiers!
š What if my usage suddenly spikes?
9Router’s smart fallback prevents surprise charges:
Scenario: You’re on a coding sprint and blow through your quotas
Without 9Router:
- ā Hit rate limit ā Work stops ā Frustration
- ā Or: Accidentally rack up huge API bills
With 9Router:
- ā Subscription hits limit ā Auto-fallback to cheap tier
- ā Cheap tier gets expensive ā Auto-fallback to free tier
- ā Never stop coding ā Predictable costs
You’re in control: Set spending limits per provider in dashboard, and 9Router respects them.
š Setup Guide
š Subscription Providers (Maximize Value)
Claude Code (Pro/Max)
|
|
Pro Tip: Use Opus for complex tasks, Sonnet for speed. 9Router tracks quota per model!
OpenAI Codex (Plus/Pro)
|
|
GitHub Copilot
|
|
Cursor IDE
|
|
š° Cheap Providers (Backup)
GLM-5.1 / GLM-4.7 (Daily reset, $0.6/1M)
- Sign up: Zhipu AI
- Get API key from Coding Plan
- Dashboard ā Add API Key:
- Provider:
glm - API Key:
your-key
- Provider:
Use: glm/glm-5.1, glm/glm-5, glm/glm-4.7
Pro Tip: Coding Plan offers 3Ć quota at 1/7 cost! Reset daily 10:00 AM.
MiniMax M2.7 (5h reset, $0.20/1M)
- Sign up: MiniMax
- Get API key
- Dashboard ā Add API Key
Use: minimax/MiniMax-M2.7, minimax/MiniMax-M2.5
Pro Tip: Cheapest option for long context (1M tokens)!
Kimi K2.5 ($9/month flat)
- Subscribe: Moonshot AI
- Get API key
- Dashboard ā Add API Key
Use: kimi/kimi-k2.5, kimi/kimi-k2.5-thinking
Pro Tip: Fixed $9/month for 10M tokens = $0.90/1M effective cost!
š FREE Providers (Recommended)
Kiro AI (Claude 4.5 + GLM-5 + MiniMax FREE)
|
|
Pro Tip: Best free option for Claude. No API key, no payment, fully unlimited.
OpenCode Free (No auth, auto-fetch models)
|
|
Pro Tip: Fastest setup. Just connect and start coding.
Vertex AI ($300 free credits for new GCP accounts)
|
|
Pro Tip: New Google Cloud accounts get $300 credits free for 90 days. Plenty for daily coding.
šØ Create Combos
Example 1: Maximize Subscription ā Cheap Backup
|
|
Example 2: Free-Only (Zero Cost)
|
|
š§ CLI Integration
Cursor IDE
|
|
Or use combo: premium-coding
Claude Code
Edit ~/.claude/config.json:
|
|
Codex CLI
|
|
OpenClaw
Option 1 ā Dashboard (recommended):
|
|
Option 2 ā Manual: Edit ~/.openclaw/openclaw.json:
|
|
Note: OpenClaw only works with local 9Router. Use
127.0.0.1instead oflocalhostto avoid IPv6 resolution issues.
Cline / Continue / RooCode
|
|
š Deployment
VPS Deployment
|
|
Docker
|
|
Portable command (if you are already at repository root):
|
|
Container defaults:
PORT=20128HOSTNAME=0.0.0.0
Useful commands:
|
|
Environment Variables
| Variable | Default | Description |
|---|---|---|
JWT_SECRET |
9router-default-secret-change-me |
JWT signing secret for dashboard auth cookie (change in production) |
INITIAL_PASSWORD |
123456 |
First login password when no saved hash exists |
DATA_DIR |
~/.9router |
Main app database location (db.json) |
PORT |
framework default | Service port (20128 in examples) |
HOSTNAME |
framework default | Bind host (Docker defaults to 0.0.0.0) |
NODE_ENV |
runtime default | Set production for deploy |
BASE_URL |
http://localhost:20128 |
Server-side internal base URL used by cloud sync jobs |
CLOUD_URL |
https://9router.com |
Server-side cloud sync endpoint base URL |
NEXT_PUBLIC_BASE_URL |
http://localhost:3000 |
Backward-compatible/public base URL (prefer BASE_URL for server runtime) |
NEXT_PUBLIC_CLOUD_URL |
https://9router.com |
Backward-compatible/public cloud URL (prefer CLOUD_URL for server runtime) |
API_KEY_SECRET |
endpoint-proxy-api-key-secret |
HMAC secret for generated API keys |
MACHINE_ID_SALT |
endpoint-proxy-salt |
Salt for stable machine ID hashing |
ENABLE_REQUEST_LOGS |
false |
Enables request/response logs under logs/ |
AUTH_COOKIE_SECURE |
false |
Force Secure auth cookie (set true behind HTTPS reverse proxy) |
REQUIRE_API_KEY |
false |
Enforce Bearer API key on /v1/* routes (recommended for internet-exposed deploys) |
HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY |
empty | Optional outbound proxy for upstream provider calls |
Notes:
- Lowercase proxy variables are also supported:
http_proxy,https_proxy,all_proxy,no_proxy. .envis not baked into Docker image (.dockerignore); inject runtime config with--env-fileor-e.- On Windows,
APPDATAcan be used for local storage path resolution. INSTANCE_NAMEappears in older docs/env templates, but is currently not used at runtime.
Runtime Files and Storage
- Main app state:
${DATA_DIR}/db.json(providers, combos, aliases, keys, settings), managed bysrc/lib/localDb.js. - Usage history and logs:
${DATA_DIR}/usage.jsonand${DATA_DIR}/log.txt, managed bysrc/lib/usageDb.js. - Optional request/translator logs:
<repo>/logs/...whenENABLE_REQUEST_LOGS=true. - Both
${DATA_DIR}and~/.9routerresolve to the same location in a Docker container ā the symlink/root/.9router -> /app/datais created at build time.
š Available Models
View all available models
Claude Code (cc/) - Pro/Max:
cc/claude-opus-4-7cc/claude-opus-4-6cc/claude-sonnet-4-6cc/claude-sonnet-4-5-20250929cc/claude-haiku-4-5-20251001
Codex (cx/) - Plus/Pro:
cx/gpt-5.5cx/gpt-5.4cx/gpt-5.3-codexcx/gpt-5.2-codexcx/gpt-5.1-codex-max
GitHub Copilot (gh/):
gh/gpt-5.4gh/claude-opus-4.7gh/claude-sonnet-4.6gh/gemini-3.1-pro-previewgh/grok-code-fast-1
Cursor (cu/) - Subscription:
cu/claude-4.6-opus-maxcu/claude-4.5-sonnet-thinkingcu/gpt-5.3-codexcu/kimi-k2.5
GLM (glm/) - $0.6/1M:
glm/glm-5.1glm/glm-5glm/glm-4.7
MiniMax (minimax/) - $0.2/1M:
minimax/MiniMax-M2.7minimax/MiniMax-M2.5
Kimi (kimi/) - $9/mo flat:
kimi/kimi-k2.5kimi/kimi-k2.5-thinking
Kiro (kr/) - FREE unlimited:
kr/claude-sonnet-4.5kr/claude-haiku-4.5kr/glm-5kr/MiniMax-M2.5kr/qwen3-coder-nextkr/deepseek-3.2
OpenCode Free (oc/) - FREE no-auth:
- Auto-fetched from
opencode.ai/zen/v1/models
Vertex AI (vertex/) - $300 free credits:
vertex/gemini-3.1-pro-previewvertex/gemini-3-flash-previewvertex/gemini-2.5-flashvertex-partner/glm-5-maasvertex-partner/deepseek-v3.2-maas
š Troubleshooting
“Language model did not provide messages”
- Provider quota exhausted ā Check dashboard quota tracker
- Solution: Use combo fallback or switch to cheaper tier
Rate limiting
- Subscription quota out ā Fallback to GLM/MiniMax
- Add combo:
cc/claude-opus-4-7 ā glm/glm-5.1 ā kr/claude-sonnet-4.5
OAuth token expired
- Auto-refreshed by 9Router
- If issues persist: Dashboard ā Provider ā Reconnect
High costs
- Enable RTK in Dashboard ā Endpoint settings (default ON, saves 20-40% tokens)
- Check usage stats in Dashboard
- Switch primary model to GLM/MiniMax
- Use free tier (Kiro, OpenCode Free, Vertex) for non-critical tasks
Dashboard opens on wrong port
- Set
PORT=20128andNEXT_PUBLIC_BASE_URL=http://localhost:20128
First login not working
- Check
INITIAL_PASSWORDin.env - If unset, fallback password is
123456
No request logs under logs/
- Set
ENABLE_REQUEST_LOGS=true
š ļø Tech Stack
- Runtime: Node.js 20+
- Framework: Next.js 16
- UI: React 19 + Tailwind CSS 4
- Database: LowDB (JSON file-based)
- Streaming: Server-Sent Events (SSE)
- Auth: OAuth 2.0 (PKCE) + JWT + API Keys
š API Reference
Chat Completions
|
|
List Models
|
|
š§ Support
- Website: 9router.com
- GitHub: github.com/decolua/9router
- Issues: github.com/decolua/9router/issues
š„ Contributors
Thanks to all contributors who helped make 9Router better!
š Star Chart
š Forks
OmniRoute ā A full-featured TypeScript fork of 9Router. Adds 36+ providers, 4-tier auto-fallback, multi-modal APIs (images, embeddings, audio, TTS), circuit breaker, semantic cache, LLM evaluations, and a polished dashboard. 368+ unit tests. Available via npm and Docker.
š Acknowledgments
Built on the shoulders of giants:
- CLIProxyAPI ā original Go implementation that inspired this JavaScript port.
- RTK
ā Rust token-saver. 9Router ports its compression pipeline to JS ā ā20-40% input tokens on every request.
- Caveman
by @JuliusBrussee ā viral “why use many token when few token do trick”. 9Router adapts its prompt ā ā65% output tokens.
Huge thanks to these authors ā without their work, 9Router’s token-saving features wouldn’t exist. ā them on GitHub!
š License
MIT License - see LICENSE for details.






























