
# 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.**
[](https://www.npmjs.com/package/9router)
[](https://www.npmjs.com/package/9router)
[](https://github.com/decolua/9router/blob/main/LICENSE)

[π Quick Start](#-quick-start) β’ [π‘ Features](#-key-features) β’ [π Setup](#-setup-guide) β’ [π Website](https://9router.com)
[π»π³ TiαΊΏng Viα»t](./i18n/README.vi.md) β’ [π¨π³ δΈζ](./i18n/README.zh-CN.md) β’ [π―π΅ ζ₯ζ¬θͺ](./i18n/README.ja-JP.md)
---
## π€ 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:**
```bash
npm install -g 9router
9router
```
π Dashboard opens at `http://localhost:20128`
**2. Connect a FREE provider (no signup needed):**
Dashboard β Providers β Connect **Kiro AI** (free Claude unlimited) 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.
```bash
cp .env.example .env
npm install
PORT=20128 NEXT_PUBLIC_BASE_URL=http://localhost:20128 npm run dev
```
Production mode:
```bash
npm run build
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
---
## π‘ Key Features
| Feature | What It Does | Why It Matters |
|---------|--------------|----------------|
| π **RTK Token Saver** ([RTK](https://github.com/rtk-ai/rtk) β40K) | Compress tool outputs (`git diff`, `grep`, `ls`, `tree`...) before sending to LLM | Save **20-40% input tokens** per request |
| πͺ¨ **Caveman Mode** ([Caveman](https://github.com/JuliusBrussee/caveman) β52K) | Inject caveman-speak prompt β LLM replies terse, technical substance preserved | Save **up to 65% output tokens** |
| π― **Smart 3-Tier Fallback** | Auto-route: Subscription β Cheap β Free | Never stop coding, zero downtime |
| π **Real-Time Quota Tracking** | Live token count + reset countdown | Maximize subscription value |
| π **Format Translation** | OpenAI β Claude β Gemini β Cursor β Kiro β Vertex | Works with any CLI tool |
| π₯ **Multi-Account Support** | Multiple accounts per provider | Load balancing + redundancy |
| π **Auto Token Refresh** | OAuth tokens refresh automatically | No manual re-login needed |
| π¨ **Custom Combos** | Create unlimited model combinations | Tailor fallback to your needs |
| π **Request Logging** | Debug mode with full request/response logs | Troubleshoot issues easily |
| πΎ **Cloud Sync** | Sync config across devices | Same setup everywhere |
| π **Usage Analytics** | Track tokens, cost, trends over time | Optimize spending |
| π **Deploy Anywhere** | Localhost, VPS, Docker, Cloudflare Workers | Flexible deployment options |