Self-host 9Router
v0.5.35AI gateway routing coding CLIs to 60+ LLM providers
docker run -d --name 9router -p 20128:20128 -v "$HOME/.9router:/app/data" -e DATA_DIR=/app/data decolua/9router:latest- Stars
- 32 505
- Port
- 20128 (Web dashboard and the OpenAI-compatible /v1 API)
decolua/9routerWhat is 9Router?
9Router is an MIT-licensed gateway that sits between coding tools such as Claude Code, Codex, Cursor, Cline, OpenClaw, Continue and Roo and a large catalog of model providers, exposing a single OpenAI-compatible API on your own machine. Requests follow user-built combos that step down automatically from subscription accounts to cheap providers and then to free ones, so an exhausted quota does not halt a session. It compresses tool output (git diff, grep, directory listings) before the request leaves, appends terseness prompts to shrink replies, tracks per-provider quota and token usage, balances several accounts per provider, refreshes upstream OAuth tokens by itself, and rewrites payloads between OpenAI, Anthropic, Gemini, Kiro, Vertex and other shapes. Chat is only one of nine service kinds: embeddings, speech synthesis and recognition, image and video generation, web search and page fetching are routed too, and self-hosted speech or embedding servers can be fronted. Run it with a global npm install, with the published amd64/arm64 container image plus a data volume for the embedded SQLite state, or from source on a VPS behind PM2. Worth knowing before you rely on it: upstream free tiers come and go (the docs note several that were discontinued during 2026), and the money figures in the dashboard are savings estimates rather than bills.
9Router alternatives
GPTPortalGPTPortal is a self-hosted, open-source Node.js web app providing a unified chat interface for multiple LLM providers and local endpoints like Ollama.CompareGPTPortal with 9Router
FreeLLMAPI7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.CompareFreeLLMAPI with 9Router
Should you self-host 9Router?
9Router scores 68/100 on selfhost.directory (how scoring works) and ranks #3 of 7 in LLM Integration. It has 32 505 GitHub stars, +1 375 in the last 30 days.
There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.
Setup is easy: most people get it running in one sitting. An official Docker image is available. It is MIT-licensed and written mostly in JavaScript.
Its closest alternative on selfhost.directory is private-gpt (80/100, 57 639 stars). It scores higher overall, so compare the two before you pick. See 9Router vs private-gpt side by side.
Features
- Automatic OAuth token refresh
- Automatic provider fallback
- Cloud sync of configuration
- Cross-provider format translation
- Custom model combos
- Input token compression
- MITM bridge for IDE subscriptionsProject notes each tool's own policy must be respected.
- Multi-account load balancing
- Multimodal endpoint routing
- OpenAI Compatible API
- Outbound proxy support
- Output token saving prompts
- Quota and usage tracking
- Request logging
- Web Dashboard
9Router README
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
🇧🇷 Português (Brasil) • 🇻🇳 Tiếng Việt • 🇨🇳 中文 • 🇯🇵 日本語 • 🇷🇺 Русский • 🇹🇭 ไทย • 🇮🇷 فارسی • 🇮🇩 Indonesia • 🇪🇸 Español • 🇫🇷 Français
FAQ
What if my usage suddenly spikes?
Fallback cascades from subscription to cheap to free as limits are hit, and you can set spending caps per provider in the dashboard.
How do I minimize my actual AI costs?
Begin with a combo made only of free-tier models, add a cheap pay-per-token provider as backup if you need headroom, and use paid subscriptions last.
Are FREE providers really unlimited?
Mostly, but each free offering is capped by its vendor, and some former free tiers (iFlow, Qwen Code, Gemini CLI) have been withdrawn, so availability shifts over time.
Will I be charged by 9Router?
No. The router is free software running locally with no billing system; subscription and pay-per-token charges go straight to the providers.
Why does my dashboard show high costs?
The dashboard prices your usage as if the same tokens had gone through paid APIs; it is a savings comparison, not an invoice.
More in LLM Integration
aci-devACI.dev is an open-source tool-calling platform you self-host as a backend and dev portal, wiring 600+ SaaS integrations into AI agents via function calls or unified MCP.
agentgatewayOpen-source, self-hosted HTTP and gRPC gateway routing LLM, MCP, A2A and service traffic in one binary, with auth, policy, guardrails, cost controls and observability.
anakinSelf-hosted open-source web scraping API turning pages into clean markdown or JSON, with an anti-detect Camoufox browser, proxy auto-selection and a web dashboard.
AxeOpen-source, self-hosted CLI that runs focused AI agents defined in TOML files, triggered from pipes, cron, or git hooks, with local Ollama or cloud LLM providers.
Basic MemoryAI conversations that actually remember. Never re-explain your project to your AI again. Join our Discord: https://discord.gg/tyvKNccgqN
Big-AGISelf-hosted, open-source AI workspace for experts: run 2 to 24 models in parallel with Beam, personas, image generation, voice and BYO API keys via Docker.
BricksLLMOpen-source Go AI gateway that meters LLM traffic with per-key rate limits, spend caps, and PII masking, covering OpenAI-style APIs, Anthropic, Azure and vLLM.
chatbot-uiOpen-source AI chat app you self-host with a Supabase backend, supporting OpenAI, Anthropic, Gemini, Mistral and Azure keys plus local Ollama models.
chat-uiA self-hosted, open-source chat interface for LLMs that talks to any OpenAI-compatible API (Ollama, llama.cpp, OpenRouter) with MCP tool calling and model routing.
DesktopCommanderMCPOpen-source, self-hosted MCP server that gives Claude, ChatGPT and other AI clients terminal, file and process control on your own machine.
Evo AIOpen-source, self-hosted workbench for building AI agents: LLM, A2A, sequential, parallel, task and LangGraph workflow types with MCP tools and encrypted API keys.
FalkorDBA super fast Graph Database uses GraphBLAS under the hood for its sparse adjacency matrix graph representation. Our goal is to provide the best Knowledge Graph for LLM (GraphRAG).
0 comments