본문으로 건너뛰기

연동 가이드

Claude Code Router (ccr) 설정 가이드: config.json 4채널 자동 라우팅

참고: ProxyStacks Relay는 기본 /anthropic 직결을 지원하지만, claude-code-router(ccr)를 함께 쓰면 default, background, think, longContext(>120K) 요청을 단일 API 키로 자동 분기할 수 있습니다.

설정 방법

  1. 1

    `npm install -g @musistudio/claude-code-router` 설치 후 콘솔에서 sk-relay-... 키를 발급합니다.

  2. 2

    ~/.claude-code-router/config.json(또는 `ccr ui`)에서 api_base_url에 전체 경로 "https://proxystacks.com/v1/chat/completions"를 입력합니다(/chat/completions 누락 시 404 발생).

  3. 3

    Router에 default, background, think, longContext 슬롯을 매핑하고 `ccr code`로 실행합니다.

설정

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"
  }
}

~/.claude-code-router/config.json에 /v1/chat/completions 전체 경로를 지정해 default, background, think, longContext 자동 분기.

고급 설정: 환경 변수 API 키, 다중 모델 라우팅 및 최대 출력 토큰 제한

프로젝트별 설정 파일이나 다중 프로필에서 환경 변수로 API 키를 주입하고 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%)와 컨텍스트/출력 토큰 한도를 함께 구성합니다.

~/.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
  }
}

문제 해결

  • 401: Relay 키와 인증 헤더를 확인하세요. 지원 요청에 비밀 키를 붙여 넣지 마세요.
  • 404: 게시된 정확한 모델 ID와 문서의 기본 URL을 사용하세요. 상위 공급자의 별칭을 사용하지 마세요.
  • 스트리밍은 stream: true를 설정하세요. Codex는 Responses를 사용하며 disable_response_storage = true를 유지해야 합니다.

자주 묻는 질문

claude-code-router에서 api_base_url을 /v1까지만 적으면 왜 404가 발생하나요?

ccr은 api_base_url 문자열로 직접 POST 요청을 보내므로 반드시 "https://proxystacks.com/v1/chat/completions" 전체 경로를 입력해야 합니다.

기본 /anthropic 직결과 claude-code-router(ccr)는 언제 구분해 쓰나요?

별도 로컬 프로세스 없이 네이티브 캐싱을 쓰려면 /anthropic 직결이 가장 빠르며, 120K 이상 장문(longContext)이나 추론(think) 요청을 모델별로 자동 분기할 때 `ccr code`를 사용합니다.

모든 문서