cc-switch Integration

Use TheRouter as the routing layer behind multiple local coding clients without editing each config by hand.

cc-switch is useful when your team switches between Claude Code, Codex, Gemini CLI, OpenCode, and OpenClaw and wants one desktop control plane for provider presets. TheRouter works well here because one tenant key can drive all of those clients while keeping routing, failover, and billing in one place.

When this guide is the right one
Use this path when you manage multiple local coding clients or want a safer preset-driven workflow. If you only need one tool, the dedicated Cursor or Claude Code guide is usually faster.

1. Create a routing key in TheRouter

Create a tenant API key in the dashboard first. This is the key you will paste into cc-switch. Do not use a management key.

text
Dashboard → API Keys
Create Key
Copy the raw tenant key immediately

Expected format: sk-...

2. Pick the target client inside cc-switch

In cc-switch, choose the app you actually want to drive with TheRouter. TheRouter presets are most useful for these targets:

text
Claude Code  → Anthropic-compatible TheRouter path
Codex        → OpenAI-compatible TheRouter path
Gemini CLI   → Gemini-native TheRouter path
OpenCode     → OpenAI-compatible TheRouter path
OpenClaw     → OpenAI-compatible TheRouter path

3. Add the TheRouter preset

Open Add Provider, search for TheRouter, paste the key, then enable the preset. If you do not see the preset, update cc-switch to a build that includes the latest provider presets.

text
cc-switch → target app → Add Provider
Search: TheRouter
Paste: sk-...
Enable the preset
Restart the target CLI if required

4. Know which base URL style you are using

cc-switch hides the file editing, but the protocol rules still matter. TheRouter uses different base URL styles depending on the client protocol.

text
Claude Code preset:
  base URL = https://api.therouter.ai

Codex / OpenCode / OpenClaw preset:
  base URL = https://api.therouter.ai/v1

Gemini CLI preset:
  base URL = https://api.therouter.ai

5. Validate the path before deeper debugging

Confirm the key and model aliases are live before debugging the desktop app itself.

bash
curl https://api.therouter.ai/v1/models \
  -H "Authorization: Bearer $THEROUTER_API_KEY" | head -c 400

Then restart the target CLI and run its smallest possible request or status check.

Common mistakes

text
1. Using a management key instead of a tenant routing key
2. Mixing OpenAI-compatible and Anthropic-native base URLs
3. Expecting old cached model IDs to work after switching providers
4. Forgetting to restart the target CLI after enabling a new preset
5. Assuming cc-switch fixes the wrong model alias automatically
cc-switch does not remove protocol boundaries
cc-switch simplifies config management, but it does not make every client speak the same API protocol. Claude Code, Gemini CLI, and OpenAI-compatible tools still need the right TheRouter preset for their native request shape.

Related setup paths

Open the adjacent guide when you want the exact client-level steps instead of the switcher workflow.