[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-musistudio--claude-code-router":3,"tool-musistudio--claude-code-router":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",154349,2,"2026-04-13T23:32:16",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":79,"owner_twitter":77,"owner_website":77,"owner_url":80,"languages":81,"stars":106,"forks":107,"last_commit_at":108,"license":109,"difficulty_score":32,"env_os":110,"env_gpu":111,"env_ram":111,"env_deps":112,"category_tags":118,"github_topics":77,"view_count":32,"oss_zip_url":77,"oss_zip_packed_at":77,"status":17,"created_at":119,"updated_at":120,"faqs":121,"releases":122},7370,"musistudio\u002Fclaude-code-router","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.","claude-code-router 是一款专为增强 Claude Code 灵活性而设计的开源路由工具。它允许开发者以 Claude Code 为核心构建编码基础设施，同时自由决定如何与底层模型交互，既能享受 Anthropic 的官方更新，又能突破单一模型限制。\n\n该工具主要解决了开发者在使用 AI 编程时面临的模型选择僵化问题。通过它，用户可以轻松将请求路由至 OpenRouter、DeepSeek、Ollama、Gemini 等多种模型提供商，针对不同任务场景（如后台处理、深度思考或长上下文分析）动态切换最合适的模型。此外，它还支持自定义请求与响应转换，并能在 GitHub Actions 等自动化流程中无缝集成。\n\nclaude-code-router 特别适合需要高度定制化 AI 工作流的软件开发者、技术研究人员及 DevOps 工程师。其独特亮点在于提供了终端命令行管理功能（`ccr model`）和实时模型切换命令（`\u002Fmodel`），让用户无需重启即可在对话中灵活调整模型策略。配合插件系统，用户还能扩展更多个性化功能。无论是希望降低 API 成本，还是想尝试不同模型特","claude-code-router 是一款专为增强 Claude Code 灵活性而设计的开源路由工具。它允许开发者以 Claude Code 为核心构建编码基础设施，同时自由决定如何与底层模型交互，既能享受 Anthropic 的官方更新，又能突破单一模型限制。\n\n该工具主要解决了开发者在使用 AI 编程时面临的模型选择僵化问题。通过它，用户可以轻松将请求路由至 OpenRouter、DeepSeek、Ollama、Gemini 等多种模型提供商，针对不同任务场景（如后台处理、深度思考或长上下文分析）动态切换最合适的模型。此外，它还支持自定义请求与响应转换，并能在 GitHub Actions 等自动化流程中无缝集成。\n\nclaude-code-router 特别适合需要高度定制化 AI 工作流的软件开发者、技术研究人员及 DevOps 工程师。其独特亮点在于提供了终端命令行管理功能（`ccr model`）和实时模型切换命令（`\u002Fmodel`），让用户无需重启即可在对话中灵活调整模型策略。配合插件系统，用户还能扩展更多个性化功能。无论是希望降低 API 成本，还是想尝试不同模型特性的技术团队，都能借此获得更稳定、高效且可控的编码体验。","![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_4f20b13b9b86.png)\n\n[![](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%87%A8%F0%9F%87%B3-%E4%B8%AD%E6%96%87%E7%89%88-ff0000?style=flat)](README_zh.md)\n[![Discord](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiscord-%235865F2.svg?&logo=discord&logoColor=white)](https:\u002F\u002Fdiscord.gg\u002FrdftVMaUcS)\n[![](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fmusistudio\u002Fclaude-code-router)](https:\u002F\u002Fgithub.com\u002Fmusistudio\u002Fclaude-code-router\u002Fblob\u002Fmain\u002FLICENSE)\n\n\u003Chr>\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_9d4a89ff62b5.jpg)\n> This project is sponsored by Z.ai, supporting us with their GLM CODING PLAN.\n\n> GLM CODING PLAN is a subscription service designed for AI coding, starting at just $10\u002Fmonth. It provides access to their flagship GLM-4.7 & （GLM-5 Only Available  for Pro Users）model across 10+ popular AI coding tools (Claude Code, Cline, Roo Code, etc.), offering developers top-tier, fast, and stable coding experiences.\n\n> Get 10% OFF GLM CODING PLAN：https:\u002F\u002Fz.ai\u002Fsubscribe?ic=8JVLJQFSKB  \n\n> [Progressive Disclosure of Agent Tools from the Perspective of CLI Tool Style](\u002Fblog\u002Fen\u002Fprogressive-disclosure-of-agent-tools-from-the-perspective-of-cli-tool-style.md)\n\n> A powerful tool to route Claude Code requests to different models and customize any request.\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_d3ac566941e2.png)\n\n## ✨ Features\n\n- **Model Routing**: Route requests to different models based on your needs (e.g., background tasks, thinking, long context).\n- **Multi-Provider Support**: Supports various model providers like OpenRouter, DeepSeek, Ollama, Gemini, Volcengine, and SiliconFlow.\n- **Request\u002FResponse Transformation**: Customize requests and responses for different providers using transformers.\n- **Dynamic Model Switching**: Switch models on-the-fly within Claude Code using the `\u002Fmodel` command.\n- **CLI Model Management**: Manage models and providers directly from the terminal with `ccr model`.\n- **GitHub Actions Integration**: Trigger Claude Code tasks in your GitHub workflows.\n- **Plugin System**: Extend functionality with custom transformers.\n\n## 🚀 Getting Started\n\n### 1. Installation\n\nFirst, ensure you have [Claude Code](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fquickstart) installed:\n\n```shell\nnpm install -g @anthropic-ai\u002Fclaude-code\n```\n\nThen, install Claude Code Router:\n\n```shell\nnpm install -g @musistudio\u002Fclaude-code-router\n```\n\n### 2. Configuration\n\nCreate and configure your `~\u002F.claude-code-router\u002Fconfig.json` file. For more details, you can refer to `config.example.json`.\n\nThe `config.json` file has several key sections:\n\n- **`PROXY_URL`** (optional): You can set a proxy for API requests, for example: `\"PROXY_URL\": \"http:\u002F\u002F127.0.0.1:7890\"`.\n- **`LOG`** (optional): You can enable logging by setting it to `true`. When set to `false`, no log files will be created. Default is `true`.\n- **`LOG_LEVEL`** (optional): Set the logging level. Available options are: `\"fatal\"`, `\"error\"`, `\"warn\"`, `\"info\"`, `\"debug\"`, `\"trace\"`. Default is `\"debug\"`.\n- **Logging Systems**: The Claude Code Router uses two separate logging systems:\n  - **Server-level logs**: HTTP requests, API calls, and server events are logged using pino in the `~\u002F.claude-code-router\u002Flogs\u002F` directory with filenames like `ccr-*.log`\n  - **Application-level logs**: Routing decisions and business logic events are logged in `~\u002F.claude-code-router\u002Fclaude-code-router.log`\n- **`APIKEY`** (optional): You can set a secret key to authenticate requests. When set, clients must provide this key in the `Authorization` header (e.g., `Bearer your-secret-key`) or the `x-api-key` header. Example: `\"APIKEY\": \"your-secret-key\"`.\n- **`HOST`** (optional): You can set the host address for the server. If `APIKEY` is not set, the host will be forced to `127.0.0.1` for security reasons to prevent unauthorized access. Example: `\"HOST\": \"0.0.0.0\"`.\n- **`NON_INTERACTIVE_MODE`** (optional): When set to `true`, enables compatibility with non-interactive environments like GitHub Actions, Docker containers, or other CI\u002FCD systems. This sets appropriate environment variables (`CI=true`, `FORCE_COLOR=0`, etc.) and configures stdin handling to prevent the process from hanging in automated environments. Example: `\"NON_INTERACTIVE_MODE\": true`.\n\n- **`Providers`**: Used to configure different model providers.\n- **`Router`**: Used to set up routing rules. `default` specifies the default model, which will be used for all requests if no other route is configured.\n- **`API_TIMEOUT_MS`**: Specifies the timeout for API calls in milliseconds.\n\n#### Environment Variable Interpolation\n\nClaude Code Router supports environment variable interpolation for secure API key management. You can reference environment variables in your `config.json` using either `$VAR_NAME` or `${VAR_NAME}` syntax:\n\n```json\n{\n  \"OPENAI_API_KEY\": \"$OPENAI_API_KEY\",\n  \"GEMINI_API_KEY\": \"${GEMINI_API_KEY}\",\n  \"Providers\": [\n    {\n      \"name\": \"openai\",\n      \"api_base_url\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"$OPENAI_API_KEY\",\n      \"models\": [\"gpt-5\", \"gpt-5-mini\"]\n    }\n  ]\n}\n```\n\nThis allows you to keep sensitive API keys in environment variables instead of hardcoding them in configuration files. The interpolation works recursively through nested objects and arrays.\n\nHere is a comprehensive example:\n\n```json\n{\n  \"APIKEY\": \"your-secret-key\",\n  \"PROXY_URL\": \"http:\u002F\u002F127.0.0.1:7890\",\n  \"LOG\": true,\n  \"API_TIMEOUT_MS\": 600000,\n  \"NON_INTERACTIVE_MODE\": false,\n  \"Providers\": [\n    {\n      \"name\": \"openrouter\",\n      \"api_base_url\": \"https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\n        \"google\u002Fgemini-2.5-pro-preview\",\n        \"anthropic\u002Fclaude-sonnet-4\",\n        \"anthropic\u002Fclaude-3.5-sonnet\",\n        \"anthropic\u002Fclaude-3.7-sonnet:thinking\"\n      ],\n      \"transformer\": {\n        \"use\": [\"openrouter\"]\n      }\n    },\n    {\n      \"name\": \"deepseek\",\n      \"api_base_url\": \"https:\u002F\u002Fapi.deepseek.com\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\"deepseek-chat\", \"deepseek-reasoner\"],\n      \"transformer\": {\n        \"use\": [\"deepseek\"],\n        \"deepseek-chat\": {\n          \"use\": [\"tooluse\"]\n        }\n      }\n    },\n    {\n      \"name\": \"ollama\",\n      \"api_base_url\": \"http:\u002F\u002Flocalhost:11434\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"ollama\",\n      \"models\": [\"qwen2.5-coder:latest\"]\n    },\n    {\n      \"name\": \"gemini\",\n      \"api_base_url\": \"https:\u002F\u002Fgenerativelanguage.googleapis.com\u002Fv1beta\u002Fmodels\u002F\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\"gemini-2.5-flash\", \"gemini-2.5-pro\"],\n      \"transformer\": {\n        \"use\": [\"gemini\"]\n      }\n    },\n    {\n      \"name\": \"volcengine\",\n      \"api_base_url\": \"https:\u002F\u002Fark.cn-beijing.volces.com\u002Fapi\u002Fv3\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\"deepseek-v3-250324\", \"deepseek-r1-250528\"],\n      \"transformer\": {\n        \"use\": [\"deepseek\"]\n      }\n    },\n    {\n      \"name\": \"modelscope\",\n      \"api_base_url\": \"https:\u002F\u002Fapi-inference.modelscope.cn\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"\",\n      \"models\": [\"Qwen\u002FQwen3-Coder-480B-A35B-Instruct\", \"Qwen\u002FQwen3-235B-A22B-Thinking-2507\"],\n      \"transformer\": {\n        \"use\": [\n          [\n            \"maxtoken\",\n            {\n              \"max_tokens\": 65536\n            }\n          ],\n          \"enhancetool\"\n        ],\n        \"Qwen\u002FQwen3-235B-A22B-Thinking-2507\": {\n          \"use\": [\"reasoning\"]\n        }\n      }\n    },\n    {\n      \"name\": \"dashscope\",\n      \"api_base_url\": \"https:\u002F\u002Fdashscope.aliyuncs.com\u002Fcompatible-mode\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"\",\n      \"models\": [\"qwen3-coder-plus\"],\n      \"transformer\": {\n        \"use\": [\n          [\n            \"maxtoken\",\n            {\n              \"max_tokens\": 65536\n            }\n          ],\n          \"enhancetool\"\n        ]\n      }\n    },\n    {\n      \"name\": \"aihubmix\",\n      \"api_base_url\": \"https:\u002F\u002Faihubmix.com\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-\",\n      \"models\": [\n        \"Z\u002Fglm-4.5\",\n        \"claude-opus-4-20250514\",\n        \"gemini-2.5-pro\"\n      ]\n    }\n  ],\n  \"Router\": {\n    \"default\": \"deepseek,deepseek-chat\",\n    \"background\": \"ollama,qwen2.5-coder:latest\",\n    \"think\": \"deepseek,deepseek-reasoner\",\n    \"longContext\": \"openrouter,google\u002Fgemini-2.5-pro-preview\",\n    \"longContextThreshold\": 60000,\n    \"webSearch\": \"gemini,gemini-2.5-flash\"\n  }\n}\n```\n\n### 3. Running Claude Code with the Router\n\nStart Claude Code using the router:\n\n```shell\nccr code\n```\n\n> **Note**: After modifying the configuration file, you need to restart the service for the changes to take effect:\n>\n> ```shell\n> ccr restart\n> ```\n\n### 4. UI Mode\n\nFor a more intuitive experience, you can use the UI mode to manage your configuration:\n\n```shell\nccr ui\n```\n\nThis will open a web-based interface where you can easily view and edit your `config.json` file.\n\n![UI](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_74f0c7cfe791.png)\n\n### 5. CLI Model Management\n\nFor users who prefer terminal-based workflows, you can use the interactive CLI model selector:\n\n```shell\nccr model\n```\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_2e3d5dd36362.gif)\n\nThis command provides an interactive interface to:\n\n- View current configuration:\n- See all configured models (default, background, think, longContext, webSearch, image)\n- Switch models: Quickly change which model is used for each router type\n- Add new models: Add models to existing providers\n- Create new providers: Set up complete provider configurations including:\n   - Provider name and API endpoint\n   - API key\n   - Available models\n   - Transformer configuration with support for:\n     - Multiple transformers (openrouter, deepseek, gemini, etc.)\n     - Transformer options (e.g., maxtoken with custom limits)\n     - Provider-specific routing (e.g., OpenRouter provider preferences)\n\nThe CLI tool validates all inputs and provides helpful prompts to guide you through the configuration process, making it easy to manage complex setups without editing JSON files manually.\n\n### 6. Presets Management\n\nPresets allow you to save, share, and reuse configurations easily. You can export your current configuration as a preset and install presets from files or URLs.\n\n```shell\n# Export current configuration as a preset\nccr preset export my-preset\n\n# Export with metadata\nccr preset export my-preset --description \"My OpenAI config\" --author \"Your Name\" --tags \"openai,production\"\n\n# Install a preset from local directory\nccr preset install \u002Fpath\u002Fto\u002Fpreset\n\n# List all installed presets\nccr preset list\n\n# Show preset information\nccr preset info my-preset\n\n# Delete a preset\nccr preset delete my-preset\n```\n\n**Preset Features:**\n- **Export**: Save your current configuration as a preset directory (with manifest.json)\n- **Install**: Install presets from local directories\n- **Sensitive Data Handling**: API keys and other sensitive data are automatically sanitized during export (marked as `{{field}}` placeholders)\n- **Dynamic Configuration**: Presets can include input schemas for collecting required information during installation\n- **Version Control**: Each preset includes version metadata for tracking updates\n\n**Preset File Structure:**\n```\n~\u002F.claude-code-router\u002Fpresets\u002F\n├── my-preset\u002F\n│   └── manifest.json    # Contains configuration and metadata\n```\n\n### 7. Activate Command (Environment Variables Setup)\n\nThe `activate` command allows you to set up environment variables globally in your shell, enabling you to use the `claude` command directly or integrate Claude Code Router with applications built using the Agent SDK.\n\nTo activate the environment variables, run:\n\n```shell\neval \"$(ccr activate)\"\n```\n\nThis command outputs the necessary environment variables in shell-friendly format, which are then set in your current shell session. After activation, you can:\n\n- **Use `claude` command directly**: Run `claude` commands without needing to use `ccr code`. The `claude` command will automatically route requests through Claude Code Router.\n- **Integrate with Agent SDK applications**: Applications built with the Anthropic Agent SDK will automatically use the configured router and models.\n\nThe `activate` command sets the following environment variables:\n\n- `ANTHROPIC_AUTH_TOKEN`: API key from your configuration\n- `ANTHROPIC_BASE_URL`: The local router endpoint (default: `http:\u002F\u002F127.0.0.1:3456`)\n- `NO_PROXY`: Set to `127.0.0.1` to prevent proxy interference\n- `DISABLE_TELEMETRY`: Disables telemetry\n- `DISABLE_COST_WARNINGS`: Disables cost warnings\n- `API_TIMEOUT_MS`: API timeout from your configuration\n\n> **Note**: Make sure the Claude Code Router service is running (`ccr start`) before using the activated environment variables. The environment variables are only valid for the current shell session. To make them persistent, you can add `eval \"$(ccr activate)\"` to your shell configuration file (e.g., `~\u002F.zshrc` or `~\u002F.bashrc`).\n\n#### Providers\n\nThe `Providers` array is where you define the different model providers you want to use. Each provider object requires:\n\n- `name`: A unique name for the provider.\n- `api_base_url`: The full API endpoint for chat completions.\n- `api_key`: Your API key for the provider.\n- `models`: A list of model names available from this provider.\n- `transformer` (optional): Specifies transformers to process requests and responses.\n\n#### Transformers\n\nTransformers allow you to modify the request and response payloads to ensure compatibility with different provider APIs.\n\n- **Global Transformer**: Apply a transformer to all models from a provider. In this example, the `openrouter` transformer is applied to all models under the `openrouter` provider.\n  ```json\n  {\n    \"name\": \"openrouter\",\n    \"api_base_url\": \"https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\",\n    \"api_key\": \"sk-xxx\",\n    \"models\": [\n      \"google\u002Fgemini-2.5-pro-preview\",\n      \"anthropic\u002Fclaude-sonnet-4\",\n      \"anthropic\u002Fclaude-3.5-sonnet\"\n    ],\n    \"transformer\": { \"use\": [\"openrouter\"] }\n  }\n  ```\n- **Model-Specific Transformer**: Apply a transformer to a specific model. In this example, the `deepseek` transformer is applied to all models, and an additional `tooluse` transformer is applied only to the `deepseek-chat` model.\n\n  ```json\n  {\n    \"name\": \"deepseek\",\n    \"api_base_url\": \"https:\u002F\u002Fapi.deepseek.com\u002Fchat\u002Fcompletions\",\n    \"api_key\": \"sk-xxx\",\n    \"models\": [\"deepseek-chat\", \"deepseek-reasoner\"],\n    \"transformer\": {\n      \"use\": [\"deepseek\"],\n      \"deepseek-chat\": { \"use\": [\"tooluse\"] }\n    }\n  }\n  ```\n\n- **Passing Options to a Transformer**: Some transformers, like `maxtoken`, accept options. To pass options, use a nested array where the first element is the transformer name and the second is an options object.\n  ```json\n  {\n    \"name\": \"siliconflow\",\n    \"api_base_url\": \"https:\u002F\u002Fapi.siliconflow.cn\u002Fv1\u002Fchat\u002Fcompletions\",\n    \"api_key\": \"sk-xxx\",\n    \"models\": [\"moonshotai\u002FKimi-K2-Instruct\"],\n    \"transformer\": {\n      \"use\": [\n        [\n          \"maxtoken\",\n          {\n            \"max_tokens\": 16384\n          }\n        ]\n      ]\n    }\n  }\n  ```\n\n**Available Built-in Transformers:**\n\n- `Anthropic`:If you use only the `Anthropic` transformer, it will preserve the original request and response parameters(you can use it to connect directly to an Anthropic endpoint).\n- `deepseek`: Adapts requests\u002Fresponses for DeepSeek API.\n- `gemini`: Adapts requests\u002Fresponses for Gemini API.\n- `openrouter`: Adapts requests\u002Fresponses for OpenRouter API. It can also accept a `provider` routing parameter to specify which underlying providers OpenRouter should use. For more details, refer to the [OpenRouter documentation](https:\u002F\u002Fopenrouter.ai\u002Fdocs\u002Ffeatures\u002Fprovider-routing). See an example below:\n  ```json\n    \"transformer\": {\n      \"use\": [\"openrouter\"],\n      \"moonshotai\u002Fkimi-k2\": {\n        \"use\": [\n          [\n            \"openrouter\",\n            {\n              \"provider\": {\n                \"only\": [\"moonshotai\u002Ffp8\"]\n              }\n            }\n          ]\n        ]\n      }\n    }\n  ```\n- `groq`: Adapts requests\u002Fresponses for groq API.\n- `maxtoken`: Sets a specific `max_tokens` value.\n- `tooluse`: Optimizes tool usage for certain models via `tool_choice`.\n- `gemini-cli` (experimental): Unofficial support for Gemini via Gemini CLI [gemini-cli.js](https:\u002F\u002Fgist.github.com\u002Fmusistudio\u002F1c13a65f35916a7ab690649d3df8d1cd).\n- `reasoning`: Used to process the `reasoning_content` field.\n- `sampling`: Used to process sampling information fields such as `temperature`, `top_p`, `top_k`, and `repetition_penalty`.\n- `enhancetool`: Adds a layer of error tolerance to the tool call parameters returned by the LLM (this will cause the tool call information to no longer be streamed).\n- `cleancache`: Clears the `cache_control` field from requests.\n- `vertex-gemini`: Handles the Gemini API using Vertex authentication.\n- `chutes-glm` Unofficial support for GLM 4.5 model via Chutes [chutes-glm-transformer.js](https:\u002F\u002Fgist.github.com\u002Fvitobotta\u002F2be3f33722e05e8d4f9d2b0138b8c863).\n- `qwen-cli` (experimental): Unofficial support for qwen3-coder-plus model via Qwen CLI [qwen-cli.js](https:\u002F\u002Fgist.github.com\u002Fmusistudio\u002Ff5a67841ced39912fd99e42200d5ca8b).\n- `rovo-cli` (experimental): Unofficial support for gpt-5 via Atlassian Rovo Dev CLI [rovo-cli.js](https:\u002F\u002Fgist.github.com\u002FSaseQ\u002Fc2a20a38b11276537ec5332d1f7a5e53).\n\n**Custom Transformers:**\n\nYou can also create your own transformers and load them via the `transformers` field in `config.json`.\n\n```json\n{\n  \"transformers\": [\n    {\n      \"path\": \"\u002FUser\u002Fxxx\u002F.claude-code-router\u002Fplugins\u002Fgemini-cli.js\",\n      \"options\": {\n        \"project\": \"xxx\"\n      }\n    }\n  ]\n}\n```\n\n#### Router\n\nThe `Router` object defines which model to use for different scenarios:\n\n- `default`: The default model for general tasks.\n- `background`: A model for background tasks. This can be a smaller, local model to save costs.\n- `think`: A model for reasoning-heavy tasks, like Plan Mode.\n- `longContext`: A model for handling long contexts (e.g., > 60K tokens).\n- `longContextThreshold` (optional): The token count threshold for triggering the long context model. Defaults to 60000 if not specified.\n- `webSearch`: Used for handling web search tasks and this requires the model itself to support the feature. If you're using openrouter, you need to add the `:online` suffix after the model name.\n- `image` (beta): Used for handling image-related tasks (supported by CCR’s built-in agent). If the model does not support tool calling, you need to set the `config.forceUseImageAgent` property to `true`.\n\n- You can also switch models dynamically in Claude Code with the `\u002Fmodel` command:\n`\u002Fmodel provider_name,model_name`\nExample: `\u002Fmodel openrouter,anthropic\u002Fclaude-3.5-sonnet`\n\n#### Custom Router\n\nFor more advanced routing logic, you can specify a custom router script via the `CUSTOM_ROUTER_PATH` in your `config.json`. This allows you to implement complex routing rules beyond the default scenarios.\n\nIn your `config.json`:\n\n```json\n{\n  \"CUSTOM_ROUTER_PATH\": \"\u002FUser\u002Fxxx\u002F.claude-code-router\u002Fcustom-router.js\"\n}\n```\n\nThe custom router file must be a JavaScript module that exports an `async` function. This function receives the request object and the config object as arguments and should return the provider and model name as a string (e.g., `\"provider_name,model_name\"`), or `null` to fall back to the default router.\n\nHere is an example of a `custom-router.js` based on `custom-router.example.js`:\n\n```javascript\n\u002F\u002F \u002FUser\u002Fxxx\u002F.claude-code-router\u002Fcustom-router.js\n\n\u002F**\n * A custom router function to determine which model to use based on the request.\n *\n * @param {object} req - The request object from Claude Code, containing the request body.\n * @param {object} config - The application's config object.\n * @returns {Promise\u003Cstring|null>} - A promise that resolves to the \"provider,model_name\" string, or null to use the default router.\n *\u002F\nmodule.exports = async function router(req, config) {\n  const userMessage = req.body.messages.find((m) => m.role === \"user\")?.content;\n\n  if (userMessage && userMessage.includes(\"explain this code\")) {\n    \u002F\u002F Use a powerful model for code explanation\n    return \"openrouter,anthropic\u002Fclaude-3.5-sonnet\";\n  }\n\n  \u002F\u002F Fallback to the default router configuration\n  return null;\n};\n```\n\n##### Subagent Routing\n\nFor routing within subagents, you must specify a particular provider and model by including `\u003CCCR-SUBAGENT-MODEL>provider,model\u003C\u002FCCR-SUBAGENT-MODEL>` at the **beginning** of the subagent's prompt. This allows you to direct specific subagent tasks to designated models.\n\n**Example:**\n\n```\n\u003CCCR-SUBAGENT-MODEL>openrouter,anthropic\u002Fclaude-3.5-sonnet\u003C\u002FCCR-SUBAGENT-MODEL>\nPlease help me analyze this code snippet for potential optimizations...\n```\n\n## Status Line (Beta)\nTo better monitor the status of claude-code-router at runtime, version v1.0.40 includes a built-in statusline tool, which you can enable in the UI.\n![statusline-config.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_8f6758cde6ec.png)\n\nThe effect is as follows:\n![statusline](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_9105aa42adda.png)\n\n## 🤖 GitHub Actions\n\nIntegrate Claude Code Router into your CI\u002FCD pipeline. After setting up [Claude Code Actions](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fgithub-actions), modify your `.github\u002Fworkflows\u002Fclaude.yaml` to use the router:\n\n```yaml\nname: Claude Code\n\non:\n  issue_comment:\n    types: [created]\n  # ... other triggers\n\njobs:\n  claude:\n    if: |\n      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||\n      # ... other conditions\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      pull-requests: read\n      issues: read\n      id-token: write\n    steps:\n      - name: Checkout repository\n        uses: actions\u002Fcheckout@v4\n        with:\n          fetch-depth: 1\n\n      - name: Prepare Environment\n        run: |\n          curl -fsSL https:\u002F\u002Fbun.sh\u002Finstall | bash\n          mkdir -p $HOME\u002F.claude-code-router\n          cat \u003C\u003C 'EOF' > $HOME\u002F.claude-code-router\u002Fconfig.json\n          {\n            \"log\": true,\n            \"NON_INTERACTIVE_MODE\": true,\n            \"OPENAI_API_KEY\": \"${{ secrets.OPENAI_API_KEY }}\",\n            \"OPENAI_BASE_URL\": \"https:\u002F\u002Fapi.deepseek.com\",\n            \"OPENAI_MODEL\": \"deepseek-chat\"\n          }\n          EOF\n        shell: bash\n\n      - name: Start Claude Code Router\n        run: |\n          nohup ~\u002F.bun\u002Fbin\u002Fbunx @musistudio\u002Fclaude-code-router@1.0.8 start &\n        shell: bash\n\n      - name: Run Claude Code\n        id: claude\n        uses: anthropics\u002Fclaude-code-action@beta\n        env:\n          ANTHROPIC_BASE_URL: http:\u002F\u002Flocalhost:3456\n        with:\n          anthropic_api_key: \"any-string-is-ok\"\n```\n\n> **Note**: When running in GitHub Actions or other automation environments, make sure to set `\"NON_INTERACTIVE_MODE\": true` in your configuration to prevent the process from hanging due to stdin handling issues.\n\nThis setup allows for interesting automations, like running tasks during off-peak hours to reduce API costs.\n\n## 📝 Further Reading\n\n- [Project Motivation and How It Works](blog\u002Fen\u002Fproject-motivation-and-how-it-works.md)\n- [Maybe We Can Do More with the Router](blog\u002Fen\u002Fmaybe-we-can-do-more-with-the-route.md)\n- [GLM-4.6 Supports Reasoning and Interleaved Thinking](blog\u002Fen\u002Fglm-4.6-supports-reasoning.md)\n\n## ❤️ Support & Sponsoring\n\nIf you find this project helpful, please consider sponsoring its development. Your support is greatly appreciated!\n\n[![ko-fi](https:\u002F\u002Fko-fi.com\u002Fimg\u002Fgithubbutton_sm.svg)](https:\u002F\u002Fko-fi.com\u002FF1F31GN2GM)\n\n[Paypal](https:\u002F\u002Fpaypal.me\u002Fmusistudio1999)\n\n\u003Ctable>\n  \u003Ctr>\n    \u003Ctd>\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_8c5d6426ecb4.jpg\" width=\"200\" alt=\"Alipay\" \u002F>\u003C\u002Ftd>\n    \u003Ctd>\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_5a1bb8ef6f18.jpg\" width=\"200\" alt=\"WeChat Pay\" \u002F>\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n### Our Sponsors\n\nA huge thank you to all our sponsors for their generous support!\n\n\n- [AIHubmix](https:\u002F\u002Faihubmix.com\u002F)\n- [BurnCloud](https:\u002F\u002Fai.burncloud.com)\n- [302.AI](https:\u002F\u002Fshare.302.ai\u002FZGVF9w)\n- [Z智谱](https:\u002F\u002Fwww.bigmodel.cn\u002Fclaude-code?ic=FPF9IVAGFJ)\n- @Simon Leischnig\n- [@duanshuaimin](https:\u002F\u002Fgithub.com\u002Fduanshuaimin)\n- [@vrgitadmin](https:\u002F\u002Fgithub.com\u002Fvrgitadmin)\n- @\\*o\n- [@ceilwoo](https:\u002F\u002Fgithub.com\u002Fceilwoo)\n- @\\*说\n- @\\*更\n- @K\\*g\n- @R\\*R\n- [@bobleer](https:\u002F\u002Fgithub.com\u002Fbobleer)\n- @\\*苗\n- @\\*划\n- [@Clarence-pan](https:\u002F\u002Fgithub.com\u002FClarence-pan)\n- [@carter003](https:\u002F\u002Fgithub.com\u002Fcarter003)\n- @S\\*r\n- @\\*晖\n- @\\*敏\n- @Z\\*z\n- @\\*然\n- [@cluic](https:\u002F\u002Fgithub.com\u002Fcluic)\n- @\\*苗\n- [@PromptExpert](https:\u002F\u002Fgithub.com\u002FPromptExpert)\n- @\\*应\n- [@yusnake](https:\u002F\u002Fgithub.com\u002Fyusnake)\n- @\\*飞\n- @董\\*\n- @\\*汀\n- @\\*涯\n- @\\*:-）\n- @\\*\\*磊\n- @\\*琢\n- @\\*成\n- @Z\\*o\n- @\\*琨\n- [@congzhangzh](https:\u002F\u002Fgithub.com\u002Fcongzhangzh)\n- @\\*\\_\n- @Z\\*m\n- @*鑫\n- @c\\*y\n- @\\*昕\n- [@witsice](https:\u002F\u002Fgithub.com\u002Fwitsice)\n- @b\\*g\n- @\\*亿\n- @\\*辉\n- @JACK\n- @\\*光\n- @W\\*l\n- [@kesku](https:\u002F\u002Fgithub.com\u002Fkesku)\n- [@biguncle](https:\u002F\u002Fgithub.com\u002Fbiguncle)\n- @二吉吉\n- @a\\*g\n- @\\*林\n- @\\*咸\n- @\\*明\n- @S\\*y\n- @f\\*o\n- @\\*智\n- @F\\*t\n- @r\\*c\n- [@qierkang](http:\u002F\u002Fgithub.com\u002Fqierkang)\n- @\\*军\n- [@snrise-z](http:\u002F\u002Fgithub.com\u002Fsnrise-z)\n- @\\*王\n- [@greatheart1000](http:\u002F\u002Fgithub.com\u002Fgreatheart1000)\n- @\\*王\n- @zcutlip\n- [@Peng-YM](http:\u002F\u002Fgithub.com\u002FPeng-YM)\n- @\\*更\n- @\\*.\n- @F\\*t\n- @\\*政\n- @\\*铭\n- @\\*叶\n- @七\\*o\n- @\\*青\n- @\\*\\*晨\n- @\\*远\n- @\\*霄\n- @\\*\\*吉\n- @\\*\\*飞\n- @\\*\\*驰\n- @x\\*g\n- @\\*\\*东\n- @\\*落\n- @哆\\*k\n- @\\*涛\n- [@苗大](https:\u002F\u002Fgithub.com\u002FWitMiao)\n- @\\*呢\n- @\\d*u\n- @crizcraig\n- s\\*s\n- \\*火\n- \\*勤\n- \\*\\*锟\n- \\*涛\n- \\*\\*明\n- \\*知\n- \\*语\n- \\*瓜\n\n\n(If your name is masked, please contact me via my homepage email to update it with your GitHub username.)\n","![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_4f20b13b9b86.png)\n\n[![](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002F%F0%9F%87%A8%F0%9F%87%B3-%E4%B8%AD%E6%96%87%E7%89%88-ff0000?style=flat)](README_zh.md)\n[![Discord](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDiscord-%235865F2.svg?&logo=discord&logoColor=white)](https:\u002F\u002Fdiscord.gg\u002FrdftVMaUcS)\n[![](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Flicense\u002Fmusistudio\u002Fclaude-code-router)](https:\u002F\u002Fgithub.com\u002Fmusistudio\u002Fclaude-code-router\u002Fblob\u002Fmain\u002FLICENSE)\n\n\u003Chr>\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_9d4a89ff62b5.jpg)\n> 本项目由Z.ai赞助，他们通过GLM CODING PLAN计划支持我们。\n\n> GLM CODING PLAN是一项专为AI编码设计的订阅服务，每月仅需10美元起。它让开发者能够使用其旗舰模型GLM-4.7及（GLM-5仅供Pro用户使用）在10余款热门AI编码工具中进行开发，提供顶级、快速且稳定的编码体验。\n\n> GLM CODING PLAN享受10%折扣：https:\u002F\u002Fz.ai\u002Fsubscribe?ic=8JVLJQFSKB  \n\n> [从CLI工具风格视角看智能体工具的渐进式披露](\u002Fblog\u002Fen\u002Fprogressive-disclosure-of-agent-tools-from-the-perspective-of-cli-tool-style.md)\n\n> 一款强大的工具，可将Claude Code请求路由到不同模型，并自定义任何请求。\n\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_d3ac566941e2.png)\n\n## ✨ 功能\n\n- **模型路由**：根据需求将请求路由到不同模型（如后台任务、思考、长上下文等）。\n- **多提供商支持**：支持OpenRouter、DeepSeek、Ollama、Gemini、Volcengine和SiliconFlow等多种模型提供商。\n- **请求\u002F响应转换**：使用转换器为不同提供商自定义请求和响应。\n- **动态模型切换**：在Claude Code中使用`\u002Fmodel`命令实时切换模型。\n- **CLI模型管理**：通过`ccr model`直接在终端管理模型和提供商。\n- **GitHub Actions集成**：在GitHub工作流中触发Claude Code任务。\n- **插件系统**：通过自定义转换器扩展功能。\n\n## 🚀 快速上手\n\n### 1. 安装\n\n首先，请确保已安装[Claude Code](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fquickstart)：\n\n```shell\nnpm install -g @anthropic-ai\u002Fclaude-code\n```\n\n然后，安装Claude Code Router：\n\n```shell\nnpm install -g @musistudio\u002Fclaude-code-router\n```\n\n### 2. 配置\n\n创建并配置你的 `~\u002F.claude-code-router\u002Fconfig.json` 文件。更多详细信息，请参考 `config.example.json`。\n\n`config.json` 文件包含几个关键部分：\n\n- **`PROXY_URL`**（可选）：你可以为 API 请求设置代理，例如：`\"PROXY_URL\": \"http:\u002F\u002F127.0.0.1:7890\"`。\n- **`LOG`**（可选）：通过将其设置为 `true` 可以启用日志记录。当设置为 `false` 时，将不会创建任何日志文件。默认值为 `true`。\n- **`LOG_LEVEL`**（可选）：设置日志级别。可用选项包括：`\"fatal\"`、`\"error\"`、`\"warn\"`、`\"info\"`、`\"debug\"`、`\"trace\"`。默认值为 `\"debug\"`。\n- **日志系统**：Claude Code Router 使用两种独立的日志系统：\n  - **服务器级日志**：HTTP 请求、API 调用和服务器事件会使用 pino 记录在 `~\u002F.claude-code-router\u002Flogs\u002F` 目录下，文件名为 `ccr-*.log` 等。\n  - **应用级日志**：路由决策和业务逻辑事件会记录在 `~\u002F.claude-code-router\u002Fclaude-code-router.log` 中。\n- **`APIKEY`**（可选）：你可以设置一个密钥来验证请求。当设置后，客户端必须在 `Authorization` 头部（例如 `Bearer your-secret-key`）或 `x-api-key` 头部中提供该密钥。示例：`\"APIKEY\": \"your-secret-key\"`。\n- **`HOST`**（可选）：你可以设置服务器的主机地址。如果未设置 `APIKEY`，出于安全考虑，主机将被强制设置为 `127.0.0.1`，以防止未经授权的访问。示例：`\"HOST\": \"0.0.0.0\"`。\n- **`NON_INTERACTIVE_MODE`**（可选）：当设置为 `true` 时，可与非交互式环境兼容，如 GitHub Actions、Docker 容器或其他 CI\u002FCD 系统。这会设置适当的环境变量（`CI=true`、`FORCE_COLOR=0` 等），并配置标准输入处理，以防止进程在自动化环境中挂起。示例：`\"NON_INTERACTIVE_MODE\": true`。\n\n- **`Providers`**：用于配置不同的模型提供商。\n- **`Router`**：用于设置路由规则。`default` 指定默认模型，如果没有其他路由配置，则所有请求都将使用该模型。\n- **`API_TIMEOUT_MS`**：指定 API 调用的超时时间，单位为毫秒。\n\n#### 环境变量插值\n\nClaude Code Router 支持环境变量插值，以便安全地管理 API 密钥。你可以在 `config.json` 中使用 `$VAR_NAME` 或 `${VAR_NAME}` 语法引用环境变量：\n\n```json\n{\n  \"OPENAI_API_KEY\": \"$OPENAI_API_KEY\",\n  \"GEMINI_API_KEY\": \"${GEMINI_API_KEY}\",\n  \"Providers\": [\n    {\n      \"name\": \"openai\",\n      \"api_base_url\": \"https:\u002F\u002Fapi.openai.com\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"$OPENAI_API_KEY\",\n      \"models\": [\"gpt-5\", \"gpt-5-mini\"]\n    }\n  ]\n}\n```\n\n这样可以将敏感的 API 密钥保存在环境变量中，而不是硬编码到配置文件中。插值功能会递归地应用于嵌套的对象和数组。\n\n以下是一个完整的示例：\n\n```json\n{\n  \"APIKEY\": \"your-secret-key\",\n  \"PROXY_URL\": \"http:\u002F\u002F127.0.0.1:7890\",\n  \"LOG\": true,\n  \"API_TIMEOUT_MS\": 600000,\n  \"NON_INTERACTIVE_MODE\": false,\n  \"Providers\": [\n    {\n      \"name\": \"openrouter\",\n      \"api_base_url\": \"https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\n        \"google\u002Fgemini-2.5-pro-preview\",\n        \"anthropic\u002Fclaude-sonnet-4\",\n        \"anthropic\u002Fclaude-3.5-sonnet\",\n        \"anthropic\u002Fclaude-3.7-sonnet:thinking\"\n      ],\n      \"transformer\": {\n        \"use\": [\"openrouter\"]\n      }\n    },\n    {\n      \"name\": \"deepseek\",\n      \"api_base_url\": \"https:\u002F\u002Fapi.deepseek.com\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\"deepseek-chat\", \"deepseek-reasoner\"],\n      \"transformer\": {\n        \"use\": [\"deepseek\"],\n        \"deepseek-chat\": {\n          \"use\": [\"tooluse\"]\n        }\n      }\n    },\n    {\n      \"name\": \"ollama\",\n      \"api_base_url\": \"http:\u002F\u002Flocalhost:11434\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"ollama\",\n      \"models\": [\"qwen2.5-coder:latest\"]\n    },\n    {\n      \"name\": \"gemini\",\n      \"api_base_url\": \"https:\u002F\u002Fgenerativelanguage.googleapis.com\u002Fv1beta\u002Fmodels\u002F\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\"gemini-2.5-flash\", \"gemini-2.5-pro\"],\n      \"transformer\": {\n        \"use\": [\"gemini\"]\n      }\n    },\n    {\n      \"name\": \"volcengine\",\n      \"api_base_url\": \"https:\u002F\u002Fark.cn-beijing.volces.com\u002Fapi\u002Fv3\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-xxx\",\n      \"models\": [\"deepseek-v3-250324\", \"deepseek-r1-250528\"],\n      \"transformer\": {\n        \"use\": [\"deepseek\"]\n      }\n    },\n    {\n      \"name\": \"modelscope\",\n      \"api_base_url\": \"https:\u002F\u002Fapi-inference.modelscope.cn\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"\",\n      \"models\": [\"Qwen\u002FQwen3-Coder-480B-A35B-Instruct\", \"Qwen\u002FQwen3-235B-A22B-Thinking-2507\"],\n      \"transformer\": {\n        \"use\": [\n          [\n            \"maxtoken\",\n            {\n              \"max_tokens\": 65536\n            }\n          ],\n          \"enhancetool\"\n        ],\n        \"Qwen\u002FQwen3-235B-A22B-Thinking-2507\": {\n          \"use\": [\"reasoning\"]\n        }\n      }\n    },\n    {\n      \"name\": \"dashscope\",\n      \"api_base_url\": \"https:\u002F\u002Fdashscope.aliyuncs.com\u002Fcompatible-mode\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"\",\n      \"models\": [\"qwen3-coder-plus\"],\n      \"transformer\": {\n        \"use\": [\n          [\n            \"maxtoken\",\n            {\n              \"max_tokens\": 65536\n            }\n          ],\n          \"enhancetool\"\n        ]\n      }\n    },\n    {\n      \"name\": \"aihubmix\",\n      \"api_base_url\": \"https:\u002F\u002Faihubmix.com\u002Fv1\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-\",\n      \"models\": [\n        \"Z\u002Fglm-4.5\",\n        \"claude-opus-4-20250514\",\n        \"gemini-2.5-pro\"\n      ]\n    }\n  ],\n  \"Router\": {\n    \"default\": \"deepseek,deepseek-chat\",\n    \"background\": \"ollama,qwen2.5-coder:latest\",\n    \"think\": \"deepseek,deepseek-reasoner\",\n    \"longContext\": \"openrouter,google\u002Fgemini-2.5-pro-preview\",\n    \"longContextThreshold\": 60000,\n    \"webSearch\": \"gemini,gemini-2.5-flash\"\n  }\n}\n```\n\n### 3. 使用路由器运行 Claude Code\n\n使用路由器启动 Claude Code：\n\n```shell\nccr code\n```\n\n> **注意**：修改配置文件后，需要重启服务才能使更改生效：\n>\n> ```shell\n> ccr restart\n> ```\n\n### 4. UI 模式\n\n为了获得更直观的体验，你可以使用 UI 模式来管理你的配置：\n\n```shell\nccr ui\n```\n\n这将打开一个基于 Web 的界面，你可以在其中轻松查看和编辑你的 `config.json` 文件。\n\n![UI](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_74f0c7cfe791.png)\n\n### 5. CLI 模型管理\n\n对于喜欢使用终端工作流的用户，可以使用交互式的 CLI 模型选择器：\n\n```shell\nccr model\n```\n![](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_2e3d5dd36362.gif)\n\n该命令提供了一个交互式界面，用于：\n\n- 查看当前配置：\n- 查看所有已配置的模型（默认、背景、思考、长上下文、网页搜索、图像）\n- 切换模型：快速更改每种路由器类型所使用的模型\n- 添加新模型：将模型添加到现有提供商\n- 创建新提供商：设置完整的提供商配置，包括：\n   - 提供商名称和 API 端点\n   - API 密钥\n   - 可用模型\n   - 转换器配置，支持：\n     - 多个转换器（openrouter、deepseek、gemini 等）\n     - 转换器选项（例如，带有自定义限制的 maxtoken）\n     - 特定提供商的路由规则（例如，OpenRouter 提供商偏好）\n\nCLI 工具会验证所有输入，并提供有用的提示来引导您完成配置过程，从而轻松管理复杂的设置，而无需手动编辑 JSON 文件。\n\n### 6. 预设管理\n\n预设允许您轻松保存、共享和重复使用配置。您可以将当前配置导出为预设，并从文件或 URL 安装预设。\n\n```shell\n# 将当前配置导出为预设\nccr preset export my-preset\n\n# 带元数据导出\nccr preset export my-preset --description \"我的 OpenAI 配置\" --author \"您的姓名\" --tags \"openai,production\"\n\n# 从本地目录安装预设\nccr preset install \u002Fpath\u002Fto\u002Fpreset\n\n# 列出所有已安装的预设\nccr preset list\n\n# 显示预设信息\nccr preset info my-preset\n\n# 删除预设\nccr preset delete my-preset\n```\n\n**预设功能：**\n- **导出**：将当前配置保存为预设目录（包含 manifest.json）\n- **安装**：从本地目录安装预设\n- **敏感数据处理**：API 密钥和其他敏感数据在导出时会自动被屏蔽（标记为 `{{field}}` 占位符）\n- **动态配置**：预设可以包含输入模式，以便在安装时收集所需信息\n- **版本控制**：每个预设都包含版本元数据，用于跟踪更新\n\n**预设文件结构：**\n```\n~\u002F.claude-code-router\u002Fpresets\u002F\n├── my-preset\u002F\n│   └── manifest.json    # 包含配置和元数据\n```\n\n### 7. 激活命令（环境变量设置）\n\n`activate` 命令允许您在 shell 中全局设置环境变量，从而使您可以直接使用 `claude` 命令，或将 Claude Code Router 与使用 Agent SDK 构建的应用程序集成。\n\n要激活环境变量，请运行：\n\n```shell\neval \"$(ccr activate)\"\n```\n\n该命令会以适合 shell 的格式输出必要的环境变量，然后在当前 shell 会话中进行设置。激活后，您可以：\n\n- **直接使用 `claude` 命令**：无需使用 `ccr code` 即可运行 `claude` 命令。`claude` 命令将自动通过 Claude Code Router 路由请求。\n- **与 Agent SDK 应用程序集成**：使用 Anthropic Agent SDK 构建的应用程序将自动使用已配置的路由器和模型。\n\n`activate` 命令会设置以下环境变量：\n\n- `ANTHROPIC_AUTH_TOKEN`：来自您的配置的 API 密钥\n- `ANTHROPIC_BASE_URL`：本地路由器端点（默认：`http:\u002F\u002F127.0.0.1:3456`）\n- `NO_PROXY`：设置为 `127.0.0.1`，以防止代理干扰\n- `DISABLE_TELEMETRY`：禁用遥测\n- `DISABLE_COST_WARNINGS`：禁用成本警告\n- `API_TIMEOUT_MS`：来自您的配置的 API 超时时间\n\n> **注意**：在使用激活后的环境变量之前，请确保 Claude Code Router 服务正在运行（`ccr start`）。这些环境变量仅对当前 shell 会话有效。如需使其持久化，可将 `eval \"$(ccr activate)\"` 添加到您的 shell 配置文件中（例如 `~\u002F.zshrc` 或 `~\u002F.bashrc`）。\n\n#### 提供商\n\n`Providers` 数组是您定义要使用的不同模型提供商的地方。每个提供商对象需要：\n\n- `name`：提供商的唯一名称。\n- `api_base_url`：聊天完成的完整 API 端点。\n- `api_key`：您对该提供商的 API 密钥。\n- `models`：该提供商可用的模型列表。\n- `transformer`（可选）：指定用于处理请求和响应的转换器。\n\n#### 转换器\n\n转换器允许您修改请求和响应负载，以确保与不同提供商 API 的兼容性。\n\n- **全局转换器**：将转换器应用于提供商的所有模型。在此示例中，`openrouter` 转换器被应用于 `openrouter` 提供商下的所有模型。\n  ```json\n  {\n    \"name\": \"openrouter\",\n    \"api_base_url\": \"https:\u002F\u002Fopenrouter.ai\u002Fapi\u002Fv1\u002Fchat\u002Fcompletions\",\n    \"api_key\": \"sk-xxx\",\n    \"models\": [\n      \"google\u002Fgemini-2.5-pro-preview\",\n      \"anthropic\u002Fclaude-sonnet-4\",\n      \"anthropic\u002Fclaude-3.5-sonnet\"\n    ],\n    \"transformer\": { \"use\": [\"openrouter\"] }\n  }\n  ```\n- **特定模型转换器**：将转换器应用于特定模型。在此示例中，`deepseek` 转换器被应用于所有模型，而额外的 `tooluse` 转换器仅应用于 `deepseek-chat` 模型。\n  ```json\n  {\n    \"name\": \"deepseek\",\n    \"api_base_url\": \"https:\u002F\u002Fapi.deepseek.com\u002Fchat\u002Fcompletions\",\n    \"api_key\": \"sk-xxx\",\n    \"models\": [\"deepseek-chat\", \"deepseek-reasoner\"],\n    \"transformer\": {\n      \"use\": [\"deepseek\"],\n      \"deepseek-chat\": { \"use\": [\"tooluse\"] }\n    }\n  }\n  ```\n- **向转换器传递选项**：某些转换器，如 `maxtoken`，接受选项。要传递选项，可以使用嵌套数组，其中第一个元素是转换器名称，第二个元素是选项对象。\n  ```json\n  {\n    \"name\": \"siliconflow\",\n    \"api_base_url\": \"https:\u002F\u002Fapi.siliconflow.cn\u002Fv1\u002Fchat\u002Fcompletions\",\n    \"api_key\": \"sk-xxx\",\n    \"models\": [\"moonshotai\u002FKimi-K2-Instruct\"],\n    \"transformer\": {\n      \"use\": [\n        [\n          \"maxtoken\",\n          {\n            \"max_tokens\": 16384\n          }\n        ]\n      ]\n    }\n  }\n  ```\n\n**可用的内置转换器：**\n\n- `Anthropic`：如果仅使用 `Anthropic` 转换器，它将保留原始的请求和响应参数（你可以直接用它连接到 Anthropic 的 API 端点）。\n- `deepseek`：为 DeepSeek API 适配请求\u002F响应。\n- `gemini`：为 Gemini API 适配请求\u002F响应。\n- `openrouter`：为 OpenRouter API 适配请求\u002F响应。它还可以接受一个 `provider` 路由参数，以指定 OpenRouter 应该使用哪些底层提供商。更多详情请参阅 [OpenRouter 文档](https:\u002F\u002Fopenrouter.ai\u002Fdocs\u002Ffeatures\u002Fprovider-routing)。示例如下：\n  ```json\n    \"transformer\": {\n      \"use\": [\"openrouter\"],\n      \"moonshotai\u002Fkimi-k2\": {\n        \"use\": [\n          [\n            \"openrouter\",\n            {\n              \"provider\": {\n                \"only\": [\"moonshotai\u002Ffp8\"]\n              }\n            }\n          ]\n        ]\n      }\n    }\n  ```\n- `groq`：为 groq API 适配请求\u002F响应。\n- `maxtoken`：设置特定的 `max_tokens` 值。\n- `tooluse`：通过 `tool_choice` 优化某些模型的工具使用。\n- `gemini-cli`（实验性）：通过 Gemini CLI [gemini-cli.js](https:\u002F\u002Fgist.github.com\u002Fmusistudio\u002F1c13a65f35916a7ab690649d3df8d1cd) 对 Gemini 提供非官方支持。\n- `reasoning`：用于处理 `reasoning_content` 字段。\n- `sampling`：用于处理采样相关字段，如 `temperature`、`top_p`、`top_k` 和 `repetition_penalty`。\n- `enhancetool`：为 LLM 返回的工具调用参数增加一层容错机制（这会导致工具调用信息不再以流式传输）。\n- `cleancache`：从请求中清除 `cache_control` 字段。\n- `vertex-gemini`：使用 Vertex 认证来处理 Gemini API。\n- `chutes-glm`：通过 Chutes [chutes-glm-transformer.js](https:\u002F\u002Fgist.github.com\u002Fvitobotta\u002F2be3f33722e05e8d4f9d2b0138b8c863) 对 GLM 4.5 模型提供非官方支持。\n- `qwen-cli`（实验性）：通过 Qwen CLI [qwen-cli.js](https:\u002F\u002Fgist.github.com\u002Fmusistudio\u002Ff5a67841ced39912fd99e42200d5ca8b) 对 qwen3-coder-plus 模型提供非官方支持。\n- `rovo-cli`（实验性）：通过 Atlassian Rovo Dev CLI [rovo-cli.js](https:\u002F\u002Fgist.github.com\u002FSaseQ\u002Fc2a20a38b11276537ec5332d1f7a5e53) 对 gpt-5 提供非官方支持。\n\n**自定义转换器：**\n\n你也可以创建自己的转换器，并通过 `config.json` 中的 `transformers` 字段加载它们。\n\n```json\n{\n  \"transformers\": [\n    {\n      \"path\": \"\u002FUser\u002Fxxx\u002F.claude-code-router\u002Fplugins\u002Fgemini-cli.js\",\n      \"options\": {\n        \"project\": \"xxx\"\n      }\n    }\n  ]\n}\n```\n\n#### 路由器\n\n`Router` 对象定义了在不同场景下应使用的模型：\n\n- `default`：通用任务的默认模型。\n- `background`：后台任务使用的模型。这可以是一个较小的本地模型，以节省成本。\n- `think`：用于推理密集型任务的模型，比如计划模式。\n- `longContext`：用于处理长上下文的模型（例如超过 60K 个 token）。\n- `longContextThreshold`（可选）：触发长上下文模型的 token 数阈值。若未指定，则默认为 60000。\n- `webSearch`：用于处理网络搜索任务，这需要模型本身支持该功能。如果你使用 openrouter，则需要在模型名称后添加 `:online` 后缀。\n- `image`（测试版）：用于处理图像相关任务（由 CCR 内置代理支持）。如果模型不支持工具调用，则需要将 `config.forceUseImageAgent` 属性设置为 `true`。\n\n你还可以在 Claude Code 中使用 `\u002Fmodel` 命令动态切换模型：\n`\u002Fmodel provider_name,model_name`\n示例：`\u002Fmodel openrouter,anthropic\u002Fclaude-3.5-sonnet`\n\n#### 自定义路由器\n\n对于更高级的路由逻辑，你可以在 `config.json` 中通过 `CUSTOM_ROUTER_PATH` 指定自定义路由器脚本。这允许你实现超出默认场景的复杂路由规则。\n\n在你的 `config.json` 中：\n\n```json\n{\n  \"CUSTOM_ROUTER_PATH\": \"\u002FUser\u002Fxxx\u002F.claude-code-router\u002Fcustom-router.js\"\n}\n```\n\n自定义路由器文件必须是一个导出 `async` 函数的 JavaScript 模块。该函数接收请求对象和配置对象作为参数，并应返回一个字符串形式的提供者和模型名称（例如 `\"provider_name,model_name\"`），或返回 `null` 以回退到默认路由器。\n\n以下是一个基于 `custom-router.example.js` 的 `custom-router.js` 示例：\n\n```javascript\n\u002F\u002F \u002FUser\u002Fxxx\u002F.claude-code-router\u002Fcustom-router.js\n\n\u002F**\n * 自定义路由器函数，根据请求决定使用哪个模型。\n *\n * @param {object} req - 来自 Claude Code 的请求对象，包含请求体。\n * @param {object} config - 应用程序的配置对象。\n * @returns {Promise\u003Cstring|null>} - 一个 Promise，解析为“provider,model_name”字符串，或返回 null 以使用默认路由器。\n *\u002F\nmodule.exports = async function router(req, config) {\n  const userMessage = req.body.messages.find((m) => m.role === \"user\")?.content;\n\n  if (userMessage && userMessage.includes(\"explain this code\")) {\n    \u002F\u002F 使用强大的模型进行代码解释\n    return \"openrouter,anthropic\u002Fclaude-3.5-sonnet\";\n  }\n\n  \u002F\u002F 回退到默认的路由器配置\n  return null;\n};\n```\n\n##### 子代理路由\n\n对于子代理内的路由，你必须在子代理提示的**开头**包含 `\u003CCCR-SUBAGENT-MODEL>provider,model\u003C\u002FCCR-SUBAGENT-MODEL>`，以指定特定的提供者和模型。这样可以将特定的子代理任务定向到指定的模型。\n\n**示例：**\n\n```\n\u003CCCR-SUBAGENT-MODEL>openrouter,anthropic\u002Fclaude-3.5-sonnet\u003C\u002FCCR-SUBAGENT-MODEL>\n请帮我分析这段代码，看看是否有优化的空间……\n```\n\n\n\n## 状态栏（测试版）\n为了更好地监控 claude-code-router 运行时的状态，v1.0.40 版本内置了一个状态栏工具，你可以在 UI 中启用它。\n![statusline-config.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_8f6758cde6ec.png)\n\n效果如下：\n![statusline](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_9105aa42adda.png)\n\n## 🤖 GitHub Actions\n\n将 Claude Code Router 集成到您的 CI\u002FCD 流水线中。在设置好 [Claude Code Actions](https:\u002F\u002Fdocs.anthropic.com\u002Fen\u002Fdocs\u002Fclaude-code\u002Fgithub-actions) 后，修改您的 `.github\u002Fworkflows\u002Fclaude.yaml` 文件以使用该路由器：\n\n```yaml\nname: Claude Code\n\non:\n  issue_comment:\n    types: [created]\n  # ... 其他触发条件\n\njobs:\n  claude:\n    if: |\n      (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||\n      # ... 其他条件\n    runs-on: ubuntu-latest\n    permissions:\n      contents: read\n      pull-requests: read\n      issues: read\n      id-token: write\n    steps:\n      - name: 检出仓库\n        uses: actions\u002Fcheckout@v4\n        with:\n          fetch-depth: 1\n\n      - name: 准备环境\n        run: |\n          curl -fsSL https:\u002F\u002Fbun.sh\u002Finstall | bash\n          mkdir -p $HOME\u002F.claude-code-router\n          cat \u003C\u003C 'EOF' > $HOME\u002F.claude-code-router\u002Fconfig.json\n          {\n            \"log\": true,\n            \"NON_INTERACTIVE_MODE\": true,\n            \"OPENAI_API_KEY\": \"${{ secrets.OPENAI_API_KEY }}\",\n            \"OPENAI_BASE_URL\": \"https:\u002F\u002Fapi.deepseek.com\",\n            \"OPENAI_MODEL\": \"deepseek-chat\"\n          }\n          EOF\n        shell: bash\n\n      - name: 启动 Claude Code Router\n        run: |\n          nohup ~\u002F.bun\u002Fbin\u002Fbunx @musistudio\u002Fclaude-code-router@1.0.8 start &\n        shell: bash\n\n      - name: 运行 Claude Code\n        id: claude\n        uses: anthropics\u002Fclaude-code-action@beta\n        env:\n          ANTHROPIC_BASE_URL: http:\u002F\u002Flocalhost:3456\n        with:\n          anthropic_api_key: \"any-string-is-ok\"\n```\n\n> **注意**：在 GitHub Actions 或其他自动化环境中运行时，请确保在配置中设置 `\"NON_INTERACTIVE_MODE\": true`，以防止因标准输入处理问题而导致进程挂起。\n\n此设置允许实现一些有趣的自动化任务，例如在非高峰时段运行任务以降低 API 成本。\n\n## 📝 更多阅读\n\n- [项目动机与工作原理](blog\u002Fen\u002Fproject-motivation-and-how-it-works.md)\n- [也许我们可以用这个路由器做更多事情](blog\u002Fen\u002Fmaybe-we-can-do-more-with-the-route.md)\n- [GLM-4.6 支持推理与交错式思考](blog\u002Fen\u002Fglm-4.6-supports-reasoning.md)\n\n## ❤️ 支持与赞助\n\n如果您觉得这个项目很有帮助，请考虑赞助它的开发。您的支持将不胜感激！\n\n[![ko-fi](https:\u002F\u002Fko-fi.com\u002Fimg\u002Fgithubbutton_sm.svg)](https:\u002F\u002Fko-fi.com\u002FF1F31GN2GM)\n\n[Paypal](https:\u002F\u002Fpaypal.me\u002Fmusistudio1999)\n\n\u003Ctable>\n  \u003Ctr>\n    \u003Ctd>\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_8c5d6426ecb4.jpg\" width=\"200\" alt=\"支付宝\" \u002F>\u003C\u002Ftd>\n    \u003Ctd>\u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_readme_5a1bb8ef6f18.jpg\" width=\"200\" alt=\"微信支付\" \u002F>\u003C\u002Ftd>\n  \u003C\u002Ftr>\n\u003C\u002Ftable>\n\n### 我们的赞助者\n\n衷心感谢所有赞助者的慷慨支持！\n\n\n- [AIHubmix](https:\u002F\u002Faihubmix.com\u002F)\n- [BurnCloud](https:\u002F\u002Fai.burncloud.com)\n- [302.AI](https:\u002F\u002Fshare.302.ai\u002FZGVF9w)\n- [Z智谱](https:\u002F\u002Fwww.bigmodel.cn\u002Fclaude-code?ic=FPF9IVAGFJ)\n- @Simon Leischnig\n- [@duanshuaimin](https:\u002F\u002Fgithub.com\u002Fduanshuaimin)\n- [@vrgitadmin](https:\u002F\u002Fgithub.com\u002Fvrgitadmin)\n- @\\*o\n- [@ceilwoo](https:\u002F\u002Fgithub.com\u002Fceilwoo)\n- @\\*说\n- @\\*更\n- @K\\*g\n- @R\\*R\n- [@bobleer](https:\u002F\u002Fgithub.com\u002Fbobleer)\n- @\\*苗\n- @\\*划\n- [@Clarence-pan](https:\u002F\u002Fgithub.com\u002FClarence-pan)\n- [@carter003](https:\u002F\u002Fgithub.com\u002Fcarter003)\n- @S\\*r\n- @\\*晖\n- @\\*敏\n- @Z\\*z\n- @\\*然\n- [@cluic](https:\u002F\u002Fgithub.com\u002Fcluic)\n- @\\*苗\n- [@PromptExpert](https:\u002F\u002Fgithub.com\u002FPromptExpert)\n- @\\*应\n- [@yusnake](https:\u002F\u002Fgithub.com\u002Fyusnake)\n- @\\*飞\n- @董\\*\n- @\\*汀\n- @\\*涯\n- @\\*:-）\n- @\\*\\*磊\n- @\\*琢\n- @\\*成\n- @Z\\*o\n- @\\*琨\n- [@congzhangzh](https:\u002F\u002Fgithub.com\u002Fcongzhangzh)\n- @\\*\\_\n- @Z\\*m\n- @*鑫\n- @c\\*y\n- @\\*昕\n- [@witsice](https:\u002F\u002Fgithub.com\u002Fwitsice)\n- @b\\*g\n- @\\*亿\n- @\\*辉\n- @JACK\n- @\\*光\n- @W\\*l\n- [@kesku](https:\u002F\u002Fgithub.com\u002Fkesku)\n- [@biguncle](https:\u002F\u002Fgithub.com\u002Fbiguncle)\n- @二吉吉\n- @a\\*g\n- @\\*林\n- @\\*咸\n- @\\*明\n- @S\\*y\n- @f\\*o\n- @\\*智\n- @F\\*t\n- @r\\*c\n- [@qierkang](http:\u002F\u002Fgithub.com\u002Fqierkang)\n- @\\*军\n- [@snrise-z](http:\u002F\u002Fgithub.com\u002Fsnrise-z)\n- @\\*王\n- [@greatheart1000](http:\u002F\u002Fgithub.com\u002Fgreatheart1000)\n- @\\*王\n- @zcutlip\n- [@Peng-YM](http:\u002F\u002Fgithub.com\u002FPeng-YM)\n- @\\*更\n- @\\*.\n- @F\\*t\n- @\\*政\n- @\\*铭\n- @\\*叶\n- @七\\*o\n- @\\*青\n- @\\*\\*晨\n- @\\*远\n- @\\*霄\n- @\\*\\*吉\n- @\\*\\*飞\n- @\\*\\*驰\n- @x\\*g\n- @\\*\\*东\n- @\\*落\n- @哆\\*k\n- @\\*涛\n- [@苗大](https:\u002F\u002Fgithub.com\u002FWitMiao)\n- @\\*呢\n- @\\d*u\n- @crizcraig\n- s\\*s\n- \\*火\n- \\*勤\n- \\*\\*锟\n- \\*涛\n- \\*\\*明\n- \\*知\n- \\*语\n- \\*瓜\n\n\n（如果您的名字被遮挡，请通过我的主页邮箱联系我，以便用您的 GitHub 用户名更新。）","# Claude Code Router 快速上手指南\n\n`claude-code-router` 是一个强大的路由工具，允许你将 Claude Code 的请求动态分发到不同的 AI 模型提供商（如 OpenRouter, DeepSeek, Ollama, Gemini, 火山引擎等），并支持自定义请求转换和动态模型切换。\n\n## 环境准备\n\n在开始之前，请确保你的系统满足以下要求：\n\n*   **Node.js**: 需安装 Node.js (推荐 v18 或更高版本)，因为该工具基于 npm 分发。\n*   **Claude Code**: 必须先安装官方的 Claude Code CLI。\n*   **API Keys**: 准备好你所使用的模型提供商的 API Key（如 DeepSeek, OpenRouter, Google Gemini 等）。\n\n## 安装步骤\n\n### 1. 安装 Claude Code\n首先安装官方客户端：\n\n```shell\nnpm install -g @anthropic-ai\u002Fclaude-code\n```\n\n### 2. 安装 Claude Code Router\n接着安装路由工具：\n\n```shell\nnpm install -g @musistudio\u002Fclaude-code-router\n```\n\n> **提示**：如果下载速度较慢，可配置国内 npm 镜像源（如阿里云或腾讯云）后再执行安装命令：\n> `npm config set registry https:\u002F\u002Fregistry.npmmirror.com`\n\n## 基本使用\n\n### 1. 配置文件设置\n工具启动时需要读取配置文件。请在用户目录下创建配置文件夹及文件：\n\n```shell\nmkdir -p ~\u002F.claude-code-router\ntouch ~\u002F.claude-code-router\u002Fconfig.json\n```\n\n编辑 `~\u002F.claude-code-router\u002Fconfig.json`，填入基础配置。以下是一个最小化示例，展示了如何配置一个默认模型（以 DeepSeek 为例）：\n\n```json\n{\n  \"Providers\": [\n    {\n      \"name\": \"deepseek\",\n      \"api_base_url\": \"https:\u002F\u002Fapi.deepseek.com\u002Fchat\u002Fcompletions\",\n      \"api_key\": \"sk-your-deepseek-api-key\",\n      \"models\": [\"deepseek-chat\"]\n    }\n  ],\n  \"Router\": {\n    \"default\": \"deepseek,deepseek-chat\"\n  }\n}\n```\n\n> **安全提示**：建议将敏感信息（如 `api_key`）通过环境变量注入，或在配置中使用 `$ENV_VAR_NAME` 语法引用，避免硬编码在文件中。\n\n### 2. 启动服务\n配置完成后，使用以下命令启动带有路由功能的 Claude Code：\n\n```shell\nccr code\n```\n\n此时，你输入的指令将根据配置中的 `Router` 规则被发送到指定的模型。\n\n### 3. 动态切换模型 (可选)\n在对话过程中，你可以直接使用 `\u002Fmodel` 命令动态切换当前使用的模型，无需重启服务：\n\n```text\n\u002Fmodel deepseek,deepseek-reasoner\n```\n\n### 4. 图形化配置管理 (推荐)\n如果你不熟悉 JSON 配置，可以使用内置的 Web UI 进行可视化管理：\n\n```shell\nccr ui\n```\n运行后在浏览器打开显示的地址，即可直观地添加提供商、配置模型路由规则和管理 API Key。\n\n### 5. 使变更生效\n如果你手动修改了 `config.json` 文件，需要重启服务以应用新配置：\n\n```shell\nccr restart\n```","某全栈开发团队在构建微服务架构时，需要频繁调用 AI 辅助生成代码、编写单元测试及分析长日志，但面临模型成本高昂且响应速度不稳定的挑战。\n\n### 没有 claude-code-router 时\n- **成本与性能难以平衡**：所有任务（包括简单的语法检查）都强制使用昂贵的 Claude Opus 模型，导致 API 账单激增，而轻量级任务无需如此强大的算力。\n- **多模型切换繁琐**：当需要针对长上下文分析切换至 DeepSeek 或本地 Ollama 模型时，开发者必须手动修改环境变量或重启终端会话，打断心流。\n- **供应商锁定风险**：深度绑定单一提供商，一旦遇到网络波动或服务限流，整个团队的 AI 编码工作流即刻停摆，缺乏自动降级机制。\n- **定制化能力缺失**：无法根据不同任务类型（如“后台静默任务”或“即时交互”）动态调整请求参数，导致资源利用率低下。\n\n### 使用 claude-code-router 后\n- **智能路由降本增效**：配置规则让简单任务自动路由至低价的 DeepSeek 或本地模型，仅复杂推理才调用 Claude Opus，整体 API 成本降低 60%。\n- **终端内无缝热切换**：开发者直接在 Claude Code 终端输入 `\u002Fmodel` 命令即可实时切换后端模型，无需重启环境，保持开发节奏流畅。\n- **多源容错保障连续性**：同时接入 OpenRouter、SiliconFlow 等多个供应商，当主节点故障时自动故障转移，确保团队编码工作零中断。\n- **精细化请求定制**：利用 Transformer 插件针对不同场景自定义请求体，例如为长日志分析任务自动开启大上下文窗口，为代码补全任务优化延迟设置。\n\nclaude-code-router 通过灵活的路由策略和多模型管理能力，将原本僵化的单点 AI 依赖转化为低成本、高可用且可定制的智能编码基础设施。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fmusistudio_claude-code-router_d3ac5669.png","musistudio","musi","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fmusistudio_394ab771.jpg","Focusing on AI",null,"Hangzhou","779956774@qq.com","https:\u002F\u002Fgithub.com\u002Fmusistudio",[82,86,90,94,98,102],{"name":83,"color":84,"percentage":85},"TypeScript","#3178c6",96.2,{"name":87,"color":88,"percentage":89},"JavaScript","#f1e05a",2.3,{"name":91,"color":92,"percentage":93},"CSS","#663399",0.7,{"name":95,"color":96,"percentage":97},"Shell","#89e051",0.5,{"name":99,"color":100,"percentage":101},"Dockerfile","#384d54",0.2,{"name":103,"color":104,"percentage":105},"HTML","#e34c26",0,32156,2549,"2026-04-13T23:20:48","MIT","Linux, macOS, Windows","未说明",{"notes":113,"python":111,"dependencies":114},"该工具是基于 Node.js 的命令行工具，需先安装 Node.js 环境。核心依赖是官方的 Claude Code (@anthropic-ai\u002Fclaude-code)。配置通过 JSON 文件或交互式 CLI\u002FUI 界面管理，支持环境变量插值以保护 API 密钥。无需本地 GPU 或大模型文件，所有推理请求均路由至外部 API 提供商。",[115,116,117],"Node.js","@anthropic-ai\u002Fclaude-code","@musistudio\u002Fclaude-code-router",[35,13,52],"2026-03-27T02:49:30.150509","2026-04-14T12:30:14.459806",[],[]]