Files
claude-code-router/README.md
2025-03-31 22:28:02 +08:00

1.5 KiB
Raw Permalink Blame History

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": ""
}