Skip to content

Integration guide

Claude Code Router (ccr) config.json Setup & Multi-Model Routing

Note: ProxyStacks Relay already speaks native /anthropic for direct Claude Code connections without any local proxy. Use musistudio/claude-code-router (ccr) when you want automatic per-turn routing across default, background, think, and longContext (>120K tokens) slots on one Relay API key.

Setup

  1. 1

    Install Claude Code Router (`npm install -g @musistudio/claude-code-router`) and create an API key (sk-relay-...) in the ProxyStacks Relay console.

  2. 2

    Save ~/.claude-code-router/config.json (or open `ccr ui`). Set Providers[].api_base_url to the FULL path "https://proxystacks.com/v1/chat/completions" (omitting /chat/completions causes 404s in ccr).

  3. 3

    Assign Router slots ("default": "relay,claude-sonnet-5-5", "background": "relay,deepseek-v4.1-flash", "think": "relay,gpt-6.1-sol", "longContext": "relay,glm-5.3") and start coding via `ccr code`.

Configuration

deepseek-v4.1-flash
~/.claude-code-router/config.json
{
  "LOG": true,
  "HOST": "127.0.0.1",
  "PORT": 3456,
  "Providers": [
    {
      "name": "relay",
      "api_base_url": "https://proxystacks.com/v1/chat/completions",
      "api_key": "sk-relay-your-key",
      "models": [
        "deepseek-v4.1-flash",
        "claude-sonnet-5-5",
        "gpt-6.1-sol",
        "deepseek-v4.1-flash",
        "glm-5.3"
      ],
      "transformer": {
        "use": ["openai"]
      }
    }
  ],
  "Router": {
    "default": "relay,deepseek-v4.1-flash",
    "background": "relay,deepseek-v4.1-flash"
  }
}

Set api_base_url to https://proxystacks.com/v1/chat/completions in ~/.claude-code-router/config.json to route default, background, think, and longContext tasks.

Advanced config: environment variable API key, multi-model routing & max output tokens

Use a project-specific config or multi-profile setup with environment variable keys, flagship and fast models — Claude Opus/Sonnet 5.5 (-50%), GPT-6.1 Sol / GPT-6 Luna (-30%), DeepSeek V4.1 Flash (-40%), GLM-5.3 & Kimi K3.1 Pro (-30%) — and explicit context/output token limits.

~/.claude-code-router/config.json (4-lane Router)
{
  // ~/.claude-code-router/config.json — 4-lane dynamic task routing (launch via `ccr code` or `ccr ui`)
  // Important: api_base_url MUST include the full /v1/chat/completions path!
  // Mainland China / APAC low-latency endpoint: "https://hk.proxystacks.com/v1/chat/completions"
  "LOG": true,
  "HOST": "127.0.0.1",
  "PORT": 3456,
  "Providers": [
    {
      "name": "relay",
      "api_base_url": "https://proxystacks.com/v1/chat/completions",
      "api_key": "$RELAY_API_KEY",
      "models": [
        "claude-opus-5-5",
        "claude-sonnet-5-5",
        "gpt-6.1-sol",
        "deepseek-v4.1-flash",
        "glm-5.3",
        "kimi-k3.1-pro"
      ],
      "transformer": {
        "use": ["openai"]
      }
    }
  ],
  "Router": {
    "default": "relay,claude-sonnet-5-5",
    "background": "relay,deepseek-v4.1-flash",
    "think": "relay,gpt-6.1-sol",
    "longContext": "relay,glm-5.3",
    "longContextThreshold": 120000
  }
}

Troubleshooting

  • 401: check the Relay key and authentication header. Never paste a secret into a support ticket.
  • 404: use an exact published model ID and the documented base URL, not an upstream alias.
  • For streaming use stream: true. Codex uses Responses; keep disable_response_storage = true.

Common questions

Why does Claude Code Router return 404 unless api_base_url ends with /v1/chat/completions?

Unlike standard OpenAI SDKs that append /chat/completions automatically to a /v1 base URL, musistudio/claude-code-router sends POST payloads directly to the exact Providers[].api_base_url string. Always set "api_base_url": "https://proxystacks.com/v1/chat/completions" (or "https://hk.proxystacks.com/v1/chat/completions" in APAC) with "transformer": { "use": ["openai"] }.

When should I use claude-code-router vs connecting Claude Code directly to /anthropic?

If you use a single primary model plus ANTHROPIC_SMALL_FAST_MODEL, pointing Claude Code directly at https://proxystacks.com/anthropic requires zero local processes and preserves native Anthropic caching. Add claude-code-router (`ccr code`) when you specifically want automatic threshold switching—for example sending prompts above 120K tokens to glm-5.3 (longContext) and reasoning turns to gpt-6.1-sol (think).

All docs