2025-03-31 22:28:02 +08:00
2025-03-31 22:28:02 +08:00
2025-03-31 22:28:02 +08:00
2025-03-25 14:51:28 +08:00
2025-02-26 14:41:20 +08:00
2025-03-25 14:51:28 +08:00
2025-03-25 14:51:28 +08:00
2025-03-31 22:28:02 +08:00
2025-03-25 14:51:28 +08:00

Claude Code Router

This is a repository for testing routing Claude Code requests to different models.

demo.png

Implemented

  • Support writing custom plugins for rewriting prompts.

  • Support writing custom plugins for implementing routers.

Usage

  1. Install Claude Code
npm install -g @anthropic-ai/claude-code
  1. Clone this repo and install dependencies
git clone https://github.com/musistudio/claude-code-router
cd claude-code-router && pnpm i
npm run build
  1. Start claude-code-router server
node dist/cli.js
  1. Set environment variable to start claude code
export DISABLE_PROMPT_CACHING=1
export ANTHROPIC_BASE_URL="http://127.0.0.1:3456"
export API_TIMEOUT_MS=600000
claude

Plugin

The plugin allows users to rewrite Claude Code prompt and custom router. The plugin path is in $HOME/.claude-code-router/plugins. Currently, there are two demos available:

  1. custom router
  2. rewrite prompt

You need to move them to the $HOME/.claude-code-router/plugins directory and configure 'usePlugin' in $HOME/.claude-code-router/config.jsonlike this:

{
    "usePlugin": "gemini",
    "LOG": true,
    "OPENAI_API_KEY": "",
    "OPENAI_BASE_URL": "",
    "OPENAI_MODEL": ""
}
Description
Use Claude Code as the foundation for coding infrastructure, allowing you to decide how to interact with the model while enjoying updates from Anthropic.
Readme MIT 30 MiB
Languages
TypeScript 95%
JavaScript 3.3%
CSS 1.6%