Intelligent LLM proxy that routes requests to appropriate models based on complexity. Save money by using cheaper models for simple tasks. Tested with Anthropic, OpenAI, Gemini, Kimi/Moonshot, and Ollama.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install llmrouter或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install llmrouter⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/llmrouter/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: llmrouter description: Intelligent LLM proxy that routes requests to appropriate models based on complexity. Save money by using cheaper models for simple tasks. Tested with Anthropic, OpenAI, Gemini, Kimi/Moonshot, and Ollama. homepage: https://github.com/alexrudloff/llmrouter metadata: {"openclaw":{"emoji":"🔀","homepage":"https://github.com/alexrudloff/llmrouter","os":["darwin","linux"],"requires":{"bins":["python3"],"anyBins":["pip","pip3"]},"primaryEnv":"ANTHROPIC_API_KEY"}} ---
An intelligent proxy that classifies incoming requests by complexity and routes them to appropriate LLM models. Use cheaper/faster models for simple tasks and reserve expensive models for complex ones.
Works with OpenClaw to reduce token usage and API costs by routing simple requests to smaller models.
Status: Tested with Anthropic, OpenAI, Google Gemini, Kimi/Moonshot, and Ollama.
# Clone if not already present
git clone https://github.com/alexrudloff/llmrouter.git
cd llmrouter
# Create virtual environment (required on modern Python)
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Pull classifier model (if using local classification)
ollama pull qwen2.5:3b
# Copy and customize config
cp config.yaml.example config.yaml
# Edit config.yaml with your API key and model preferences
# Start the server
source venv/bin/activate
python server.py
# In another terminal, test health endpoint
curl http://localhost:4001/health
# Should return: {"status": "ok", ...}
python server.py
Options:
--port PORT - Port to listen on (default: 4001)--host HOST - Host to bind (default: 127.0.0.1)--config PATH - Config file path (default: config.yaml)--log - Enable verbose logging--openclaw - Enable OpenClaw compatibility (rewrites model name in system prompt)Edit config.yaml to customize:
# Anthropic routing
models:
super_easy: "anthropic:claude-haiku-4-5-20251001"
easy: "anthropic:claude-haiku-4-5-20251001"
medium: "anthropic:claude-sonnet-4-20250514"
hard: "anthropic:claude-opus-4-20250514"
super_hard: "anthropic:claude-opus-4-20250514"
# OpenAI routing
models:
super_easy: "openai:gpt-4o-mini"
easy: "openai:gpt-4o-mini"
medium: "openai:gpt-4o"
hard: "openai:o3-mini"
super_hard: "openai:o3"
# Google Gemini routing
models:
super_easy: "google:gemini-2.0-flash"
easy: "google:gemini-2.0-flash"
medium: "google:gemini-2.0-flash"
hard: "google:gemini-2.0-flash"
super_hard: "google:gemini-2.0-flash"
Note: Reasoning models are auto-detected and use correct API params.
Three options for classifying request complexity:
Local (default) - Free, requires Ollama:
classifier:
provider: "local"
model: "qwen2.5:3b"
Anthropic - Uses Haiku, fast and cheap:
classifier:
provider: "anthropic"
model: "claude-haiku-4-5-20251001"
OpenAI - Uses GPT-4o-mini:
classifier:
provider: "openai"
model: "gpt-4o-mini"
Google - Uses Gemini:
classifier:
provider: "google"
model: "gemini-2.0-flash"
Kimi - Uses Moonshot:
classifier:
provider: "kimi"
model: "moonshot-v1-8k"
Use remote (anthropic/openai/google/kimi) if your machine can't run local models.
anthropic:claude-* - Anthropic Claude models (tested)openai:gpt-, openai:o1-, openai:o3-* - OpenAI models (tested)google:gemini-* - Google Gemini models (tested)kimi:kimi-k2.5, kimi:moonshot-* - Kimi/Moonshot models (tested)local:model-name - Local Ollama models (tested)| Level | Use Case | Default Model | |-------|----------|---------------| | super_easy | Greetings, acknowledgments | Haiku | | easy | Simple Q&A, reminders | Haiku | | medium | Coding, emails, research | Sonnet | | hard | Complex reasoning, debugging | Opus | | super_hard | System architecture, proofs | Opus |
Edit ROUTES.md to tune how messages are classified. The classifier reads the table in this file to determine complexity levels.
The router exposes an OpenAI-compatible API:
curl http://localhost:4001/v1/chat/completions \
-H "Authorization: Bearer $ANTHROPIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "llm-router",
"messages": [{"role": "user", "content": "Hello!"}]
}'
python classifier.py "Write a Python sort function"
# Output: medium
python classifier.py --test
# Runs test suite
Create ~/Library/LaunchAgents/com.llmrouter.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.llmrouter</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/llmrouter/venv/bin/python</string>
<string>/path/to/llmrouter/server.py</string>
<string>--openclaw</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>/path/to/llmrouter</string>
<key>StandardOutPath</key>
<string>/path/to/llmrouter/logs/stdout.log</string>
<key>StandardErrorPath</key>
<string>/path/to/llmrouter/logs/stderr.log</string>
</dict>
</plist>
Important: Replace /path/to/llmrouter with your actual install path. Must use the venv python, not system python.
# Create logs directory
mkdir -p ~/path/to/llmrouter/logs
# Load the service
launchctl load ~/Library/LaunchAgents/com.llmrouter.plist
# Verify it's running
curl http://localhost:4001/health
# To stop/restart
launchctl unload ~/Library/LaunchAgents/com.llmrouter.plist
launchctl load ~/Library/LaunchAgents/com.llmrouter.plist
Add the router as a provider in ~/.openclaw/openclaw.json:
{
"models": {
"providers": {
"localrouter": {
"baseUrl": "http://localhost:4001/v1",
"apiKey": "via-router",
"api": "openai-completions",
"models": [
{
"id": "llm-router",
"name": "LLM Router (Auto-routes by complexity)",
"reasoning": false,
"input": ["text", "image"],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 200000,
"maxTokens": 8192
}
]
}
}
}
}
Note: Cost is set to 0 because actual costs depend on which model the router selects. The router logs which model handled each request.
To use the router for all agents by default, add:
{
"agents": {
"defaults": {
"model": {
"primary": "localrouter/llm-router"
}
}
}
}
If your config.yaml uses an Anthropic OAuth token from OpenClaw's ~/.openclaw/auth-profiles.json, the router automatically handles Claude Code identity headers.
If using with OpenClaw, you MUST start the server with --openclaw:
python server.py --openclaw
This flag enables compatibility features required for OpenClaw:
...
安装 Llmrouter 后,可以对 AI 说这些话来触发它
Help me get started with Llmrouter
Explains what Llmrouter does, walks through the setup, and runs a quick demo based on your current project
Use Llmrouter to intelligent LLM proxy that routes requests to appropriate models ba...
Invokes Llmrouter with the right parameters and returns the result directly in the conversation
What can I do with Llmrouter in my product manager workflow?
Lists the top use cases for Llmrouter, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/llmrouter/ 目录(个人级,所有项目可用),或 .claude/skills/llmrouter/(项目级)。重启 AI 客户端后,用 /llmrouter 主动调用,或让 AI 根据上下文自动发现并使用。
Llmrouter 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Llmrouter 可免费安装使用。请查阅仓库了解许可证信息。
Intelligent LLM proxy that routes requests to appropriate models based on complexity. Save money by using cheaper models for simple tasks. Tested with Anthropic, OpenAI, Gemini, Kimi/Moonshot, and Ollama.
Llmrouter 属于「Product Manager」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my product manager tasks using Llmrouter
Identifies repetitive steps in your workflow and sets up Llmrouter to handle them automatically