Claude Code Router v1.0.33配置指南:轻松连接各类三方API——附邪修环境切换法

最近在折腾 claude-code-router ,发现它是一个非常强大的工具,可以帮助我们统一管理和调用各种大模型 API。我把配置过程中的一些经验和踩坑心得整理了一下,希望能帮助到有需要的佬友。

一、 基础安装

首先,需要安装Claude Code和 claude-code-router。打开终端,运行以下命令:

  1. 安装 Claude Code 主程序
npm install -g @anthropic-ai/claude-code
  1. 安装 claude-code-router
npm install -g @musistudio/claude-code-router

3.启动 UI 界面 ccr ui

二、 网络代理

很多第三方通用 API(如 new-api、公益 API 等)的服务器都在国外,国内直接访问可能会遇到 500 , api_error , internal_error 等网络错误。如果遇到此类问题,可以尝试设置。

请根据你自己梯子进行修改。

三、 API 分类配置教程

claude-code-router 支持多种 API,我们主要看两类。

1. 常见直连 API

这类 API 包括 硅基 (Siliconflow)Kimi (Moonshot)通义千问 (ModelScope)火山引擎 (Volcengine) 等。

官方仓库的 README 已经有非常详细的配置说明,大家直接参考即可,这里不再赘述。

2. 第三方通用 API (以 Gemini 和智谱为例)

Gemini (谷歌)
  • URL :需要以 /v1beta/models/ 结尾。例如,如果你使用 gptLoad 或类似的中转服务,地址可能如下:
http://localhost:3001/proxy/gemini/v1beta/models/
  • 供应商转换器 (Provider Converter) :选择 gemini

  • 模型 (Model) :填写模型名称即可,不需要 models/ 前缀。

    • 例如,模型 ID 是 models/gemini-2.5-pro ,那么在模型字段里只填写 gemini-2.5-pro

  • 关于 429 Too Many Requests 错误 : 我在使用 flash 模型时,遇到 429问题,如果有佬知道怎么配置,麻烦解答一二。
智谱

智谱提供了两种连接方式一种是 CC 接口 ,即可以直接在 CC 中 使用的方式,也是官方推荐使用方式。还有一种是OpenAI接口

方式 1 (推荐): CC 兼容接口

  • URL
https://open.bigmodel.cn/api/anthropic/v1/messages
  • 模型 :如 glm-4glm-4-air
  • 供应商转换器 :选择 Anthropic

方式 2: OpenAI接口

  • URL
https://open.bigmodel.cn/api/paas/v4/chat/completions
  • 模型选择glm-4
  • 其余选项 :保持默认即可。

从第二种方式,可见,常见OpenAI接口,都可以如上简单进行配置。

配置切换(邪修)

通过智谱的配置方式,我们可以看出,其实 CCR 其实也可以作为一个 简单的CC 配置切换工具来使用(邪修),非常方便快捷。
我们可以直接在 CC 中配置

"env": {
"ANTHROPIC_AUTH_TOKEN": "key",
"ANTHROPIC_BASE_URL": "http://127.0.0.1:3456"
}

CC环境全走 CCR,然后我们在 CCR 中配置中转商的Claude Code 专用的Anthropic 接口,那么即可在 CCR 中随意切换自如。
需注意的是,Claude Code 专用的Anthropic 接口在配置中,应如:供应商 API/v1/messages

最后

发现很多佬做了CC 环境切换,还有 CCR 的 UI,发现重复造轮子的问题挺多的,但是因为发现确实需要这些功能,别人的东西又不是很满意,自己提 MR,也很麻烦。感谢 AI,重复造轮子试错成本低了很多。

还有就是CCR 目前出的 UI 已经还可以了,很方便。

遇到非流的问题,也就是如retool2API 的接口,返回contains “[object Object]”,没有解决。

另外,也有遇到N 佬公益的claude-4.0-sonnet时而吞回复的问题,感觉是间歇性的,再次感谢 N 佬。

如果各位佬有在使用 CCR 过程中踩坑,遇到的问题也可以一起讨论。
简单贴一下配置。

