9router

decoluaMIT活跃维护

把 Claude Code、Cursor、Copilot 等编程助手接到 40+ 家免费模型供应商的 AI 网关,支持自动故障切换和 RTK 省 token,避免额度耗尽。

Unlimited FREE AI coding. Connect Claude Code, Codex, Cursor, Cline, Copilot, Antigravity to FREE Claude/GPT/Gemini via 40+ providers. Auto-fallback, RTK -40% tokens, never hit limits.

v0.5.35发布于 2026-07-16 11:14 UTC32,210star +129 / 7 天6,304fork同步于 2026-11-10 17:21 UTC

怎么上手

由 README 提炼,执行前请确认
npm install -g 9router
9router
硬件要求按 README 说明

README 未说明显存或 GPU 要求;从源码构建时建议临时加 2G swap 并限制编译并行度,说明对内存有一定要求。

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

本地 AI 路由网关,把各类编码工具接到 40+ 家模型并自动降级省钱

把 Claude Code、Cursor、Copilot 等编程助手接到 40+ 家免费模型供应商的 AI 网关,支持自动故障切换和 RTK 省 token,避免额度耗尽。

核心能力

  • 用 RTK 自动压缩 tool_result 内容,省 20-40% token
  • 按订阅→便宜→免费三级自动 fallback,避免中断
  • 同一 provider 多账号轮询分摊配额
  • 做 OpenAI 与 Claude 格式互转,兼容各类 CLI 工具
  • 跟踪各订阅配额,重置前尽量用满

容易踩的坑

