AI | Modelscope接入Claude code

Aug 7, 2025
#ai

除了免费的anyrouter和gemini之外,Modelscope提供每天2000的请求,对于个人来说完全够了。

bun install -g @anthropic-ai/claude-code
bun install -g @musistudio/claude-code-router

申请魔搭社区的key(https://www.modelscope.cn/my/myaccesstoken)。

创建配置文件~/.claude-code-router/config.json

{
  "Providers": [
    {
      "name": "modelscope",
      "api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
      "api_key": "xxxx",
      "models": ["Qwen/Qwen3-Coder-480B-A35B-Instruct"],
      "transformer": {
        "use": [
          [
            "maxtoken",
            {
              "max_tokens": 65536
            }
          ],
          "enhancetool"
        ]
      }
    }
  ],
  "Router": {
    "default": "modelscope,Qwen/Qwen3-Coder-480B-A35B-Instruct"
  },
  "HOST": "127.0.0.1",
  "LOG": true
}

当前也可以是使用ui配饰:

ccr ui

完成后需要ccr restart

开始videcoding:

ccr code

切换模型,需要使用魔搭社区(https://www.modelscope.cn/models):

/model moonshotai/Kimi-K2-Instruct

  • https://linux.do/t/topic/809617
  • https://github.com/musistudio/claude-code-router
  • https://www.modelscope.cn/models
https://inasa.dev/posts/rss.xml