5-minute setup for AI model routing across Claude Code, Cursor, Codex, Gemini CLI, and more
English | 中文
AI coding tools each have different model providers. Switching between them manually is painful. 9Router gives you a local proxy that routes requests to the right model with fallback chains — configured in 5 minutes.
Use this starter kit when you want one llm proxy and model router for Claude Code, Cursor, Cline, Codex CLI, Gemini CLI, and OpenClaw. It helps with ai coding model switching, quota fallback, cost control, and 多模型路由 without editing every tool by hand.
Common problems it solves:
- Quota exhausted mid-session → automatically fallback to the next available model
- Premium models wasted on low-complexity tasks → route Haiku-style tasks to cheaper models such as GLM
- Manual model switching across tools → use aliases and combo presets instead
- Different endpoint formats → expose a local OpenAI-compatible proxy at
localhost:20128/v1
# Install and configure in one go
./install.sh && ./configure.sh
# Optional: verify the generated routing setup
./verify.shThe interactive setup checks whether 9Router is running, asks which AI coding tools you use, collects provider credentials, writes 9Router providers/aliases/combos through the REST API, generates tool-specific config, and verifies that the local model router works.
- Node.js >= 18
curlandjq(brew install jqon macOS if needed)- At least one model provider API key or Claude OAuth subscription connection
| Tool | Config Generated |
|---|---|
| Claude Code | .claude.json with model routing |
| Cursor | Guide for settings.json |
| Codex CLI | Setup shell script |
| Gemini CLI | .gemini/settings.json |
| Cline | Guide for VS Code settings |
| OpenClaw | Configuration file |
| Combo | Models | Use Case |
|---|---|---|
| full-subscription | All premium models | Power users with API keys |
| hybrid | Mix of free and paid | Cost-conscious developers |
| domestic-only | China-based models (GLM, DeepSeek, Qwen, etc.) | No overseas API needed |
| free-tier | Free models only | Zero-cost setup |
configure.sh matches your selected providers to the closest preset, then writes a fallback chain into 9Router so requests can move from the preferred model to backup providers when quota, network, or provider errors occur.
AI coding tools send OpenAI-compatible requests to localhost:20128/v1. 9Router receives each request, resolves the model field through model aliases, applies combo fallback rules when needed, and forwards the request to the first available provider.
Read docs/architecture.md for data flow and storage schema.
├── install.sh # One-command install for 9Router and pm2 process management
├── configure.sh # Interactive setup for tools, providers, API keys, aliases, and combos
├── verify.sh # Five-stage verification script
├── uninstall.sh # Rollback script
├── config/ # Preset templates
│ ├── combos/ # Four combo presets
│ ├── aliases.json # Default model aliases
│ └── tool-configs/ # Templates for supported tools
├── claude-md/ # CLAUDE.md routing rule snippets
├── output/ # Generated configs, ignored by git
└── docs/
├── architecture.md
└── faq.md
./uninstall.shThis restores previous local tool configuration and stops 9Router-managed processes where applicable.
Install Node.js 18 or newer first. We recommend nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
nvm install 22Run lsof -i :20128. If the process is 9Router, it usually means 9Router is already installed. If another process owns the port, stop that process before installing.
The setup script uses jq to parse API responses and generated JSON. On macOS, install it with brew install jq; on Linux, use your package manager such as apt install jq or yum install jq.
Choose Claude Max subscription / OAuth if available. OAuth can refresh tokens automatically and avoids pay-as-you-go API key billing for supported workflows. Use an API key when you specifically want metered API usage.
Yes, but the main value of 9Router is multi-provider fallback. For reliable ai model routing, we recommend configuring at least two providers.
For low-complexity sub-tasks such as review, testing, and summarization, GLM-5.1 is usually sufficient. Strong reasoning tasks can still route to Opus or Sonnet through aliases and combo rules.
Cursor settings are GUI-based, so they cannot be fully scripted. configure.sh generates output/cursor/guide.md with step-by-step instructions for Cursor Settings → Models.
Use pm2 logs 9router or inspect ~/.9router/logs/.
- 9router-starter-kit — AI model routing in 5 minutes
- awesome-claude-code — Claude Code learning toolkit
- zero2claude — Learn Claude Code from zero
- zero2codex — Learn Codex CLI from zero
- zero2cursor — Learn Cursor IDE from zero
- zero2codewhale — Learn CodeWhale from zero
- ai-coding-skillpacks — 21 AI coding learning paths
Practice AI coding workflows and model routing patterns on AIFlowLearn, a browser-based platform for interactive AI coding courses, labs, and skill packs.
Contributions welcome! Please see the issues tab or submit a PR.
MIT License — Copyright (c) 2026 AIFlowLearn
Sponsored by AIFlowLearn — AI-native learning platform
AIFlowLearn / AI智流学社 — Browser-based AI coding practice environments, interactive courses, and skill packs.