默认监听 20128 端口,CLI 里要填 http://localhost:20128/v1 并从 dashboard 复制 API Key;源码包名为私有的 9router-app,需先 cp .env.example .env 再 npm install;免费额度依赖 Kiro AI 或 OpenCode Free 等 provider,需在 dashboard 手动连接后才可用。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.5.35
  1. v0.5.35feat: Grok Imagine video, Copilot Claude route, i18n th/fa version 0.5.35最新正式版2026-07-16 · 2026-07-16 11:14 UTC

    Features:

    • xAI: Grok Imagine video generation (/v1/videos) + CLI
    • CLI tools: Grok Build setup — writes [model.9router] to ~/.grok/config.toml
    • GitHub Copilot: route Claude models through Copilot native /v1/messages
    • Kiro: add GPT-5.6 model family (#2596)
    • RTK: X-9Router-Token-Saver header to bypass token savers per request
    • Providers: quota visibility settings
    • Translator: drop temperature for all Claude models
    • i18n: Thai (th) + Persian (fa) translations / README

    Fixes:

    • Providers: bulk-add API keys no longer overwrite existing keys (gap-fill Key N)
    • Anthropic: lowercase anthropic-version header to prevent duplication on /v1/messages
    • Alicode-intl: use DashScope compatible-mode endpoint so standard keys work
    • Grok CLI: align Grok Build with current subscription protocol (#2590)
    • Grok CLI: surface expiresAt so proactive token refresh fires (#2546)
    • Kiro: improve direct session cache reuse
    • Models: populate capabilities for live-catalog LLM models
    • Models: list compatible provider models in /v1/models
    • Thinking: send explicit thinking:{type:adaptive} alongside output_config.effort
    • Translator: strip client_metadata when converting openai-responses to openai

    Improvements:

    • Perf: skip inactive background services on startup

    Docs:

    • README: Persian YouTube tutorial
  2. v0.5.20feat: thinking level picker + suffix support across providers version 0.5.202026-07-07 · 2026-07-07 09:30 UTC
    查看更新说明

    Features:

    • Thinking: per-model thinking level picker on provider page, appends (level) suffix to copied model names for forced reasoning effort across all formats (openai, claude, gemini, deepseek, kimi, qwen, zai, minimax, hunyuan, step)
    • RTK: add JS-native git-log filter (#2423)
    • Caveman: add targeted upstream-aligned style rules (#2424)
    • i18n: add Farsi (fa) language support (#2385)

    Fixes:

    • Thinking: strip (level) suffix from upstream body.model so providers no longer reject requests
    • Translator: preserve developer instructions in openai-responses conversion (#2434)
    • count_tokens: count structured Anthropic blocks (#2419)
    • Volcengine-ark: clamp GLM-5 max_tokens to model output ceiling (#2428)
    • Kimi: normalize reasoning_effort to backend enum (#2427)
    • Claude: reconcile max_tokens vs thinking budget and lift per-model ceiling (#2381)
    • Kiro: deliver system prompt natively, add Opus 4.5/4.7/4.8, tolerate dash version ids (#2366)
    • Headroom: proxy dashboard through app (#2372)
    • MITM: recover from stale lock file on server start

    Docs:

    • README: swap in Vietnamese tutorial video; add English and Urdu/Hindi tutorials (#2305)
    • Add CLAUDE.md guidance for Claude Code (#2354)
  3. v0.5.18v0.5.18: cached token tracking, provider fixes version 0.5.182026-07-03 · 2026-07-03 08:38 UTC
    查看更新说明

    Features:

    • Usage: track cached tokens + correct input/output/cache cost (#2209)
    • Codex: show reset credit expiry details (#2290)
    • NVIDIA: add new models and capabilities
    • ClinePass: add provider support

    Fixes:

    • Usage: dedupe streaming request-details log entries
    • Claude: drop foreign thinking signatures in passthrough
    • Prevent non-SSE stream pipe crash and cross-IdP account overwrites (#2244)
    • Kiro: route IdC auth to regional CodeWhisperer surface (#2297)
    • Kiro: add Claude Sonnet 5 model support (#2264)
    • Xiaomi-tokenplan: region selector, key validation, multi-connection (#2251)
    • Translator: strict Anthropic content block compliance (#2225)
    • Kimchi: strip reasoning_content echo to bound multi-turn input tokens
    • Kimchi: bump User-Agent to kimchi/0.1.40 (#2256)
    • Codebuddy-cn: strip empty tool_calls arrays to preserve reasoning
    • Antigravity: preserve Claude tool delta index (#2223)
    • MITM: generate root CA on server startup (#2228)
  4. v0.5.12feat: token-saver dashboard, Venice AI, Blackbox catalog overhaul version 0.5.122026-06-26 · 2026-06-26 11:04 UTC
    查看更新说明

    Features:

    • Add token-saver dashboard page — decolua
    • Add bulk delete for provider connections — teddytkz
    • Resolve GitHub Copilot model catalog from upstream — caiqinzhou
    • Add Venice AI provider — Brokenc0de
    • Add Kiro external_idp import for Microsoft SSO (CLIProxyAPI) — Stevanus Pangau
    • Overhaul Blackbox provider catalog + WebUI test support — suryacagur

    Fixes:

    • Provider thinking compatibility (DeepSeek/Gemini) — Mink Nguyen
    • Stop double-counting streaming usage at source — decolua
    • Usage logging dedupe to reduce stats churn — Mink Nguyen
    • Prevent non-JSON SSE lines / duplicate [DONE] from breaking clients (PR #2046) — qianze
    • Resolve Gemini TTS models from catalog — nguyenha935
    • Support Kiro IDC (organization) token import — quanturbo
    • Preserve forced streaming for JSON clients (#2031) — Joseph Yaksich
    • Preserve Responses text format (Codex) — tenglong
    • Support Gemini native TTS generateContent endpoint — nguyenha935
    • Add missing zh-CN endpoint key label (i18n) — weimaozhen
    • CodeBuddy: only send reasoning params when client requests reasoning (#2071) — Rex
    • Show custom provider models in combo picker — Sapto
    • Docker: add docker-compose.yml with headroom enabled by default — nitsuahlabs
    • Clarify token diagnostics vs provider billing (headroom, #1998) — Sutarto Jordan Chrisfivo
    • Translate openai-responses input through OpenAI for compression (#1998) — Ankit
    • Kiro: report 1M context window for claude-opus-4.8 — EdisonPVE
    • Avoid stale redirects after auth changes (#2100) — Emirhan
    • Mark Claude Opus 4.7 (dashed id) as 1M context — Brokenc0de
    • Preserve reasoning effort through Codex translations — ntdung6868
    • Token-saver: full width card layout — decolua
    • Antigravity: retry transient upstream failures — Sutarto Jordan Chrisfivo
    • Param-support: handle strip rules without match/drop (#1960) — Joseph Yaksich
    • Translator: resolve custom provider prefix in debug endpoint (#1083) — hamsa0x7
  5. v0.5.8feat: Antigravity native image gen, CodeBuddy CN auth version 0.5.82026-06-21 · 2026-06-21 11:05 UTC
    查看更新说明

    Features:

    • Antigravity: native image generation support (image models tagged kind:image, shown in media-providers UI)
    • CodeBuddy CN: API key auth + credit quota tracker
    • CodeBuddy CN: short model prefix alias cbcn

    Fixes:

    • MiniMax-M3: enable vision capability
    • Headroom: support Docker sidecar proxy
    • Antigravity: image executor fixes
    • mimo-free: Chrome User-Agent rotation to bypass anti-abuse gate
    • cloudflare-ai: flatten content-part arrays to string to avoid oneOf 400 (#1926)
    • Translator: normalize tools to Anthropic-native shape for non-Anthropic providers
    • CLI: handle Next.js 16 nested standalone output path (#1940)
    • Codex: preserve custom tools during request normalization
    • next.config: add new route for responses endpoint to API

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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

    🚀 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:

    # Create Temporary Memory For Build
    sudo fallocate -l 2G /swapfile_temp
    sudo chmod 600 /swapfile_temp
    sudo mkswap /swapfile_temp
    sudo swapon /swapfile_temp
    
    export MAKEFLAGS="-j1"
    export DLIB_NO_GUI_SUPPORT=1
    export CFLAGS="-mno-avx"
    
    npm run build
    
    # Clear temporary swap
    sudo swapoff /swapfile_temp
    sudo rm /swapfile_temp
    
    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

    🎬 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:


    🌐 Supported Providers

    🔐 OAuth Providers

    🆓 Free Providers

    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+)

    🏠 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
    📊 Usage AnalyticsTrack tokens, cost, trends over timeOptimize spending
    🌐 Deploy AnywhereLocalhost, VPS, Docker, Cloudflare WorkersFlexible deployment options

    Set X-9Router-Token-Saver: off to bypass all token savers for one chat request.

    🚀 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_result and 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.
    Without RTK: 47K tokens sent to LLM
    With RTK:    28K tokens sent to LLM   (40% saved · same context · same answer)
    

    🧠 Headroom Token Saver

    Headroom is optional and runs separately. 9Router calls Headroom's local /v1/compress endpoint, then keeps normal routing, fallback, auth, and usage tracking:

    Client → 9Router → Headroom /v1/compress → 9Router → provider
    

    Local setup:

    pip install "headroom-ai[proxy]"
    headroom proxy --port 8787
    

    Enable in Dashboard → Endpoint → Token Saver → Headroom. Default URL: http://localhost:8787.

    Docker examples:

    # Headroom service in same Docker network
    http://headroom:8787
    
    # Headroom running on host machine
    http://host.docker.internal:8787
    

    If Headroom is down or returns an error, 9Router fails open and sends the original request.

    🐴 Ponytail (Lazy Senior Dev)

    Ponytail injects a "lazy senior dev" system prompt into every request, biasing the LLM toward minimal, YAGNI-first code — deletion over addition, stdlib over new deps, one-liners over abstractions. Adapted from DietrichGebert/ponytail.

    • Lite — Build what's asked, name the lazier alternative.
    • Full — YAGNI ladder enforced: stdlib → native → existing deps → one-liner → minimal code.
    • Ultra — YAGNI extremist: deletion first, ship the one-liner, challenge the rest of the requirement in the same response.
    Without Ponytail: verbose code, extra abstractions, "just in case" scaffolding
    With Ponytail:    shortest working diff, no unrequested abstractions, fewer tokens
    

    Never trades away: input validation, error handling that prevents data loss, security, accessibility, or anything explicitly requested. Enable in Dashboard → Endpoint → Ponytail. Stacks with Caveman (output terseness) and RTK (input compression).

    🎯 Smart 3-Tier Fallback

    Create combos with automatic fallback:

    Combo: "my-coding-stack"
      1. cc/claude-opus-4-6        (your subscription)
      2. glm/glm-4.7               (cheap backup, $0.6/1M)
      3. if/kimi-k2-thinking       (free fallback)
    
    → Auto switches when quota runs out or errors occur
    

    📊 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_URL and NEXT_PUBLIC_CLOUD_URL are still supported for compatibility/UI, but server runtime now prioritizes BASE_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 Kiro free models, this represents what you would have paid using paid APIs directly. Your actual cost = $0 (Kiro free tier: ~50 credits/mo).

    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

    TierProviderCostQuota ResetBest For
    🚀 TOKEN SAVERRTK (built-in)FREEAlways onSave 20-40% tokens on EVERY request
    💳 SUBSCRIPTIONClaude Code (Pro/Max)$20-200/mo5h + weeklyAlready subscribed
    Codex (Plus/Pro)$20-200/mo5h + weeklyOpenAI users
    GitHub Copilot$10-19/moMonthlyGitHub users
    Cursor IDE$20/moMonthlyCursor users
    💰 CHEAPGLM-5.1 / GLM-4.7$0.6/1MDaily 10AMBudget backup
    MiniMax M2.7$0.2/1M5-hour rollingCheapest option
    Kimi K2.5$9/mo flat10M tokens/moPredictable cost
    🆓 FREEKiro AI$050 credits/moClaude 4.5 + GLM-5 + MiniMax free (paid tiers above)
    OpenCode Free$0Varies*No auth, auto-fetch models (list changes over time)
    Vertex AI$300 creditsNew GCP accountsGemini 3 Pro + DeepSeek + GLM-5 (use Vertex AI Studio endpoint for free credits)

    💡 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 (Kiro ~50 credits/mo, OpenCode Free, Vertex $300 credits = $0 within free-tier limits) — note iFlow/Qwen/Gemini CLI free tiers were discontinued in 2026 ❌ 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:

    Dashboard Display:
    • Total Requests: 1,662
    • Total Tokens: 47M
    • Display Cost: $290
    
    Reality Check:
    • Provider: Kiro (free tier: ~50 credits/mo)
    • Actual Payment: $0.00
    • What $290 Means: Amount you SAVED by using free models!
    

    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:

    Combo: "maximize-claude"
      1. cc/claude-opus-4-7        (use subscription fully)
      2. glm/glm-5.1               (cheap backup when quota out)
      3. kr/claude-sonnet-4.5      (free emergency fallback)
    
    Monthly cost: $20 (subscription) + ~$5 (backup) = $25 total
    vs. $20 + hitting limits = frustration
    

    Case 2: "I want zero cost"

    Problem: Can't afford subscriptions, need reliable AI coding

    Solution:

    Combo: "free-forever"
      1. kr/claude-sonnet-4.5      (Claude 4.5 free via Kiro, ~50 credits/mo)
      2. kr/glm-5                  (GLM-5 free via Kiro)
      3. oc/<auto>                 (OpenCode Free, no auth)
    
    Monthly cost: $0
    Quality: Production-ready models + RTK saves 20-40% tokens
    

    Case 3: "I need 24/7 coding, no interruptions"

    Problem: Deadlines, can't afford downtime

    Solution:

    Combo: "always-on"
      1. cc/claude-opus-4-7        (best quality)
      2. cx/gpt-5.5                (second subscription)
      3. glm/glm-5.1               (cheap, resets daily)
      4. minimax/MiniMax-M2.7      (cheapest, 5h reset)
      5. kr/claude-sonnet-4.5      (free via Kiro, ~50 credits/mo)
    
    Result: 5 layers of fallback = zero downtime
    Monthly cost: $20-200 (subscriptions) + $10-20 (backup)
    

    Case 4: "I want FREE AI in OpenClaw"

    Problem: Need AI assistant in messaging apps (WhatsApp, Telegram, Slack...), completely free

    Solution:

    Combo: "openclaw-free"
      1. kr/claude-sonnet-4.5      (Claude 4.5 free)
      2. kr/glm-5                  (GLM-5 free)
      3. kr/MiniMax-M2.5           (MiniMax free)
    
    Monthly cost: $0
    Access via: WhatsApp, Telegram, Slack, Discord, iMessage, Signal...
    

    ❓ Frequently Asked Questions

    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 Kiro free models (~50 credits/mo)
    • 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.

    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.

    Mostly! The current FREE providers (Kiro, OpenCode Free, Vertex) are genuinely free, but free tiers have limits:

    These are free services offered by those respective companies:

    • Kiro AI: ~50 credits/month free (plus 500 trial credits for new accounts in the first 30 days) via AWS Builder ID / Google / GitHub OAuth. Paid tiers available above that.
    • OpenCode Free: No-auth passthrough proxy, models auto-fetched from opencode.ai/zen/v1/models. The free model list fluctuates over time (some models free only for limited promos) — subject to change without notice.
    • Vertex AI: $300 free credits for new Google Cloud accounts (90 days). Since Mar 2026 the Gemini API endpoint no longer consumes these credits — use the Vertex AI Studio endpoint instead.

    9Router just routes your requests to them - there's no "catch" or future billing from 9Router itself. 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 fully discontinued by Alibaba on 2026-04-15
    • ❌ Gemini CLI: Service fully shut down by Google on 2026-06-18 (replaced by the closed-source Antigravity CLI). Discontinued — do not use.

    Free-First Strategy:

    1. Start with 100% free combo:

      1. kr/glm-5 (GLM-5 free via Kiro, ~50 credits/mo)
      2. OpenCode Free models (no auth, auto-fetched)
      3. Vertex AI Gemini 3 Pro (using the Vertex AI Studio endpoint with $300 credits)
      

      Cost: $0/month (within Kiro's free credit cap; OpenCode/Vertex subject to their free-tier limits)

    2. Add cheap backup only if you need it:

      4. glm/glm-4.7 ($0.6/1M tokens)
      

      Additional cost: Only pay for what you actually use

    3. 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!

    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

    Claude Code (Pro/Max)

    Dashboard → Providers → Connect Claude Code
    → OAuth login → Auto token refresh
    → 5-hour + weekly quota tracking
    
    Models:
      cc/claude-opus-4-7
      cc/claude-opus-4-6
      cc/claude-sonnet-4-6
      cc/claude-haiku-4-5-20251001
    

    Pro Tip: Use Opus for complex tasks, Sonnet for speed. 9Router tracks quota per model!

    OpenAI Codex (Plus/Pro)

    Dashboard → Providers → Connect Codex
    → OAuth login (port 1455)
    → 5-hour + weekly reset
    
    Models:
      cx/gpt-5.5
      cx/gpt-5.4
      cx/gpt-5.3-codex
      cx/gpt-5.2-codex
    

    GitHub Copilot

    Dashboard → Providers → Connect GitHub
    → OAuth via GitHub
    → Monthly reset (1st of month)
    
    Models:
      gh/gpt-5.4
      gh/claude-opus-4.7
      gh/claude-sonnet-4.6
      gh/gemini-3.1-pro-preview
      gh/grok-code-fast-1
    

    Cursor IDE

    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
    

    GLM-5.1 / GLM-4.7 (Daily reset, $0.6/1M)

    1. Sign up: Zhipu AI
    2. Get API key from Coding Plan
    3. Dashboard → Add API Key:
      • Provider: glm
      • API Key: your-key

    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)

    1. Sign up: MiniMax
    2. Get API key
    3. 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)

    1. Subscribe: Moonshot AI
    2. Get API key
    3. 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!

    Kiro AI (Claude 4.5 + GLM-5 + MiniMax FREE)

    Dashboard → Connect Kiro
    → AWS Builder ID, AWS IAM Identity Center, Google, or GitHub
    → Unlimited usage
    
    Models:
      kr/claude-sonnet-4.5
      kr/claude-haiku-4.5
      kr/glm-5
      kr/MiniMax-M2.5
      kr/qwen3-coder-next
      kr/deepseek-3.2
    

    Pro Tip: Best free option for Claude. No API key, no payment, fully unlimited.

    OpenCode Free (No auth, auto-fetch models)

    Dashboard → Connect OpenCode Free
    → No login required (passthrough proxy)
    → Models auto-fetched from opencode.ai/zen/v1/models
    

    Pro Tip: Fastest setup. Just connect and start coding.

    Vertex AI ($300 free credits for new GCP accounts)

    Dashboard → Connect Vertex AI
    → Upload Google Cloud Service Account JSON
    → Enable Vertex AI API in your GCP project
    
    Models:
      vertex/gemini-3.1-pro-preview
      vertex/gemini-3-flash-preview
      vertex/gemini-2.5-flash
    
    Vertex Partner (Anthropic / DeepSeek / GLM / Qwen via Vertex):
      vertex-partner/glm-5-maas
      vertex-partner/deepseek-v3.2-maas
      vertex-partner/qwen3-next-80b-a3b-thinking-maas
    

    For a raw Google Cloud API-key connection, set the following through PUT /api/providers/<connection-id> to select the global endpoint:

    {
      "providerSpecificData": {
        "projectId": "YOUR_GOOGLE_CLOUD_PROJECT_ID",
        "location": "global"
      }
    }
    

    With an explicit project, API-key requests honor location and default to global when it is omitted. Connections without an explicit project retain the projectless endpoint. Gemini 4 Argon supports global, us, and eu, not regional locations such as europe-west1; see Google's supported locations.

    Pro Tip: New Google Cloud accounts get $300 credits free for 90 days. Plenty for daily coding.

    Example 1: Maximize Subscription → Cheap Backup

    Dashboard → Combos → Create New
    
    Name: premium-coding
    Models:
      1. cc/claude-opus-4-7 (Subscription primary)
      2. glm/glm-5.1 (Cheap backup, $0.6/1M)
      3. minimax/MiniMax-M2.7 (Cheapest fallback, $0.20/1M)
    
    Use in CLI: premium-coding
    
    Monthly cost example (100M tokens):
      80M via Claude (subscription): $0 extra
      15M via GLM: $9
      5M via MiniMax: $1
      Total: $10 + your subscription
    

    Example 2: Free-Only (Zero Cost)

    Name: free-combo
    Models:
      1. kr/claude-sonnet-4.5 (Claude 4.5 free via Kiro, ~50 credits/mo)
      2. kr/glm-5 (GLM-5 free via Kiro)
      3. vertex/gemini-3.1-pro-preview ($300 free credits)
    
    Cost: $0 forever (+ 20-40% token savings via RTK)!
    

    Cursor IDE

    Settings → Models → Advanced:
      OpenAI API Base URL: http://localhost:20128/v1
      OpenAI API Key: [from 9router dashboard]
      Model: cc/claude-opus-4-7
    

    Or use combo: premium-coding

    Claude Code

    Edit ~/.claude/config.json:

    {
      "anthropic_api_base": "http://localhost:20128/v1",
      "anthropic_api_key": "your-9router-api-key"
    }
    

    Codex CLI

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

    OpenClaw

    Option 1 — Dashboard (recommended):

    Dashboard → CLI Tools → OpenClaw → Select Model → Apply
    

    Option 2 — Manual: Edit ~/.openclaw/openclaw.json:

    {
      "agents": {
        "defaults": {
          "model": {
            "primary": "9router/kr/claude-sonnet-4.5"
          }
        }
      },
      "models": {
        "providers": {
          "9router": {
            "baseUrl": "http://127.0.0.1:20128/v1",
            "apiKey": "sk_9router",
            "api": "openai-completions",
            "models": [
              {
                "id": "kr/claude-sonnet-4.5",
                "name": "Claude Sonnet 4.5 (Kiro Free)"
              }
            ]
          }
        }
      }
    }
    

    Note: OpenClaw only works with local 9Router. Use 127.0.0.1 instead of localhost to avoid IPv6 resolution issues.

    Cline / Continue / RooCode

    Provider: OpenAI Compatible
    Base URL: http://localhost:20128/v1
    API Key: [from dashboard]
    Model: cc/claude-opus-4-7
    

    VPS Deployment

    # Clone and install
    git clone https://github.com/decolua/9router.git
    cd 9router
    npm install
    npm run build
    
    # Configure
    export JWT_SECRET="your-secure-secret-change-this"
    export INITIAL_PASSWORD="your-password"
    export DATA_DIR="/var/lib/9router"
    export PORT="20128"
    export HOSTNAME="0.0.0.0"
    export NODE_ENV="production"
    export NEXT_PUBLIC_BASE_URL="http://localhost:20128"
    export NEXT_PUBLIC_CLOUD_URL="https://9router.com"
    export API_KEY_SECRET="endpoint-proxy-api-key-secret"
    export MACHINE_ID_SALT="endpoint-proxy-salt"
    
    # Start
    npm run start
    
    # Or use PM2
    npm install -g pm2
    pm2 start npm --name 9router -- start
    pm2 save
    pm2 startup
    

    Docker

    Published images (multi-platform linux/amd64 + linux/arm64):

    Quick start (use published image):

    docker run -d \
      --name 9router \
      -p 20128:20128 \
      -v "$HOME/.9router:/app/data" \
      -e DATA_DIR=/app/data \
      decolua/9router:latest
    

    → Open http://localhost:20128

    Build from source (dev):

    git clone https://github.com/decolua/9router.git
    cd 9router/app
    docker build -t 9router .
    docker run -d --name 9router -p 20128:20128 \
      -v "$HOME/.9router:/app/data" -e DATA_DIR=/app/data 9router
    

    Container defaults:

    • PORT=20128
    • HOSTNAME=0.0.0.0

    Useful commands:

    docker logs -f 9router
    docker restart 9router
    docker stop 9router && docker rm 9router
    docker pull decolua/9router:latest   # update to latest
    

    Data persistence: $HOME/.9router/db/data.sqlite on host ↔ /app/data/db/data.sqlite in container.

    Environment Variables

    VariableDefaultDescription
    JWT_SECRETAuto-generated (~/.9router/jwt-secret)JWT signing secret for dashboard auth cookie (override to share across instances)
    INITIAL_PASSWORD123456First login password when no saved hash exists
    DATA_DIR~/.9routerMain app data location (SQLite at $DATA_DIR/db/data.sqlite)
    PORTframework defaultService port (20128 in examples)
    HOSTNAMEframework defaultBind host (Docker defaults to 0.0.0.0)
    NODE_ENVruntime defaultSet production for deploy
    BASE_URLhttp://localhost:20128Server-side internal base URL used by cloud sync jobs
    CLOUD_URLhttps://9router.comServer-side cloud sync endpoint base URL
    NEXT_PUBLIC_BASE_URLhttp://localhost:3000Backward-compatible/public base URL (prefer BASE_URL for server runtime)
    NEXT_PUBLIC_CLOUD_URLhttps://9router.comBackward-compatible/public cloud URL (prefer CLOUD_URL for server runtime)
    API_KEY_SECRETendpoint-proxy-api-key-secretHMAC secret for generated API keys
    MACHINE_ID_SALTendpoint-proxy-saltSalt for stable machine ID hashing
    ENABLE_REQUEST_LOGSfalseEnables request/response logs under logs/
    AUTH_COOKIE_SECUREfalseForce Secure auth cookie (set true behind HTTPS reverse proxy)
    REQUIRE_API_KEYfalseEnforce Bearer API key on /v1/* routes (recommended for internet-exposed deploys)
    HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXYemptyOptional outbound proxy for upstream provider calls
    SEARXNG_URLhttp://localhost:8888/searchEndpoint for the built-in unauthenticated SearXNG web-search provider

    Notes:

    • Lowercase proxy variables are also supported: http_proxy, https_proxy, all_proxy, no_proxy.
    • .env is not baked into Docker image (.dockerignore); inject runtime config with --env-file or -e.
    • On Windows, APPDATA can be used for local storage path resolution.
    • INSTANCE_NAME appears in older docs/env templates, but is currently not used at runtime.

    Runtime Files and Storage

    • Main app state: ${DATA_DIR}/db/data.sqlite (SQLite — providers, combos, aliases, keys, settings, usage history)
    • Auto backups: ${DATA_DIR}/db/backups/
    • Optional request/translator logs: <repo>/logs/... when ENABLE_REQUEST_LOGS=true
    • Both ${DATA_DIR} and ~/.9router resolve to the same location in a Docker container — the symlink /root/.9router -> /app/data is created at build time.

    📊 Available Models

    Claude Code (cc/) - Pro/Max:

    • cc/claude-opus-4-7
    • cc/claude-opus-4-6
    • cc/claude-sonnet-4-6
    • cc/claude-sonnet-4-5-20250929
    • cc/claude-haiku-4-5-20251001

    Codex (cx/) - Plus/Pro:

    • cx/gpt-5.5
    • cx/gpt-5.4
    • cx/gpt-5.3-codex
    • cx/gpt-5.2-codex
    • cx/gpt-5.1-codex-max

    GitHub Copilot (gh/):

    • gh/gpt-5.4
    • gh/claude-opus-4.7
    • gh/claude-sonnet-4.6
    • gh/gemini-3.1-pro-preview
    • gh/grok-code-fast-1

    Cursor (cu/) - Subscription:

    • cu/claude-4.6-opus-max
    • cu/claude-4.5-sonnet-thinking
    • cu/gpt-5.3-codex
    • cu/kimi-k2.5

    GLM (glm/) - $0.6/1M:

    • glm/glm-5.1
    • glm/glm-5
    • glm/glm-4.7

    MiniMax (minimax/) - $0.2/1M:

    • minimax/MiniMax-M2.7
    • minimax/MiniMax-M2.5

    Kimi (kimi/) - $9/mo flat:

    • kimi/kimi-k2.5
    • kimi/kimi-k2.5-thinking

    Kiro (kr/) - Free (~50 credits/month, paid tiers above):

    • kr/claude-sonnet-4.5
    • kr/claude-haiku-4.5
    • kr/glm-5
    • kr/MiniMax-M2.5
    • kr/qwen3-coder-next
    • kr/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-preview
    • vertex/gemini-3-flash-preview
    • vertex/gemini-2.5-flash
    • vertex-partner/glm-5-maas
    • vertex-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=20128 and NEXT_PUBLIC_BASE_URL=http://localhost:20128

    First login not working

    • Check INITIAL_PASSWORD in .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: SQLite (better-sqlite3 / node:sqlite / sql.js fallback)
    • Streaming: Server-Sent Events (SSE)
    • Auth: OAuth 2.0 (PKCE) + JWT + API Keys

    📝 API Reference

    Chat Completions

    POST http://localhost:20128/v1/chat/completions
    Authorization: Bearer your-api-key
    Content-Type: application/json
    
    {
      "model": "cc/claude-opus-4-6",
      "messages": [
        {"role": "user", "content": "Write a function to..."}
      ],
      "stream": true
    }
    

    List Models

    GET http://localhost:20128/v1/models
    Authorization: Bearer your-api-key
    
    → Returns all models + combos in OpenAI format
    

    📧 Support


    👥 Contributors

    Thanks to all contributors who helped make 9Router better!

    Contributors


    📊 Star Chart

    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 Stars — Rust token-saver. 9Router ports its compression pipeline to JS → −20-40% input tokens on every request.
    • Caveman Stars by @JuliusBrussee — viral "why use many token when few token do trick". 9Router adapts its prompt → −65% output tokens.
    • Ponytail Stars by @DietrichGebert — "lazy senior dev" skill. 9Router injects its YAGNI-first ladder → fewer tokens, less code, shorter diffs.

    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.