claude-code-router
by
musistudio

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.

View musistudio/claude-code-router on GitHub ↗

Summary Information

Updated 1 hour ago
Added to GitGenius on July 16th, 2025
Created on February 25th, 2025
Open Issues/Pull Requests: 792 (+0)
Number of forks: 2,187
Total Stargazers: 28,290 (+11)
Total Subscribers: 107 (+0)
Detailed Description

Claude-Code-Router is an open-source project designed to intelligently route code-related requests to the most appropriate Large Language Model (LLM) – specifically focusing on Anthropic’s Claude models, but with extensibility in mind. It addresses the challenge that no single LLM excels at *all* coding tasks; some are better at specific languages, problem types, or require different context windows. The router aims to improve code generation, completion, and analysis quality by dynamically selecting the best Claude model for each incoming request.

At its core, the router operates by analyzing the input code and query using a series of “routers.” These routers are essentially classification models that determine the characteristics of the request. Currently, the repository features routers based on programming language detection (identifying Python, JavaScript, etc.), task type classification (e.g., code generation, bug fixing, explanation), and complexity estimation. The language detection router leverages a fastText model, while the task type router utilizes a fine-tuned BERT model. Complexity is assessed using a combination of code metrics like lines of code, cyclomatic complexity, and nesting depth. These features are combined to create a profile of the incoming request.

Based on this profile, the router then applies a set of configurable “rules” to determine which Claude model to use. These rules are defined in a YAML configuration file and allow users to map specific request characteristics to specific Claude models (e.g., Claude 3 Opus, Claude 3 Sonnet, Claude 3 Haiku). The rules can be based on any combination of the router outputs – language, task type, complexity, or even custom metrics that a user might add. This flexibility is a key strength of the project, allowing adaptation to different use cases and evolving LLM capabilities. The configuration also allows for specifying parameters like temperature, max tokens, and stop sequences for each model.

The project provides a simple API endpoint for receiving code requests. It accepts code and a natural language query, passes this input through the routers, applies the configured rules, and then forwards the request to the selected Claude model via the Anthropic API. The response from Claude is then returned to the user. The repository includes example scripts demonstrating how to interact with the API. Furthermore, it offers a basic web UI for testing and experimentation.

Beyond the core routing functionality, Claude-Code-Router includes features like request logging, rate limiting, and error handling. It’s designed to be easily integrated into existing workflows and can be deployed using Docker. The project is actively maintained and welcomes contributions, particularly in the areas of adding new routers, improving existing ones, and expanding the range of supported LLMs. The long-term vision is to create a robust and adaptable code routing system that can significantly enhance the performance and reliability of LLM-powered coding tools.

claude-code-router
by
musistudiomusistudio/claude-code-router

Repository Details

Fetching additional details & charts...