Fork of Alishahryar1/free-claude-code with automatic model routing by task complexity.
π Original project: https://github.com/Alishahryar1/free-claude-code
π¬π§ English | π·πΊ Π ΡΡΡΠΊΠΈΠΉ
This is a proxy server for Claude Code CLI. It sits between Claude Code and AI models, and automatically chooses the right model for the task:
| If the task is | It goes to | Cost |
|---|---|---|
| β Simple question / chat | OpenRouter (free models) | πΈ $0 |
| β‘ Refactoring / code generation | DeepSeek V4 Flash | β‘ cheap |
| πͺ Complex architecture / algorithms | DeepSeek V4 Pro | πͺ powerful |
You no longer need to think about which model to use. Just work β the proxy decides for you.
npm install -g @anthropic-ai/claude-codecurl -LsSf https://astral.sh/uv/install.sh | shgit clone https://github.com/smashlight/free-claude-code-AIRouting.git
cd free-claude-code-AIRouting
uv tool install --force .Create ~/.config/free-claude-code/.env:
mkdir -p ~/.config/free-claude-codeCopy this into it:
# ==== API keys ====
# DeepSeek (required for task classification + flash/pro models)
DEEPSEEK_API_KEY="sk-your-deepseek-key"
# OpenRouter (required for free models on simple tasks)
OPENROUTER_API_KEY="sk-or-v1-your-openrouter-key"
# ==== Models (you can change these) ====
MODEL_OPUS="deepseek/deepseek-v4-pro" # Most powerful
MODEL_SONNET="deepseek/deepseek-v4-flash" # Medium tier
MODEL_HAIKU="open_router/openrouter/free" # Free tier
MODEL="deepseek/deepseek-v4-pro" # Fallback
# ==== AUTO_ROUTE ====
AUTO_ROUTE_ENABLED=true
AUTO_ROUTE_CLASSIFIER_MODEL=deepseek/deepseek-v4-flash
# ==== Security ====
ANTHROPIC_AUTH_TOKEN="freecc"
# ==== Thinking ====
# DeepSeek V4 Flash/Pro support thinking; OpenRouter free tier stays off.
ENABLE_MODEL_THINKING=false
ENABLE_HAIKU_THINKING=false
ENABLE_SONNET_THINKING=true
ENABLE_OPUS_THINKING=true
# ==== Optimizations ====
ENABLE_NETWORK_PROBE_MOCK=true
ENABLE_TITLE_GENERATION_SKIP=true
ENABLE_SUGGESTION_MODE_SKIP=true
ENABLE_FILEPATH_EXTRACTION_MOCK=trueIn one terminal:
cd free-claude-code-AIRouting
uv run python server.pyThe proxy exposes fcc-claude. Add this to ~/.zshrc (or ~/.bashrc):
alias claudeds='fcc-claude'
alias claudeds-yolo='fcc-claude -- --dangerously-skip-permissions'Apply it:
source ~/.zshrcIn one terminal, start the proxy:
cd free-claude-code-AIRouting
uv run python server.pyIn another terminal, start Claude Code:
claudedsDone! π Every request is now automatically routed to the best-fit model.
Important: the regular
claudecommand runs Claude Code directly against Anthropic (official models, paid). Useclaudedsto route requests through this proxy with AUTO_ROUTE.
If you are on Windows or want to automate the setup, give this prompt to an AI assistant (Claude Code, ChatGPT, etc.):
Clone https://github.com/smashlight/free-claude-code-AIRouting.git into a project folder.
Read the README and complete all installation and proxy configuration steps.
Connect it to DeepSeek API using my key: "sk-your-deepseek-key"
IMPORTANT β model names: .env.example contains model names, but DeepSeek may rename models occasionally.
Before starting the proxy, query the DeepSeek API (GET https://api.deepseek.com/models with the API key),
check the current model names (likely deepseek-v4-flash and deepseek-v4-pro), and put them into .env.
Create two aliases:
- claudeds β run Claude Code through the proxy
- claudeds-yolo β same, plus --dangerously-skip-permissions
The assistant can clone the repo, install dependencies, configure .env, check current model names, and create aliases for you.
ββ SIMPLE β OpenRouter (free)
Your request β Proxy ββββββΌβ COMPLEX β DeepSeek Flash
ββ VERY_COMPLEX β DeepSeek Pro
β
Classifier
(DeepSeek Flash,
~1.5β2 sec)
Before each request, the proxy makes a fast classification call to DeepSeek Flash (very cheap, about 2 seconds). The classifier looks at the task text and decides its complexity. Then the request is routed to the corresponding model.
The classifier receives a prompt like this:
Classify this coding task complexity.
- SIMPLE: Chat, questions, file reads, simple search, one-line fixes
- COMPLEX: Multi-file refactoring, architecture changes, code generation
- VERY_COMPLEX: System design, complex algorithms, performance optimization
Task: {user task text}
Response (one word):
The default AUTO_ROUTE setup keeps MODEL_HAIKU on OpenRouter/free without thinking, while MODEL_SONNET (deepseek-v4-flash) and MODEL_OPUS (deepseek-v4-pro) run with thinking enabled. DeepSeek thinking with tool calls depends on replaying prior reasoning_content/thinking blocks in follow-up requests; the DeepSeek adapter preserves that replay and strips unsupported redacted thinking.
The .env file has three tiers:
# Haiku tier β for the simplest tasks
MODEL_HAIKU="open_router/openrouter/free"
# Sonnet tier β for medium tasks
MODEL_SONNET="deepseek/deepseek-v4-flash"
# Opus tier β for complex tasks
MODEL_OPUS="deepseek/deepseek-v4-pro"
# Fallback if the model cannot be resolved
MODEL="deepseek/deepseek-v4-pro"You can use any model from supported providers:
| Provider | Format | Example |
|---|---|---|
| DeepSeek | deepseek/model-name |
deepseek/deepseek-v4-flash |
| OpenRouter | open_router/model-name |
open_router/anthropic/claude-sonnet-4 |
| NVIDIA NIM | nvidia_nim/model |
nvidia_nim/meta/llama-3.3-70b-instruct |
| LM Studio | lmstudio/model |
lmstudio/qwen2.5-7b |
| Ollama | ollama/model |
ollama/llama3.1 |
| What | Where to get it | Why |
|---|---|---|
| DeepSeek API key | https://platform.deepseek.com/api_keys | Task classification + flash/pro models |
| OpenRouter API key | https://openrouter.ai/keys | Free models for simple tasks |
| Claude Code CLI | npm install -g @anthropic-ai/claude-code |
Main coding interface |
| Your request | Complexity | Routed to |
|---|---|---|
| "What is 2+2?" | SIMPLE | OpenRouter free (free) |
| "Write a bash script that finds large files" | COMPLEX | DeepSeek Flash |
| "Design a distributed cache system" | VERY_COMPLEX | DeepSeek Pro |
| "Refactor auth module to JWT" | COMPLEX β VERY_COMPLEX | DeepSeek Flash β Pro |
# Start the proxy server
cd ~/free-claude-code-AIRouting && uv run python server.py
# Start Claude Code through the proxy (in another terminal)
claudeds
# Fast launch with auto-confirmation
claudeds-yolo- Original project β free Claude Code proxy
- DeepSeek β DeepSeek API key
- OpenRouter β OpenRouter API key
- DeepSeek-TUI β Auto Mode routing inspiration