Convert Figma logo to code with AI

musistudio logoclaude-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.

35,752
2,951
35,752
1,002

Top Related Projects

Integrate cutting-edge LLM technology quickly and easily into your apps

141,372

The agent engineering platform.

Examples and guides for using the OpenAI API

The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.

25,031

JARVIS, a system to connect LLMs with ML community. Paper: https://arxiv.org/pdf/2303.17580.pdf

Quick Overview

Claude Code Router is an open-source project that provides a simple and efficient way to route code snippets to different language models, including Claude and GPT. It aims to enhance the development workflow by allowing developers to seamlessly integrate AI-powered code assistance into their projects.

Pros

  • Easy integration with various language models
  • Supports multiple programming languages
  • Customizable routing logic
  • Lightweight and easy to set up

Cons

  • Limited documentation
  • Still in early development stages
  • May require additional configuration for complex use cases
  • Potential dependency on third-party APIs

Code Examples

Here are a few examples of how to use Claude Code Router:

  1. Basic routing setup:
from claude_code_router import CodeRouter

router = CodeRouter()
router.add_route("python", "claude")
router.add_route("javascript", "gpt")

result = router.route_code("print('Hello, World!')", "python")
print(result)  # Output: Claude's response for Python code
  1. Custom routing logic:
def custom_route(code, language):
    if "machine learning" in code.lower():
        return "claude"
    return "gpt"

router = CodeRouter(custom_routing_func=custom_route)
result = router.route_code("import tensorflow as tf", "python")
print(result)  # Output: Claude's response for machine learning code
  1. Handling multiple languages:
router = CodeRouter()
router.add_route("python", "claude")
router.add_route("javascript", "gpt")
router.add_route("java", "claude")

js_code = "console.log('Hello, World!');"
java_code = "System.out.println('Hello, World!');"

js_result = router.route_code(js_code, "javascript")
java_result = router.route_code(java_code, "java")

print(js_result)    # Output: GPT's response for JavaScript code
print(java_result)  # Output: Claude's response for Java code

Getting Started

To get started with Claude Code Router, follow these steps:

  1. Install the package:

    pip install claude-code-router
    
  2. Import and initialize the router:

    from claude_code_router import CodeRouter
    
    router = CodeRouter()
    
  3. Add routes for different languages:

    router.add_route("python", "claude")
    router.add_route("javascript", "gpt")
    
  4. Route code snippets:

    result = router.route_code("print('Hello, World!')", "python")
    print(result)
    

For more advanced usage and configuration options, refer to the project's documentation.

Competitor Comparisons

Integrate cutting-edge LLM technology quickly and easily into your apps

Pros of Semantic Kernel

  • More comprehensive framework for building AI applications
  • Extensive documentation and examples
  • Larger community and active development

Cons of Semantic Kernel

  • Steeper learning curve due to its complexity
  • Heavier resource requirements

Code Comparison

Claude Code Router:

@router.post("/generate")
async def generate(prompt: str):
    response = claude.complete(prompt)
    return {"response": response}

Semantic Kernel:

var kernel = Kernel.Builder.Build();
var result = await kernel.RunAsync("What is the capital of France?");
Console.WriteLine(result);

Key Differences

Claude Code Router is a lightweight API wrapper for Claude AI, focusing on simplicity and ease of use. It's ideal for quick integrations and prototyping.

Semantic Kernel is a more robust framework for building AI applications, offering advanced features like memory, planning, and plugin systems. It's better suited for complex, production-grade applications.

Claude Code Router is Python-based and centered around Claude AI, while Semantic Kernel is primarily C#-based and designed to work with multiple AI services.

Choose Claude Code Router for rapid development and simple Claude AI integrations. Opt for Semantic Kernel when building more sophisticated AI applications with advanced features and flexibility across different AI services.

141,372

The agent engineering platform.

Pros of LangChain

  • More comprehensive framework for building LLM applications
  • Larger community and ecosystem with extensive documentation
  • Supports multiple LLM providers and integrations

