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.

CCR provider settings for Plan2API
SettingValue
Provider presetOther / custom API endpoint
NamePlan2API
API endpointhttps://api.plan2api.com/v1
API keyYour p2a_ key
ProtocolOpenAI Chat Completions, detected by CCR
Claude modelclaude/claude-opus-5-5
GPT modelopenai/gpt-6.1-sol
Gemini modelgemini/gemini-4-argon-high
Kimi modelkimi/k3
CCR portsGateway 3456, management UI 3458

Set up CCR with Plan2API

  1. 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.
  2. Install the Claude Code Router CLI with npm install -g @musistudio/claude-code-router on Node.js 22 or later.
  3. Run ccr ui to start the background service on http://127.0.0.1:3456 and open the management UI in your browser at http://127.0.0.1:3458 (or use ccr ui --no-open on a headless machine).
  4. Open Providers, click Add Provider, pick Other / custom API endpoint, enter Plan2API as the Name, https://api.plan2api.com/v1 as the API endpoint and your p2a_ 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.
  5. Go to Agent Config, add a Claude Code profile, set its Config name (for example Claude Code Work), and pick Plan2API and claude/claude-opus-5-5 as its Model.
  6. 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 copies ccr-app "Claude Code Work" for the CLI, and the play button opens Claude App.
  7. Run /model inside Claude Code to verify the available models and check CCR's Request logs to see your requests come through.
Shell
# 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.

Suggested tier mapping
Claude Code slotPlan2API modelContext window
Default modelclaude/claude-opus-5-51M tokens
Opus tierclaude/claude-opus-5-51M tokens
Sonnet tierclaude/claude-sonnet-51M tokens
Haiku tierclaude/claude-haiku-4-5200K tokens
Fable tierclaude/claude-fable-5-11M tokens
GPT insteadopenai/gpt-6.1-sol500K default in Codex
Gemini insteadgemini/gemini-4-argon-high1,048,576 tokens
Kimi insteadkimi/k31,048,576 tokens

What works and what doesn't

  • Streaming, tool and function calling, and reasoning_effort (or reasoning.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/messages or OpenAI /v1/responses endpoints.
  • JSON mode (response_format set to json_object or json_schema) works on Codex, Kimi and Gemini models, but returns HTTP 400 unsupported_parameter on 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.

Common errors
ErrorCauseFix
401 invalid_api_keyKey missing, mistyped or revokedPaste the full p2a_ key into the provider
403 no_credentialsNo plan connected for that model's providerConnect the plan at plan2api.com/connect
400 model_not_foundModel id not available on your accountUse an id returned by GET /v1/models
400 unsupported_parameterJSON mode sent to a Claude modelUse a GPT, Gemini or Kimi model for JSON
429 subscription_quota_exhaustedEvery connected account is out of quotaWait for Retry-After or add a fallback
Model not found in CCRModel differs between provider, routing, profileSelect the same id in all three
curl
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

  1. Claude Code Router on GitHubgithub.com
  2. CCR CLI guideccrdesk.top
  3. CCR provider configccrdesk.top
  4. CCR Claude Code agentccrdesk.top
  5. CCR config database locationccrdesk.top
  6. CCR troubleshootingccrdesk.top
  7. Claude Code LLM gateway docscode.claude.com
  8. Claude Code Router on npmregistry.npmjs.org