{
  "LOG": false,
  "CLAUDE_PATH": "",
  "HOST": "127.0.0.1",
  "PORT": 3456,
  "APIKEY": "key",
  "API_TIMEOUT_MS": "600000",
  "PROXY_URL": "http://127.0.0.1:7897",
  "Transformers": [],
  "Providers": [
    {
      "api_base_url": "https://api.siliconflow.cn/v1/chat/completions",
      "api_key": "key",
      "models": ["moonshotai/Kimi-K2-Instruct"],
      "name": "siliconflow",
      "transformer": {
        "use": [
          [
            "maxtoken",
            {
              "max_tokens": 16384
            }
          ]
        ]
      }
    },
    {
      "api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
      "api_key": "key",
      "models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
      "name": "modelscope",
      "transformer": {
        "use": [
          [
            "maxtoken",
            {
              "max_tokens": 65536
            },
            "enhancetool"
          ]
        ]
      }
    },
    {
      "name": "volceskimi",
      "api_base_url": "https://ark.cn-beijing.volces.com/api/v3/chat/completions",
      "api_key": "key",
      "models": ["kimi-k2-250711"]
    },
    {
      "name": "nyxar",
      "api_base_url": "https://api.nyxar.org/v1/chat/completions",
      "api_key": "key",
      "models": [
        "gemini-2.5-pro",
        "claude-4.0-sonnet",
        "anthropic/claude-3.7-sonnet",
        "anthropic/claude-4-sonnet-20250522"
      ]
    },
    {
      "name": "bigmodelOpen",
      "api_base_url": "https://open.bigmodel.cn/api/paas/v4/chat/completions",
      "api_key": "key",
      "models": ["glm-4.5"]
    },
    {
      "name": "bigmodelCC",
      "api_base_url": "https://open.bigmodel.cn/api/anthropic/v1/messages",
      "api_key": "key",
      "models": ["glm-4.5"],
      "transformer": {
        "use": ["Anthropic"]
      }
    },
    {
      "name": "geminiC",
      "api_base_url": "http://localhost:3001/proxy/gemini/v1beta/models/",
      "api_key": "key",
      "models": [
        "gemini-2.5-flash",
        "gemini-2.5-pro",
        "gemini-2.5-flash-preview-05-20"
      ],
      "transformer": {
        "use": ["gemini"]
      }
    }
  ],
  "Router": {
    "default": "nyxar,claude-4.0-sonnet",
    "background": "siliconflow,moonshotai/Kimi-K2-Instruct",
    "think": "siliconflow,moonshotai/Kimi-K2-Instruct",
    "longContext": "geminiC,gemini-2.5-pro",
    "longContextThreshold": 60000,
    "webSearch": "geminiC,gemini-2.5-flash"
  }
}

【Claude Code】使用 claude-code-router 快速配置第三方模型(新增Qwen3示例)

266 个赞

mark一下

3 个赞

感谢大佬!

3 个赞

感谢大佬!!!!

4 个赞

現在還沒用到CCR,先收藏有需要時來看看,感謝

3 个赞

提问,准备尝试使用ccr,官方的或者公益提供的就是claude格式,这些不需要转格式,为了方便统一管理,也可以直接使用ccr吗

3 个赞

可以的,参考智谱的方式一,供应商 API+/v1/messages

3 个赞

这个加上 “enhancetool” 避免工具问题。

ccr 现阶段难度已不在为接入头疼啦。 难度是 开发transformer 去适配问题。 这个原作者一直在积极接入不同厂商。 感谢作者:folded_hands:

感谢分享。

4 个赞

感谢大佬

2 个赞

我接入v0,发现ccr正常cc空回复,说是回复标志问题导致无法判断结束event,试了坛子里transformer无效

1 个赞

感谢提醒,已添加。确实,从更新的代码能看出来

1 个赞

嗯 今早上一看1.33 了 迭代太快了 :joy:

2 个赞

claude-code 能力强大不是 Claude 能力强吗 和 其他 AI大模型有什么关系 如果觉得要连其他AI 不如使用 roo code ,cline

1 个赞

收藏了,感谢:folded_hands:

2 个赞

感谢佬友分享 :folded_hands:

1 个赞

我用的newapi,用带思考的模型就会偶尔不出回复直到超时。另外我看大家都设置了maxtoken,不设这个会有影响吗?设置的话一般设多少?claude 4 sonnet模型

1 个赞

感谢大佬分享!:+1:

1 个赞

有空了配置下

1 个赞

我也偶尔遇到这个问题,暂时没找到好解决办法

2 个赞

感谢大佬

2 个赞