- A single local OpenAI-compatible proxy (port 20128) lets all your AI coding tools share one provider setup — switch providers without touching the tools.
- Three-tier fallback: when your subscription quota runs out it drops to cheap APIs (GLM $0.6/1M, MiniMax $0.2/1M), and when those run out it drops to free options (Kiro, OpenCode Free, Vertex's $300 credit).
- Built-in RTK compression for tool_result payloads (git diff, grep, log, and the like); the project claims it saves 20–40% on input tokens.
Table of Contents
You subscribed to Claude Pro, then bought Cursor, and your company handed you GitHub Copilot too — and now every service manages its own quota in isolation: when one runs out you switch to another by hand, OAuth tokens expire after a few hours and force a re-login, and each tool ships its API in a different format. You’ve paid for plenty of capacity, yet you keep hitting rate limits at exactly the moment you need them most.
9Router takes a dead-simple angle: run an OpenAI-compatible proxy on your machine, collect every AI coding tool’s requests into one place, and automatically route them to whichever provider is currently “cheapest and still has quota.” It has racked up 18k stars on GitHub, is actively maintained, and ships with a matching npm package and Docker image.
Design Philosophy: Tools Only Know One Endpoint
The traditional approach has every tool configure its own provider and hold its own API key. The moment a provider changes, you reconfigure every tool.
9Router pulls that layer out: as long as a tool supports a “custom OpenAI endpoint,” you point them all at http://localhost:20128/v1 and hand provider selection, switching, and authentication entirely to 9Router. In other words, swapping providers is 9Router’s problem; your tools get configured once and never need touching again.
npm install -g 9router
9router
# Dashboard opens at http://localhost:20128
Once it’s running, just change each tool’s endpoint and API key to the values the dashboard gives you:
Claude Code / Codex / Cursor / Cline settings:
Endpoint: http://localhost:20128/v1
API Key: (copy from dashboard)
Model: e.g. kr/claude-sonnet-4.5
API keys and OAuth tokens are stored only on your machine — nothing is sent to a third party.
Three-Tier Fallback Routing
The core mechanism is three-tier fallback that only drops down once the current tier is exhausted, ordered from lowest cost to highest:
flowchart LR
A[CLI tool request] --> R[9Router]
R --> B["Tier 1 Subscription<br/>Claude Code · Codex · Copilot"]
B -- quota exhausted --> C["Tier 2 Cheap API<br/>GLM $0.6/1M · MiniMax $0.2/1M"]
C -- budget cap --> D["Tier 3 Free<br/>Kiro · OpenCode Free · Vertex $300"]
B -- success --> E[Response]
C -- success --> E
D -- success --> E
Switching between tiers is automatic — no manual intervention needed; when a provider has multiple accounts it can round-robin across them, and the dashboard offers live quota tracking with reset countdowns.
The currently reliable options in the free tier:
| Free Provider | What you get |
|---|---|
| Kiro AI | Claude 4.5 + GLM-5 + MiniMax, billed as unlimited free |
| OpenCode Free | No auth required, auto-discovers available models |
| Vertex AI | Gemini 3 Pro + GLM-5 + DeepSeek, $300 free credit |
The README notes that the free plans for iFlow, Qwen, and Gemini CLI were shut down one after another over the course of 2026; the three above are the current mainstays.
OAuth Auto-Refresh
For OAuth-based subscription services like Claude Code, Codex, GitHub, Cursor, and Antigravity, tokens usually last only a few hours. 9Router refreshes them automatically before they expire, so long sessions don’t get cut off mid-way and force a re-login.
Cross-API Format Translation
Different providers use different native API formats (OpenAI’s and Claude’s messages structures, for instance, aren’t the same). 9Router translates formats automatically as it routes:
Your tool (OpenAI format) → 9Router → each provider's native format
Claude · Gemini · Cursor · Vertex …
Your tool only needs to speak OpenAI format — no need to write a separate adapter for each provider.
Built-in RTK Token Compression
9Router ships with an RTK (Result Token Kit) middleware that targets the contents of tool_result payloads (shell output like git diff, grep, ls, log): it detects the type, filters out redundancy, and only then feeds it to the LLM. The project claims this saves 20–40% of input tokens per request.
Note the naming clash: this RTK is a middleware built into 9Router, and it merely shares an abbreviation with a separate, standalone Rust tool, RTK (Rust Token Killer) — they are not the same thing.
Supported Tools and Deployment
CLI tools: Claude Code, OpenClaw, Codex, OpenCode, Cursor, Antigravity, Cline, Continue, Droid, Roo, Copilot, Kilo Code.
Providers: OAuth-based ones (Claude Code, Antigravity, Codex, GitHub, Cursor) plus 40-some API-key-based ones (OpenRouter, GLM, …).
Deployment: runs on localhost by default; you can also launch from source or via Docker, and some in the community have demonstrated deploying it to Hugging Face Spaces as a free, always-on alternative to a VPS.
Who It’s For, and Who It Isn’t
A good fit: anyone juggling multiple AI subscriptions who wants automatic quota fallback, or who wants to share one AI setup across several machines. Configure once, and all tools funnel through 9Router.
Things to watch: using an unofficial proxy to hook into subscription services is fundamentally a way of working around each vendor’s intended usage, and individual providers carry a risk of bans or ToS violations — you’ll need to weigh that yourself. And if your actual pain point is “shell command output blowing up the context,” that’s a different dimension of the problem, and you can pair this with a dedicated command-output compression tool instead.
References
Answers come from this article only. Click any prompt below or open the chat at the bottom right.
🇺🇸 English
You've subscribed to Claude Pro. Then you bought Cursor. And then your company handed you GitHub Copilot on top of that. So now you're paying for three different pools of AI capacity — and every single one of them manages its quota completely in isolation. When one runs dry, you switch to another by hand. The OAuth tokens expire after a few hours and kick you back to a login screen. And each tool ships its API in a slightly different format. You've paid for plenty of capacity, and yet somehow you keep slamming into rate limits at exactly the moment you need them most.
There's a tool called 9Router that takes a really clever, dead-simple angle on this. It runs an OpenAI-compatible proxy right on your machine. Every AI coding tool you use points its requests at that one proxy, and 9Router automatically routes each request to whichever provider is, at that moment, the cheapest one that still has quota left. It's picked up around eighteen thousand stars on GitHub, it's actively maintained, and it ships as both an npm package and a Docker image.
Let's talk about the core idea, because it's elegant. The traditional setup has every tool configure its own provider and hold its own API key. The moment a provider changes — new key, new endpoint, whatever — you have to go reconfigure every tool, one by one. 9Router pulls that whole layer out of your tools. As long as a tool supports a "custom OpenAI endpoint" — and almost all of them do — you point every one of them at localhost, port twenty-one-twenty-eight. From then on, choosing the provider, switching providers, handling authentication — that's all 9Router's job. Swapping providers becomes 9Router's problem. Your tools get configured exactly once, and you never touch them again.
Installing it is about as simple as it gets: one npm install, run the command, and a dashboard pops open in your browser. Then for each tool — Claude Code, Codex, Cursor, Cline, whatever — you just set the endpoint to that local address, paste in the API key the dashboard gives you, and pick a model. And here's an important detail: your API keys and OAuth tokens are stored only on your own machine. Nothing gets shipped off to some third party.
Now, the heart of the whole system is what they call three-tier fallback. Picture three tiers stacked from cheapest to most expensive. Tier one is your subscription services — Claude Code, Codex, Copilot. The stuff you're already paying a flat monthly fee for, so you want to burn that first. When tier one runs out of quota, 9Router automatically drops down to tier two: the cheap pay-as-you-go APIs, things like GLM at around sixty cents per million tokens, or MiniMax at twenty cents. And if you hit a budget cap there, it falls again to tier three: the genuinely free services. The key word in all of this is automatic. A request comes in, it tries tier one, succeeds, you get your response. Tier one's tapped out? It quietly slides to tier two, and you never notice. If a provider has multiple accounts attached, it'll even round-robin across them. And the dashboard shows you live quota tracking with reset countdowns, so you can actually see where you stand.
On that free tier, three options are holding up well right now. There's Kiro AI, which gives you Claude 4.5 plus GLM-5 plus MiniMax, billed as unlimited free. There's OpenCode Free, which needs no authentication at all and auto-discovers whatever models are available. And there's Vertex AI, which hands you three hundred dollars of free credit to spend on Gemini 3 Pro, GLM-5, and DeepSeek. Worth noting — the README mentions that the free plans for iFlow, Qwen, and the Gemini CLI all got shut down one after another over the course of 2026. So this free landscape shifts. Those three are just the current mainstays.
A couple of the smaller features really tie this together. First, OAuth auto-refresh. For the subscription services that authenticate through OAuth — Claude Code, Codex, GitHub, Cursor, Antigravity — those tokens usually only last a few hours. 9Router refreshes them automatically, before they expire, so a long working session never gets cut off mid-stream and dumps you back at a login prompt.
Second, cross-format translation. Different providers speak different native API dialects — OpenAI's message structure and Claude's message structure, for instance, are just not the same shape. 9Router translates between them on the fly as it routes. So your tool only ever has to speak OpenAI format. You never write a separate adapter for each provider; the proxy handles the conversion.
And third, there's a built-in token compression layer they call RTK, the Result Token Kit. This one targets the contents of tool results — think shell output, the stuff that comes back from a git diff, a grep, an ls, a log dump. It detects what type of output it is, filters out the redundant noise, and only then feeds the trimmed version to the language model. The project claims that saves somewhere between twenty and forty percent of your input tokens per request. Quick heads-up on the name, though — this RTK is a middleware baked into 9Router, and it just happens to share an abbreviation with a totally separate standalone Rust tool also called RTK. Different things.
In terms of reach, it supports basically the whole zoo of CLI tools — Claude Code, Codex, OpenCode, Cursor, Cline, Continue, Copilot, and more. On the provider side, the OAuth ones plus something like forty-odd API-key-based providers. It runs on localhost by default, but you can also launch from source or via Docker — and some folks in the community have even demonstrated deploying it to Hugging Face Spaces as a free, always-on alternative to renting a VPS.
But let's be honest about the catch, because there is one. Using an unofficial proxy to hook into your subscription services is, fundamentally, a way of working around how each vendor intends their product to be used. Individual providers carry a real risk of bans or terms-of-service violations, and that's a tradeoff only you can weigh. And one more honest note: if your actual pain point isn't quota juggling but rather "shell command output is blowing up my context window" — that's a different problem on a different axis, and you might be better served pairing this with a dedicated output-compression tool.
So, three things to take with you. One: 9Router's whole philosophy is to collapse provider management into a single local endpoint — configure your tools once, and let the proxy handle every switch behind the scenes forever. Two: the magic is that three-tier, cheapest-first fallback, plus the quiet machinery around it — auto-refreshing tokens and translating API formats so nothing breaks when it switches. And three: it's genuinely powerful for anyone juggling multiple AI subscriptions, but go in clear-eyed about the terms-of-service gray zone, because that risk is yours to carry.
🇹🇼 中文
你有沒有過這種狀況——訂了 Claude Pro,又買了 Cursor,公司還發了 GitHub Copilot,結果每個服務的額度各管各的。一個用完得手動切到另一個,OAuth token 過幾個小時就過期、又要重登,而且每個工具送出去的 API 格式還不一樣。明明額度買了一大堆,卻常常在你最需要的時候,撞上 rate limit。
9Router 的切入點很單純:在你的本機跑一個 OpenAI 相容的 proxy,把所有 AI coding 工具的請求統一收進來,再自動路由到當下最划算、又還有額度的那個 provider。它在 GitHub 上已經累積到一萬八千顆星,更新很活躍,背後也有對應的 npm 套件跟 Docker image。
先講它的設計哲學。傳統做法是每個工具各自設定 provider、各自塞 API key,provider 一變動,每個工具都得重設一次,很煩。9Router 把這層抽出來:工具端只要支援「自訂 OpenAI endpoint」,你就全部指向本機那個 localhost:20128 的位址,provider 的選擇、切換、認證全部交給 9Router。換句話說,provider 怎麼換都是 9Router 的事,工具本身設定一次到位,之後完全不用再動。
安裝也很簡單,npm 全域裝好、跑起來,dashboard 就開在那個 port。接著把工具的 endpoint 跟 API key 改成 dashboard 給你的值,model 填像是 claude-sonnet-4.5 這種就行。重點是——你的 API key 跟 OAuth token 都只存在本機,不會送到第三方去。
那它核心的機制是什麼?是一個三層的 fallback 路由,照成本由低到高,用完才往下掉。第一層是你已經付錢的訂閱服務,像 Claude Code、Codex、Copilot;這一層額度耗盡,就自動掉到第二層的便宜 API,例如 GLM、MiniMax 這種一百萬 token 才幾毛美金的;萬一連第二層的預算上限都碰到了,再掉到第三層的免費資源。三層之間自動切換,完全不用你手動介入。而且同一個 provider 如果你有多個帳號,它還能 round-robin 輪流分配,dashboard 上即時看得到額度追蹤跟重置倒數。
免費這一層,現在比較可靠的有三個:Kiro AI,標榜 unlimited free,給你 Claude、GLM、MiniMax;OpenCode Free,免認證、自動抓可用模型;還有 Vertex AI,三百美金的免費額度,可以用 Gemini 3 Pro 那一批。要注意的是,README 有特別講,像 iFlow、Qwen、Gemini CLI 那些免費方案,在 2026 年陸續關掉了,現在主力就是這三個。
再來幾個讓它好用的細節。第一是 OAuth 自動刷新。Claude Code、Codex、GitHub、Cursor 這些走 OAuth 的訂閱,token 效期通常只有幾小時,9Router 會在過期前自動幫你刷新,避免你跑一個長 session 跑到一半突然斷線、被踢出去重登。
第二是跨 API 格式轉換。不同 provider 的原生格式不一樣,OpenAI 跟 Claude 的 messages 結構就長得不同。9Router 在路由的時候自動幫你轉,所以工具端只要會講 OpenAI 格式就夠,你不必為每個 provider 各寫一套。
第三個我覺得蠻聰明的,是內建的 RTK token 壓縮。它有一個 middleware,專門針對 tool_result 的內容——就是 git diff、grep、ls、log 這類 shell 輸出——先偵測類型、過濾掉冗餘,再送進 LLM,官方說每次請求可以省下兩成到四成的輸入 token。這裡有個命名要提醒一下:這個 RTK 是 9Router 內建的東西,跟另一個獨立的 Rust 工具、那個也叫 RTK 的,只是縮寫剛好一樣,不是同一個東西,別搞混。
支援的工具很廣,主流的 CLI 像 Claude Code、Codex、Cursor、Cline、Continue、Copilot 都在裡面。Provider 端則是 OAuth 那幾家,加上四十多個 API key 類型的。部署預設跑 localhost,但你也可以從原始碼或 Docker 啟動,社群甚至有人示範部署到 Hugging Face Spaces,當作免費常駐、替代 VPS 的方案。
那最後,誰適合用?如果你同時手上有好幾個 AI 訂閱、想要額度自動 fallback,或是要在好幾台裝置共用同一套 AI 設定,那它很對胃口,設定一次,所有工具統一進 9Router。但有件事一定要自己評估:用非官方的 proxy 去接訂閱服務,本質上就是繞過各家原本的用法,個別 provider 是有封號、或違反服務條款的風險的,這個帳要自己算。另外,如果你真正的痛點其實是「shell 命令輸出把 context 撐爆」,那是另一個維度的問題,可以單獨搭配命令輸出層的壓縮工具來處理。
總結一下三個重點。第一,9Router 的核心價值是「工具只認一個 endpoint」,把 provider 的選擇跟認證全部抽到 proxy 這層,設定一次就不用再動。第二,它的三層 fallback 加上 OAuth 自動刷新、格式自動轉換、還有 RTK 壓 token,解決的是多訂閱時代「額度各管各的、又一直撞牆」的真實痛點。第三,方便歸方便,繞過官方用法的封號跟條款風險是實實在在的,要不要用,自己拿捏。
Tags
Related Articles
RTK: A Rust Tool That Cuts AI Coding Assistant Token Usage by 60–90%
Install one Rust binary, and the output of commands like git/grep/test/docker gets compressed before reaching the AI context — a 30-minute Claude Code session drops from roughly 118,000 tokens to about 23,900.
RAG's Five Stages: From Pipeline to Reasoning Retrieval, and the Naive RAG on My Own Site
Over the past two years RAG evolved from a 'linear pipeline' to 'loop-based reasoning'. It maps cleanly to five stages: Naive, Advanced, Modular, Graph, Agentic. The real inflection point is control moving from pipeline to agent — a System 1 → System 2 shift. Looking back at engineer-news's own RAG stack, it's stuck at the Naive edge — so this post also lays out what to fix next.
Building a Real RAG: 5 Infra Lessons from InfiniFlow's 2024 Year-in-Review
The previous post zoomed out for a five-stage panorama of RAG. This one zooms in on the five infra lessons any real RAG has to face: document ingestion, contextualized chunking, three-lane hybrid search, tensor reranker, and GraphRAG's semantic gap. Each lesson is checked against engineer-news's current stack, ending with a priority list for a personal site.