Agents & CLIs
Claude Code
Run Claude Code through RouterPlex with claude-code-router.
Claude Code speaks Anthropic's native Messages API, which RouterPlex doesn't expose — so it can't point at us directly. The bridge is Claude Code Router (CCR): it runs a local gateway that translates Claude Code's requests to the OpenAI format and routes each request role to the model you choose.
Works on macOS, Linux, and Windows.
Option A — CCR desktop app (recommended) #
- Install. Download the installer for your OS from the CCR releases page (macOS
.dmg, Windows installer, Linux package), and install Claude Code itself if you haven't:
npm install -g @anthropic-ai/claude-code
- Add RouterPlex as a provider. In CCR open Providers → Add Provider → Other / custom API endpoint and fill in:
Name: routerplexBase URL: https://api.routerplex.com/v1Protocol: OpenAI compatible (chat/completions)API Key: sk-... # your RouterPlex keyModels: claude-opus-4-8, claude-sonnet-4-6, claude-haiku-4-5, gemini-3.1-pro
Run the connectivity check if offered, then save.
- Map routing roles. In the routing settings, assign a model per role:
| Role | Used for | Suggested model |
|---|---|---|
default | normal turns | claude-sonnet-4-6 |
think | extended reasoning | claude-opus-4-8 |
background | cheap housekeeping calls | claude-haiku-4-5 |
longContext | requests above the token threshold | gemini-3.1-pro (1M context) |
- Start the gateway. Open Server → Start — CCR listens on
http://localhost:8080.
- Point Claude Code at it. The cross-platform way is Claude Code's own settings file — create
~/.claude/settings.json(Windows:%USERPROFILE%\.claude\settings.json):
{"env": {"ANTHROPIC_BASE_URL": "http://localhost:8080","ANTHROPIC_AUTH_TOKEN": "ccr"}}
Or per shell session — macOS/Linux:
export ANTHROPIC_BASE_URL=http://localhost:8080export ANTHROPIC_AUTH_TOKEN=ccr # any value, unless you set an API key in CCRclaude
Windows (PowerShell):
$env:ANTHROPIC_BASE_URL = "http://localhost:8080"$env:ANTHROPIC_AUTH_TOKEN = "ccr"claude
Run /status inside Claude Code to confirm it's talking to the router.
Option B — classic CLI (headless / servers) #
The npm CLI still works and needs no GUI. Install both:
npm install -g @anthropic-ai/claude-code @musistudio/claude-code-router
Configure RouterPlex in ~/.claude-code-router/config.json (Windows: %USERPROFILE%\.claude-code-router\config.json):
{"Providers": [{"name": "routerplex","api_base_url": "https://api.routerplex.com/v1/chat/completions","api_key": "sk-...","models": ["claude-opus-4-8", "claude-sonnet-4-6", "claude-haiku-4-5", "gemini-3.1-pro"]}],"Router": {"default": "routerplex,claude-sonnet-4-6","think": "routerplex,claude-opus-4-8","background": "routerplex,claude-haiku-4-5","longContext": "routerplex,gemini-3.1-pro","longContextThreshold": 60000}}
Then start Claude Code through the router (it sets the env vars for you):
ccr code
Switch models inside a session with /model routerplex,claude-opus-4-8.
Tip: give the router its own key with a budget — coding agents can burn tokens fast.