explaingit

musistudio/claude-code-router

34,122TypeScriptAudience · developerComplexity · 3/5MaintainedLicenseSetup · moderate

TLDR

A proxy that intercepts Claude Code requests and routes them to different AI providers and models based on rules you define, letting you use cheaper or alternative models while keeping Claude Code's familiar interface.

Mindmap

mindmap
  root((repo))
    What it does
      Intercepts Claude Code requests
      Routes to different AI providers
      Applies custom rules
      Translates API formats
    Supported providers
      OpenRouter
      DeepSeek
      Ollama local models
      Gemini
    Key features
      JSON config rules
      Slash command switching
      Cost optimization
      Local proxy server
    Use cases
      Reduce API costs
      Mix model strategies
      Experiment with backends
    Tech stack
      TypeScript
      Node.js
      npm package

Things people build with this

USE CASE 1

Reduce AI API costs by routing simple tasks to cheaper models while using powerful models only for complex reasoning.

USE CASE 2

Use AI providers and models not natively supported by Claude Code, such as local Ollama models or DeepSeek.

USE CASE 3

Experiment with different AI backends and compare their performance without changing your coding workflow or switching tools.

USE CASE 4

Switch between models on the fly during a coding session using slash commands without restarting Claude Code.

Tech stack

TypeScriptNode.jsnpm

Getting it running

Difficulty · moderate Time to first run · 30min

Requires configuring routing rules and API keys for target AI providers before the proxy can function.

Use freely for any purpose including commercial, as long as you keep the copyright notice.

In plain English

Claude Code Router is a proxy tool that sits between the Claude Code AI coding assistant (Anthropic's official CLI agent) and the AI model it calls. Rather than always sending requests to Anthropic's Claude models, this tool intercepts those requests and can route them to different AI providers and models based on rules you define, such as using a cheaper model for simple background tasks and a more powerful model for complex reasoning. The tool works by running a local server that Claude Code connects to instead of Anthropic's API directly. You configure routing rules in a JSON file specifying which model to use for different types of requests. It supports multiple providers including OpenRouter, DeepSeek, Ollama (for local models), Gemini, and others. Transformers, small plugins, handle differences in API format between providers, so Claude Code's request format gets translated to whatever each provider expects. Practically, this means a developer can use Claude Code's interface and workflow, which they are familiar with and which receives ongoing updates from Anthropic, while routing the underlying AI calls to different, potentially cheaper or faster models. A slash command within Claude Code also lets you switch models on the fly during a session. Someone would use this when they want to reduce AI API costs by mixing models strategically, when they want to use models from providers not natively supported by Claude Code, or when they want to experiment with different AI backends without changing their coding workflow. The tech stack is TypeScript/Node.js, installed as a global npm package. It requires Claude Code to already be installed.

Copy-paste prompts

Prompt 1
How do I set up Claude Code Router to route requests to OpenRouter and Ollama based on task complexity?
Prompt 2
Show me how to create a JSON routing rule that uses a cheaper model for background tasks and Claude 3.5 Sonnet for complex code generation.
Prompt 3
How do I install and configure Claude Code Router as a global npm package to work with my existing Claude Code setup?
Prompt 4
What transformers do I need to write to add support for a new AI provider to Claude Code Router?
Prompt 5
How can I use the slash command feature in Claude Code to switch between different routed models during a session?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.