Cons of LangChain

  • Steeper learning curve due to its extensive features
  • Can be overkill for simpler projects
  • Requires more setup and configuration

Code Comparison

Claude Code Router:

from claude_code_router import ClaudeCodeRouter

router = ClaudeCodeRouter()
result = router.route("Generate a Python function to calculate factorial")
print(result)

LangChain:

from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate

llm = OpenAI()
prompt = PromptTemplate.from_template("Generate a Python function to calculate {task}")
result = llm(prompt.format(task="factorial"))
print(result)

Summary

LangChain offers a more comprehensive solution for building LLM applications with extensive features and integrations. However, it may be more complex for simple use cases. Claude Code Router provides a more straightforward approach for code-related tasks but with fewer features. The choice between the two depends on the project's complexity and specific requirements.

Examples and guides for using the OpenAI API

Pros of openai-cookbook

  • Comprehensive collection of examples and best practices for using OpenAI's APIs
  • Well-maintained and regularly updated by OpenAI's team
  • Covers a wide range of use cases and applications

Cons of openai-cookbook

  • Focused solely on OpenAI's products, limiting its applicability to other AI models
  • May be overwhelming for beginners due to its extensive content

Code comparison

openai-cookbook:

import openai

response = openai.Completion.create(
  engine="text-davinci-002",
  prompt="Translate the following English text to French: '{}'",
  max_tokens=60
)

claude-code-router:

from claude_code_router import ClaudeCodeRouter

router = ClaudeCodeRouter()
result = router.route_code("Translate the following English text to French: '{}'")

Summary

openai-cookbook is a comprehensive resource for working with OpenAI's APIs, offering a wide range of examples and best practices. It's well-maintained but focuses exclusively on OpenAI products. claude-code-router, on the other hand, is a specialized tool for routing code to Claude AI, providing a simpler interface for specific use cases. The choice between the two depends on the user's needs and the AI models they're working with.

The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.

Pros of chatgpt-retrieval-plugin

  • More comprehensive documentation and setup instructions
  • Supports multiple vector database options (Pinecone, Weaviate, Zilliz, Milvus, Qdrant)
  • Includes a FastAPI server for handling requests and responses

Cons of chatgpt-retrieval-plugin

  • More complex setup and configuration process
  • Requires additional dependencies and services to run
  • Focused specifically on ChatGPT integration, less flexible for other use cases

Code Comparison

claude-code-router:

def route_code(code: str) -> str:
    # Simple routing logic based on code content
    if "def " in code:
        return "python"
    elif "function " in code:
        return "javascript"
    else:
        return "unknown"

chatgpt-retrieval-plugin:

@app.post("/upsert")
async def upsert(
    request: Request,
    background_tasks: BackgroundTasks,
    metadata: Optional[Dict[str, str]] = None,
):
    # Complex upsert logic for vector database
    # ...

The code comparison shows that claude-code-router has a simpler, more focused approach to code routing, while chatgpt-retrieval-plugin involves more complex API endpoints and database interactions.

Pros of TaskMatrix

  • More comprehensive task management system with multiple agents and task decomposition
  • Supports a wider range of applications, including image processing and web browsing
  • More actively maintained with recent updates and contributions

Cons of TaskMatrix

  • More complex setup and configuration required
  • Potentially higher resource usage due to multiple agents and broader functionality
  • Steeper learning curve for users new to multi-agent systems

Code Comparison

TaskMatrix:

def decompose_task(task):
    subtasks = []
    # Complex task decomposition logic
    return subtasks

def execute_task(task, agents):
    for agent in agents:
        agent.process(task)

Claude Code Router:

def route_code(code):
    language = detect_language(code)
    return ROUTERS[language].process(code)

TaskMatrix offers a more complex task management system with multiple agents, while Claude Code Router focuses specifically on routing and processing code snippets. TaskMatrix provides broader functionality but requires more setup, while Claude Code Router is simpler and more focused on code-related tasks.

