免费使用 Claude Code
1. 安装 Claude Code
首先确保已安装 Claude Code:
shell
npm install -g @anthropic-ai/claude-code
然后安装 Claude Code Router:
shell
npm install -g @musistudio/claude-code-router
2. UI 模式使用
为了更直观的体验,可以使用 UI 模式来管理配置:
shell
ccr ui
3. 使用 ModelScope 提供的免费调用次数
3.1 获取 API Key
- 注册 ModelScope
- 绑定阿里云账号
- ModelScope 点击账户设置,点击访问令牌,获取 API Key
3.2 配置 ModelScope
json
{
"LOG": true,
"LOG_LEVEL": "debug",
"CLAUDE_PATH": "",
"HOST": "127.0.0.1",
"PORT": 3456,
"APIKEY": "123",
"API_TIMEOUT_MS": "600000",
"PROXY_URL": "",
"transformers": [
"enhancetool",
"maxtoken"
],
"Providers": [
{
"name": "modelscope",
"api_base_url": "https://api-inference.modelscope.cn/v1/chat/completions",
"api_key": "这里填写你的apikey",
"models": [
"Qwen/Qwen3-Coder-480B-A35B-Instruct"
],
"transformer": {
"use": [
[
"maxtoken",
{
"max_tokens": 65536
}
],
"enhancetool"
]
}
}
],
"StatusLine": {
"enabled": false,
"currentStyle": "default",
"default": {
"modules": [
{
"type": "workDir",
"icon": "",
"text": "{{workDirName}}",
"color": "bright_blue"
},
{
"type": "gitBranch",
"icon": "🌿",
"text": "{{gitBranch}}",
"color": "bright_green"
},
{
"type": "model",
"icon": "🤖",
"text": "{{model}}",
"color": "bright_yellow"
},
{
"type": "usage",
"icon": "📊",
"text": "{{inputTokens}} → {{outputTokens}}",
"color": "bright_magenta"
},
{
"type": "script",
"icon": "📜",
"text": "Script Module",
"color": "bright_cyan",
"scriptPath": ""
}
]
},
"powerline": {
"modules": []
}
},
"Router": {
"default": "modelscope2,Qwen/Qwen3-Coder-480B-A35B-Instruct",
"background": "modelscope2,Qwen/Qwen3-Coder-480B-A35B-Instruct",
"think": "modelscope2,Qwen/Qwen3-Coder-480B-A35B-Instruct",
"longContext": "modelscope2,Qwen/Qwen3-Coder-480B-A35B-Instruct",
"longContextThreshold": 80000,
"webSearch": "modelscope2,Qwen/Qwen3-Coder-480B-A35B-Instruct"
}
}
3.3 通过 Claude Code Router 启动 Claude Code
shell
ccr code