Integrations
Claude Code Router with Plan2API
Claude Code Router (CCR) v3.1.3 is a free, MIT-licensed local gateway on port 3456 that lets Claude Code use models from other providers. Add Plan2API in CCR as a custom provider with the endpoint https://api.plan2api.com/v1 and your p2a_ key, and Claude Code runs Claude, GPT-6, Gemini and Kimi models from your subscriptions.
- CCR gateway
- 127.0.0.1:3456
- API endpoint
- api.plan2api.com/
v1 - Protocol
- OpenAI Chat Completions
- CCR license
- MIT, v3.1.3
Updated
Settings at a glance
These are the values you'll enter in CCR's Add Provider dialog and your Claude Code profile.
| Setting | Value |
|---|---|
| Provider preset | Other / |
| Name | Plan2API |
| API endpoint | https:// |
| API key | Your p2a_ |
| Protocol | OpenAI Chat Completions, detected by CCR |
| Claude model | claude/ |
| GPT model | openai/ |
| Gemini model | gemini/ |
| Kimi model | kimi/ |
| CCR ports | Gateway 3456, management UI 3458 |
Set up CCR with Plan2API
- Sign in with a Google account at plan2api.com/connect, connect a Claude Pro or Max, ChatGPT, Google AI Pro or Ultra, or Kimi Code subscription, and copy your
p2a_API key. - Install the Claude Code Router CLI with
npm install -g @musistudio/claude-code-routeron Node.js 22 or later. - Run
ccr uito start the background service onhttp://127.0.0.1:3456and open the management UI in your browser athttp://127.0.0.1:3458(or useccr ui --no-openon a headless machine). - Open Providers, click Add Provider, pick
Other / custom API endpoint, enterPlan2APIas the Name,https://api.plan2api.com/v1as the API endpoint and yourp2a_key, select the models you want to expose, and run Check Connection on one model since each test sends a real request that counts against your request limits. - Go to Agent Config, add a Claude Code profile, set its Config name (for example
Claude Code Work), and pickPlan2APIandclaude/claude-opus-5-5as its Model. - Launch Claude Code through the profile with
ccr "Claude Code Work". If you use the CCR Desktop app instead of the npm CLI, the terminal button on the profile card copiesccr-app "Claude Code Work"for the CLI, and the play button opens Claude App. - Run
/modelinside Claude Code to verify the available models and check CCR's Request logs to see your requests come through.
# Install Claude Code Router (Node.js 22+)
npm install -g @musistudio/claude-code-router
# Open the management UI at http://127.0.0.1:3458
ccr ui
# Start Claude Code through your CCR profile
ccr "Claude Code Work"Map Claude Code's model tiers
Your profile's Model setting is the default, while the optional Fable, Opus, Sonnet and Haiku overrides decide which Plan2API model actually answers when Claude Code asks for one of those tiers. Putting GPT, Gemini or Kimi models on some of those tiers spreads the work across your connected Claude and ChatGPT subscriptions instead of burning through one plan's quota. Every model ID you assign to a tier also needs to be checked in your Plan2API provider's Models list in CCR, or CCR won't route to it.
| Claude Code slot | Plan2API model | Context window |
|---|---|---|
| Default model | claude/ | 1M tokens |
| Opus tier | claude/ | 1M tokens |
| Sonnet tier | claude/ | 1M tokens |
| Haiku tier | claude/ | 200K tokens |
| Fable tier | claude/ | 1M tokens |
| GPT instead | openai/ | 500K default in Codex |
| Gemini instead | gemini/ | 1,048,576 tokens |
| Kimi instead | kimi/ | 1,048,576 tokens |
What works and what doesn't
- Streaming, tool and function calling, and
reasoning_effort(orreasoning.effort) pass through Plan2API on all four providers. - Image input works on Claude, Gemini and Kimi models, plus Codex models that accept images, with up to 32 image URLs per request at up to 20 MB each.
- CCR has to connect to Plan2API using the OpenAI Chat Completions protocol at
POST /v1/chat/completions, because Plan2API doesn't serve the Anthropic/v1/messagesor OpenAI/v1/responsesendpoints. - JSON mode (
response_formatset tojson_objectorjson_schema) works on Codex, Kimi and Gemini models, but returns HTTP400unsupported_parameteron Claude models. - Anthropic doesn't support running Claude Code against non-Claude models through a gateway, so routing to other models is an unofficial setup.
- Every tool-call round trip counts as a separate request against your Claude usage limits and your Plan2API plan, so the Free plan's 50 chat requests a day (resetting at 00:00 UTC) is fine for a quick test, not a full workday.
Troubleshooting
The table below covers the most common errors from CCR and Plan2API and how to fix them.
Test your p2a_ key outside CCR first with the curl command below; if it works there, the problem is in CCR's provider, routing or profile settings.
| Error | Cause | Fix |
|---|---|---|
| 401 invalid_ | Key missing, mistyped or revoked | Paste the full p2a_ |
| 403 no_ | No plan connected for that model's provider | Connect the plan at plan2api.com/ |
| 400 model_ | Model id not available on your account | Use an id returned by GET / |
| 400 unsupported_ | JSON mode sent to a Claude model | Use a GPT, Gemini or Kimi model for JSON |
| 429 subscription_ | Every connected account is out of quota | Wait for Retry-After or add a fallback |
| Model not found in CCR | Model differs between provider, routing, profile | Select the same id in all three |
curl https://api.plan2api.com/v1/models \
-H "Authorization: Bearer p2a_your_key"Where CCR v3 keeps its config
If you're looking for a claude code router config file to edit by hand, CCR v3 doesn't use config.json anymore. Providers, agent profiles and routing rules live in a SQLite database at ~/.claude-code-router/config.sqlite (%APPDATA%\claude-code-router\config.sqlite on Windows, /data/.claude-code-router/config.sqlite in Docker), and CCR reads a legacy config.json only once to migrate old settings.
Older guides that tell you to edit Providers, api_base_url and transformers blocks in JSON are describing the pre-v3 format. In v3, you put the endpoint, key and model list into the Providers page in the UI at http://127.0.0.1:3458, and configure first-match routing rules, fallbacks and per-key credential pool limits like {"rpm": 60, "tpm": 100000} right in the browser.
Use the AI subscriptions you already pay for as one OpenAI-compatible API key.
- Free: 1 subscription, 50 requests a day, no card
- Pro: $12 a month
FAQ
What is Claude Code Router?
Claude Code Router (CCR) is a free, MIT-licensed local gateway (currently v3.1.3) that lets Claude Code and other coding agents use models from other providers. It runs locally as a desktop app or npm CLI and listens for requests on http://127.0.0.1:3456, with a management UI on http://127.0.0.1:3458.
Does Claude Code Router still use config.json?
No. CCR v3 stores its configuration in a SQLite database at ~/.claude-code-router/config.sqlite and only reads an old config.json file once as a migration source. You manage providers, profiles and routing through ccr ui instead of editing a file.
Can Claude Code use GPT-6 or Gemini models?
Through CCR, yes: pick a model like openai/gpt-6.1-sol or gemini/gemini-4-argon-high from your Plan2API provider in the Claude Code profile or its tier overrides. Anthropic does not officially support using Claude Code with non-Claude models.
Do I need an Anthropic API key?
No. CCR sends Claude Code's requests to Plan2API using your p2a_ key in an Authorization: Bearer header, and Plan2API runs them through the subscriptions you already pay for, like Claude Pro or Max or a ChatGPT plan, without billing per token.
Which Plan2API plan do I need?
The Free plan ($0, no card needed) works for testing your claude code router setup with 1 connected subscription and 50 chat requests a day. For daily coding, Pro at $12 a month ($99 a year) removes the daily request cap, connects up to 3 subscriptions, and allows 10 requests per second with up to 16 requests at once.
Sources
- Claude Code Router on GitHubgithub.com
- CCR CLI guideccrdesk.top
- CCR provider configccrdesk.top
- CCR Claude Code agentccrdesk.top
- CCR config database locationccrdesk.top
- CCR troubleshootingccrdesk.top
- Claude Code LLM gateway docscode.claude.com
- Claude Code Router on npmregistry.npmjs.org