25,031

JARVIS, a system to connect LLMs with ML community. Paper: https://arxiv.org/pdf/2303.17580.pdf

Pros of JARVIS

  • More comprehensive AI agent framework with multi-modal capabilities
  • Larger community and backing from Microsoft
  • Supports a wider range of tasks beyond just code routing

Cons of JARVIS

  • More complex setup and configuration required
  • Heavier resource requirements due to broader feature set
  • Steeper learning curve for developers

Code Comparison

claude-code-router:

@app.route("/generate", methods=["POST"])
def generate():
    prompt = request.json["prompt"]
    response = claude.complete(prompt)
    return jsonify({"response": response})

JARVIS:

@app.agent()
async def code_agent(human_input: str) -> str:
    # Complex agent logic here
    response = await llm.generate(human_input)
    return await tools.refine_code(response)

The claude-code-router example shows a simpler API endpoint for code generation, while JARVIS demonstrates a more sophisticated agent-based approach with additional processing steps.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Claude Code Router

Chinese README Discord X License Desktop downloads Documentation

Kimi K2.7 Code sponsor banner
Kimi Code Subscription  Â·  API Global  Â·  API China

Thanks to Kimi for sponsoring this project! Kimi K2.7 Code is an open-source, coding-focused agentic model developed by Moonshot AI, with substantial gains on real-world long-horizon coding tasks and higher end-to-end success across complex software engineering workflows. It also cuts thinking-token usage by approximately 30% compared with K2.6. Inside CCR, Kimi ships as built-in provider presets: import the pay-as-you-go API or the Kimi Code subscription in one click and route your coding agent's requests to Kimi, the subscription endpoint passes straight through natively with no protocol conversion, API endpoints are adapted automatically, and your balance and subscription usage show up right in the CCR dashboard.

CCR already supports Kimi. Visit the Kimi Open Platform (中文站 | Global) to try the API, or explore the cost-effective Coding Plan.

Claude Code Router Desktop is a local gateway and desktop control panel for routing agent requests from Claude Code, Codex, ZCode, and compatible clients to the model provider you actually want to use.

Claude Code Router Desktop screenshot

Why Use CCR

  • Use one local endpoint for multiple agent tools instead of configuring every client separately.
  • Route requests with default routing, conditional rules, fallback targets, and request rewrites instead of editing client configuration by hand.
  • Mix providers without changing your workflow. CCR supports OpenAI-compatible APIs, Anthropic Messages, Gemini Generate Content, OpenRouter, DeepSeek, SiliconFlow, Moonshot, Kimi Code, Mistral, Z.AI, Bailian, and custom providers.
  • Control cost and reliability with fallback routing, API key rotation, usage statistics, and request logs.

Features

  • Overview dashboard: inspect system status, usage widgets, account balances, model distribution, and share cards.
  • Provider management: add provider presets or custom endpoints, probe protocol support, test model connectivity, manage credentials, and monitor supported account balances where available.
  • Routing rules: configure default routing, conditional and model-prefix rules, fallback handling, and request rewrites.
  • Agent Config: configure Claude Code, Codex, and ZCode launch entries, models, scopes, and multi-instance app profiles.
  • Gateway compatibility: translate supported client requests through the local CCR model gateway.
  • Proxy mode: capture supported API traffic through a local proxy with optional system proxy integration and network capture.
  • Fusion models: combine a base model with vision, web search, or MCP tools into a reusable selectable model.

Documentation

Read the full documentation at ccrdesk.top.

