luqman-v1/9router-go
9router-go is a single-binary Go port of 9Router, an LLM gateway that sits between CLI coding tools (Claude Code, Cursor, Codex, Cline, OpenClaw, Gemini CLI, OpenCode) and 40+ AI providers/100+ models. It adds RTK token compression (claimed 20-40% token savings on tool_result content), tiered auto-fallback (subscription → cheap → free providers), multi-account round-robin, per-key proxy pools, and an embedded Svelte dashboard backed by SQLite, with database compatibility to share state with the original Next.js 9Router. It targets the practical problem of coding-agent subscription quota exhaustion and token cost, not a research contribution.
What it claims
The repository presents one Go binary that serves the gateway APIs and the dashboard, with no Node.js runtime. The tiers it names are:
- Subscription: Claude Code, Codex, GitHub Copilot.
- Cheap: GLM at $0.6/1M, MiniMax at $0.2/1M.
- Free: Kiro at about 50 credits/month, OpenCode Free with no auth, Vertex with $300 credits.
Beyond the summary, it adds per-combo routing strategies: fallback, round-robin, sticky, capacity, fusion, and capability-aware reordering. It also adds custom headers for compatible providers, arbitrary usage windows such as 14d or 12h, and a per-request payload inspector. It tracks upstream decolua/9router v0.5.85 at Go v1.9.9.
How to use it
# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/luqman-v1/9router-go/main/install.sh | bash# Windows (PowerShell, no admin needed)
irm https://raw.githubusercontent.com/luqman-v1/9router-go/main/install.ps1 | iexdocker run -d --name 9router-go --restart unless-stopped \
-p 20130:20130 -v "$HOME/.9router:/data" \
-e PORT=20130 -e DATA_DIR=/data \
-e INITIAL_PASSWORD=your-secure-password \
luqmenul/9router-go:latestDefaults and configuration
- It listens on port 20130 and stores data in
~/.9router. - Configuration is by environment variable only:
PORT,DATA_DIR,DB_PATH,HOST,INITIAL_PASSWORD. There are no--portflags. - Daemon commands are
start,status,restart,logs -n 100andstop. - Point clients at
http://localhost:20130/v1with a dashboard-issued API key. For Claude clients, setANTHROPIC_BASE_URL=http://localhost:20130/v1. - Models are namespaced by provider prefix, for example
kr/claude-sonnet-4.5andag/gemini-3.8-flash-high.
API surface
- Chat:
/v1/chat/completions,/v1/messages,/v1/responses, and Ollama-style/api/chat. - Other generation endpoints:
/v1/embeddings, image, video, TTS, STT and/v1/search. - Monitoring: SSE
/api/usage/stream. - Proxy routes take
Authorization: BearerorX-API-Key.
Migrating from 9Router
- Point 9router-go at the same
DATA_DIR. There is no import step. - Both projects can run at once on different ports, for example 20128 and 20130. The supported setup is one active writer.
- 9router-go adds
lastUsedAtandconsecutiveUseCounttoproviderConnectionsand adds anupstream_leasestable. Upstream ignores both. - Back up first with
cp -r ~/.9router/db ~/9router-db-backup, with the daemon stopped.
Building from source
- Requires Go 1.27 and Bun 1.x.
- Run
make web-build, thenmake build. - Releases come with
SHA256SUMS.txt. - Experimental builds are tagged
exp. They are neverlatest, and9router-go updatewon't install them.
The licence is MIT, with portions derived from 9Router (MIT).
Limits
Security
- The default dashboard password is
123456. - The API server binds all interfaces by default.
- Remote access blocks the default password, citing CVE-2026-56679. On a VPS, LAN or Docker host, set
INITIAL_PASSWORDor use SSH port-forwarding. - Otherwise, bind
HOST=127.0.0.1or firewall the port.
Database
- It will not import legacy 9Router JSON exports. Run upstream once to convert them first.
- It does not interpret
_meta.schemaVersion. A database written by a much newer 9Router should be checked before relying on it. - Running both projects against one database is safe only with a single writer at a time. Avoid editing the same combo or setting in both dashboards at once.
Windows
stopuses TerminateProcess, so in-flight streams aren't drained.- Use
restartor the dashboard's Shutdown button for a graceful stop.
Unverified claims
- The 20-40% RTK token saving comes with no benchmark, workload or baseline.
- The free-tier credit figures and provider prices are the README's own and may change.
Organisations named here
- Cursor
- MiniMax
- Cline
- decolua
CVEs named here
- CVE-2026-56679
Technologies named here
- Go
- OAuth
- 9router-go
- Claude Sonnet 4.5
- 9Router
- Gemini 3.8 Flash
- GLM
- Claude Code
- Cursor
- MiniMax
- Antigravity
- Codex
- OpenCode
- Cline
- OpenClaw
- GitHub Copilot
- Kiro AI
- OpenCode Free
- Vertex
- Docker
- SQLite
- Node.js
- Bun
- Google Antigravity
- Gemini
- Kiro
Techniques named here
- RTK Token Saver
- Auto fallback
- Combo routing strategies
- Multi-account round-robin
- Proxy per API key
- Additive schema bootstrap
Related in ai-infra
kerpopule/hermes-jev-skills
Wire It, Run It, Deploy It: AI Workflows in Gradio
