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.

open-sourceagent-frameworks
Visit WebsiteView on GitHub
30.5k
Stars
+2546
Stars/month
0
Releases (6m)

Overview

Claude Code Router 是一个强大的路由工具,允许开发者以 Claude Code 为基础架构,将请求智能路由到不同的AI模型和提供商。该工具支持多达6个主要AI提供商(OpenRouter、DeepSeek、Ollama、Gemini、Volcengine、SiliconFlow),可根据任务类型(后台任务、深度思考、长上下文处理)动态选择最适合的模型。通过 `/model` 命令,用户可在 Claude Code 内实时切换模型,无需重启会话。该工具还提供了请求/响应转换器,支持自定义插件系统,并能与 GitHub Actions 集成,为CI/CD流程提供AI能力。拥有超过3万GitHub星标,是一个成熟且活跃的开源项目。

Pros

  • + 支持6个主要AI提供商的无缝切换,可根据任务需求选择最合适的模型
  • + 提供动态模型切换和CLI管理功能,操作简便且支持实时调整
  • + 可扩展的插件系统和请求转换器,允许深度定制和与现有工作流集成

Cons

  • - 需要依赖 Claude Code 作为基础框架,增加了环境配置复杂性
  • - 需要手动配置多个提供商的API密钥和参数设置
  • - 作为中间层可能引入额外的延迟和潜在的故障点

Use Cases

Getting Started

1. 安装依赖:先安装Claude Code (`npm install -g @anthropic-ai/claude-code`),再安装路由器 (`npm install -g @musistudio/claude-code-router`);2. 配置设置:创建 `~/.claude-code-router/config.json` 文件,添加各AI提供商的API密钥和路由规则;3. 开始使用:在Claude Code中使用 `/model` 命令切换模型,或通过 `ccr model` CLI命令管理模型配置。