Download And Install

  1. Open the GitHub Releases page.
  2. Download the package for your platform:
    • macOS Apple Silicon: Claude-Code-Router_<version>-mac-Apple-Silicon-arm64.dmg or .zip
    • macOS Intel: Claude-Code-Router_<version>-mac-Intel-x64.dmg or .zip
    • Windows: Claude Code Router_<version>.exe
    • Linux: Claude Code Router_<version>.AppImage
  3. Install and launch Claude Code Router.
  4. On first launch, CCR creates its local configuration database:
    • macOS/Linux: ~/.claude-code-router/config.sqlite
    • Windows: %APPDATA%\Claude Code Router\config.sqlite

CCR stores runtime configuration in SQLite. A legacy config.json is read only once for migration when no SQLite config exists.

After the service is started from the Server page, CCR listens on http://localhost:8080 by default. The Server page controls the gateway Host, Port, proxy mode, system proxy, network capture, and CA certificate status.

Quick Start

CCR can be configured entirely from the desktop UI. Use this setup order for a clean first run.

1. Add a provider

Open Providers, click Add Provider, then choose a built-in preset or Other / custom API endpoint. Fill in the provider name, base URL, protocol, API key, and model list. Run protocol probing and model connectivity checks when available, then save the provider.

2. Configure routing

Open Routing to add conditional rules, configure request rewrites, and set fallback behavior.

Use Add Routing Rule for request conditions, model-prefix routing, or rule-level fallback targets.

3. Start the gateway

Open Server and click Start. After the page shows Running, CCR listens on http://localhost:8080. Enable Auto start if you want CCR to start the local gateway whenever the desktop app opens.

4. Connect your agent tool

Open Agent Config and choose the client you want to use. Configure Claude Code, Codex, or ZCode, select the target model and effect scope, then apply the config. For app entries, use the Open Agent action to open the target app through CCR.

5. Monitor and adjust

Use Settings → Logs & Observability to enable request logs and agent observability. Use Logs to confirm request model, resolved provider, resolved model, status, tokens, latency, and errors; use the tray window for quick token and account status.

Acknowledgements

Codex support is powered by musistudio/codexl.

Support & Sponsoring

If you find this project helpful, please consider sponsoring its development. Your support is greatly appreciated.

Support on Ko-fi
One-time support via Ko-fi
Sponsor with PayPal
International sponsorship
Alipay
Alipay QR code
WeChat Pay
WeChat Pay QR code

Our Sponsors

A huge thank you to all our sponsors for their generous support.

Zhipu icon
Z智谱
AIHubmix icon
AIHubmix
BurnCloud icon
BurnCloud
302.AI icon
302.AI
RunAPI icon
RunAPI
TeamoRouter icon
TeamoRouter
code0.ai icon
code0.ai
claudeapi icon
claudeapi
Qiniu Cloud AI icon
Qiniu Cloud AI
Fenno.ai icon
Fenno.ai

Community Sponsors

@Simon Leischnig @duanshuaimin @vrgitadmin @*o @ceilwoo @*说
@*更 @K*g @R*R @bobleer @*苗 @*划
@Clarence-pan @carter003 @S*r @*晖 @*敏 @Z*z
@*然 @cluic @*苗 @PromptExpert @*应 @yusnake
@*飞 @董* @*汀 @*涯 @*:-) @**磊
@*琢 @*成 @Z*o @*琨 @congzhangzh @*_
@Z*m @*鑫 @c*y @*昕 @witsice @b*g
@*亿 @*辉 @JACK @*光 @W*l @kesku
@biguncle @二吉吉 @a*g @*林 @*咸 @*明
@S*y @f*o @*智 @F*t @r*c @qierkang
@*军 @snrise-z @*王 @greatheart1000 @*王 @zcutlip
@Peng-YM @*更 @*. @F*t @*政 @*铭
@*叶 @七*o @*青 @**晨 @*远 @*霄
@**吉 @**飞 @**驰 @x*g @**东 @*落
@哆*k @*涛 @苗大 @*呢 @d*u @crizcraig
s*s *火 *勤 **锟 *涛 **明
*知 *语 *瓜

If your name is masked, please contact me via my homepage email to update it with your GitHub username.

License

This project is licensed under the MIT License.