9router: How to Install and Set Up 2026 Guide

🟢 Beginner–Intermediate   ⚙️ Type: AI Proxy / API Gateway   💸 Free & Open Source (MIT)   ⭐ 18,000+ GitHub Stars


What is 9router?

9router is an incredibly popular open-source, universal AI proxy and token-saver created by developer decolua. It acts as a central “traffic cop” for all your AI coding assistants—such as Claude Code, Cursor, Codex, Cline, and Copilot. Instead of pasting your individual API keys directly into your coding tools, you point all your tools to the local 9router endpoint.

Why add a middleman? Because 9router is designed to aggressively save you money and prevent your coding sessions from stalling. It intercepts the requests your coding tools make and applies heavy optimizations before sending them to the AI provider. It translates formats on the fly (e.g., translating an OpenAI-formatted request into an Anthropic one), tracks your quotas in real-time, and seamlessly load-balances across over 40 different AI providers.


Who is it for?

  • Developers using multiple AI tools who are tired of manually copying and pasting API keys between Cursor, Claude Code, and their terminal environments.
  • Power Users hitting Rate Limits who frequently exhaust their monthly subscription quotas and need a system that automatically falls back to secondary accounts or free tiers without interrupting their workflow.
  • Cost-Conscious Engineers who want to actively slash their token usage. Command-line AI agents often waste thousands of tokens reading massive git diff outputs; 9router compresses this automatically.
  • Teams managing AI spend who want a unified local dashboard to monitor exactly how many tokens are being burned per model, per day.

What makes it special?

  • RTK Token Saver — When your terminal agent runs a command like ls or git diff, the output is often massive. 9router automatically intercepts and compresses these tool_result payloads, saving you 20% to 40% on input tokens per request.
  • Caveman Mode — If you are just trying to get code written and don’t need polite explanations, turning on “Caveman Mode” injects a system prompt that forces the LLM to reply with terse, bare-bones technical substance. This saves up to 65% on output tokens.
  • Smart 3-Tier Fallback — You configure it to try your main subscription first. If you hit a 429 Rate Limit, it instantly reroutes the request to a cheaper pay-as-you-go API, and if that fails, it routes to a 100% free provider (like Kiro AI or OpenCode Free). You never experience downtime.
  • Seamless Format Translation — Your CLI tool might only support OpenAI-style endpoints, but 9router can receive that request and translate it flawlessly into Gemini, Claude, or Ollama API formats in the background.

Requirements before you start

9router is exceptionally lightweight and can run locally on your machine alongside your coding tools:

  • Node.js and npm — Required to install the application globally via the command line.
  • An AI Coding Assistant — Any tool that allows you to specify a custom OpenAI-compatible Base URL (e.g., Cursor, Claude Code, Cline, Windsurf).
  • Your API Keys — You will need the API keys for the paid subscriptions you intend to use (e.g., Anthropic, OpenAI), though you can start immediately using the built-in free provider routes.

Step-by-step installation

Step 1 — Install the Proxy Globally

Open your terminal and use npm to install the 9router package globally on your machine:

npm install -g 9router

Step 2 — Launch the Dashboard

Start the router by simply typing its name in the terminal:

9router

This will spin up the local server and automatically open the 9router web dashboard in your browser at http://localhost:20128.


Step 3 — Connect Your Providers

In the dashboard, navigate to the Providers tab. Here, you can paste in your API keys for OpenAI or Anthropic. If you want to use free models, click “Connect Kiro AI” or “OpenCode Free”—these require no signup and provide instant access to free model tiers.


Step 4 — Point Your Tools to 9router

Now, open your favorite AI coding tool (like Cursor or Claude Code) and go to its API settings. Change the default API endpoint to your local 9router address:

  • Base URL / Endpoint: http://localhost:20128/v1
  • API Key: Copy the unique key provided to you on the 9router dashboard homepage.
  • Model Name: Select the model combo you created in the dashboard (e.g., kr/claude-sonnet-4.5).

That’s it! Your tool will now route all traffic through 9router, automatically compressing tokens and failing over to free tiers when necessary.


Common errors and fixes

ErrorWhat it meansHow to fix it
Connection Refused (Port 20128)Your coding assistant is trying to send a request, but the 9router background process is not running.You must have a terminal window open running the 9router command while you code, or you can set it up to run as a background daemon/Docker container so it is always on.
The AI responses are weirdly short and lack explanationYou have “Caveman Mode” toggled on in the 9router dashboard, which intentionally strips out conversational pleasantries and explanatory text to save output tokens.If you prefer detailed, step-by-step educational responses from your AI, disable Caveman Mode in the settings dashboard.
Unsupported Tool Call / Format ErrorYour coding tool tried to use a complex feature (like computer use or specific MCP tool calling) that isn’t fully mapped to the fallback provider you are currently routed to.Not all free fallback models support advanced tool calling. Ensure your fallback routing logic is set to drop down to a model with similar capabilities (e.g., falling back from Claude 3.5 Sonnet to GPT-4o, rather than a basic open-source model).

Free vs Paid comparison

Feature9router (Local Open Source)Enterprise API Gateways (e.g., Portkey / Helicone)
Software Cost$0 (Free MIT License)Free tiers available, enterprise plans $50+/mo
Target Audience🟢 Individual developers & coding agents🏢 Production SaaS applications
Coding Specific Optimizations✅ Yes (RTK token compression for terminal outputs)❌ No (Generic API load balancers)
Data Privacy✅ 100% Local (Keys stay on your machine)⚠️ Prompts route through external cloud servers

Bottom line: 9router is an essential utility for anyone who spends heavily on AI API tokens or uses terminal-based coding agents daily. The ability to automatically compress massive log files before they hit the LLM (via RTK) will noticeably reduce your API bills. Furthermore, the peace of mind that comes from the 3-Tier Fallback system—knowing your coding session won’t abruptly end just because Anthropic threw a rate limit—makes this a must-install tool for your developer environment.


Alternatives — 3 similar tools

1. LiteLLM

The industry standard for open-source AI proxying. LiteLLM acts as an I/O translation layer, allowing you to call over 100 different LLM APIs using the exact same OpenAI format. It is significantly more mature and enterprise-ready than 9router, but it lacks the aggressive, developer-focused token compression features (like Caveman mode) that make 9router special.

🔗 github.com/BerriAI/litellm

2. OmniRoute

A highly popular alternative gateway explicitly designed around the same pain points as 9router. OmniRoute focuses heavily on aggregating massive amounts of “free tier” models from around the internet, providing one endpoint to access hundreds of providers. It also features stacked token compression and smart auto-fallback specifically tuned for tools like Cursor and Cline.

🔗 github.com/diegosouzapw/OmniRoute

3. Portkey

If you are building an actual AI startup or production application rather than just organizing your local development tools, Portkey is the premium choice. It handles load balancing, automatic retries, strict security guardrails, and deep observability analytics across all your deployed LLM calls.

🔗 portkey.ai


🚀 Want more free AI tools like this?

We find, test, and write setup guides for the best free and open-source AI tools — so you don’t have to dig through GitHub yourself.Browse Free AI Tools at globalaiforce.com/shop →


📸 Follow us for daily AI tool tips and tutorials: instagram.com/globalaiforce

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top