ccr路由

推荐用musistudio/claude-code-router: Use Claude Code as the foundation for coding infrastructure, allowing you to decide how to interact with the model while enjoying updates from Anthropic. 中转不同的模型

安装

安装nodejs,pnpm后

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

ui配置

使用ccr ui 启动ui配置

可以使用下面推荐json,配置了鸭鸭的claude code,gemini可以用其他中转

推荐claude code中转,按量付费无时间限制,1R=1美元,倍率为官方0.4 https://instcopilot-api.com/register?aff=Z9U7

{
  "LOG": true,
  "LOG_LEVEL": "info",
  "CLAUDE_PATH": "",
  "HOST": "127.0.0.1",
  "PORT": 3456,
  "APIKEY": "",
  "API_TIMEOUT_MS": "600000",
  "PROXY_URL": "",
  "transformers": [],
  "Providers": [
    {
      "name": "鸭鸭",
      "api_base_url": "https://instcopilot-api.com/v1/messages",
      "api_key": "sk-xxx",
      "models": [
        "claude-3-5-haiku-20241022",
        "claude-3-5-sonnet-20241022",
        "claude-3-7-sonnet-20250219",
        "claude-3-7-sonnet-20250219-thinking",
        "claude-opus-4-1-20250805",
        "claude-opus-4-1-20250805-thinking",
        "claude-opus-4-20250514",
        "claude-opus-4-20250514-thinking",
        "claude-sonnet-4-20250514",
        "claude-sonnet-4-20250514-thinking"
      ],
      "transformer": {
        "use": [
          "Anthropic"
        ]
      }
    },
    {
      "name": "openrouter",
      "api_base_url": "https://chatapi.onechats.top/v1/chat/completions",
      "api_key": "sk-xxx",
      "models": [
        "gemini-2.5-pro",
        "gemini-2.5-flash"
      ],
      "transformer": {
        "use": [
          "openrouter"
        ]
      }
    }
  ],
  "StatusLine": {
    "enabled": true,
    "currentStyle": "default",
    "default": {
      "modules": []
    },
    "powerline": {
      "modules": []
    }
  },
  "Router": {
    "default": "鸭鸭,claude-sonnet-4-20250514",
"background": "鸭鸭,claude-3-5-haiku-20241022",
    "think": "鸭鸭,claude-sonnet-4-20250514-thinking",
    "longContext": "openrouter,gemini-2.5-pro",
    "longContextThreshold": 600000,
    "webSearch": "openrouter,gemini-2.5-flash",
    "image": ""
  },
  "CUSTOM_ROUTER_PATH": ""
}

启动

ccr code
启动

设置记忆,比如让他强制说中文

直接编辑文件 ~/.claude/CLAUDE.md

常用按键,命令

按 Escape 键:这是中断 Claude Code 当前任务或停止其生成内容。

Control+C:请注意,使用 Control+C 快捷键会完全退出 Claude Code 命令行工具,而不是仅仅中断当前的输出。

/model:切换使用的 AI 模型

/cost:显示令牌(token)的使用统计信息。

/clear:清除当前的对话历史

Last modification:September 3, 2025
如果觉得我的文章对你有用,请随意赞赏