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.
Best use case
llmrouter is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using llmrouter should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/llmrouter/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How llmrouter Compares
| Feature / Agent | llmrouter | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Top AI Agents for Productivity
See the top AI agent skills for productivity, workflow automation, operational systems, documentation, and everyday task execution.
AI Agents for Marketing
Discover AI agents for marketing workflows, from SEO and content production to campaign research, outreach, and analytics.
SKILL.md Source
# LLM Router
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](https://github.com/openclaw/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.
## Quick Start
### Prerequisites
1. **Python 3.10+** with pip
2. **Ollama** (optional - only if using local classification)
3. **Anthropic API key** or Claude Code OAuth token (or other provider key)
### Setup
```bash
# 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
```
### Verify Installation
```bash
# 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", ...}
```
### Start the Server
```bash
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)
## Configuration
Edit `config.yaml` to customize:
### Model Routing
```yaml
# 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.
### Classifier
Three options for classifying request complexity:
**Local (default)** - Free, requires Ollama:
```yaml
classifier:
provider: "local"
model: "qwen2.5:3b"
```
**Anthropic** - Uses Haiku, fast and cheap:
```yaml
classifier:
provider: "anthropic"
model: "claude-haiku-4-5-20251001"
```
**OpenAI** - Uses GPT-4o-mini:
```yaml
classifier:
provider: "openai"
model: "gpt-4o-mini"
```
**Google** - Uses Gemini:
```yaml
classifier:
provider: "google"
model: "gemini-2.0-flash"
```
**Kimi** - Uses Moonshot:
```yaml
classifier:
provider: "kimi"
model: "moonshot-v1-8k"
```
Use remote (anthropic/openai/google/kimi) if your machine can't run local models.
### Supported Providers
- `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)
## Complexity Levels
| 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 |
## Customizing Classification
Edit `ROUTES.md` to tune how messages are classified. The classifier reads the table in this file to determine complexity levels.
## API Usage
The router exposes an OpenAI-compatible API:
```bash
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!"}]
}'
```
## Testing Classification
```bash
python classifier.py "Write a Python sort function"
# Output: medium
python classifier.py --test
# Runs test suite
```
## Running as macOS Service
Create `~/Library/LaunchAgents/com.llmrouter.plist`:
```xml
<?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.
```bash
# 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
```
## OpenClaw Configuration
Add the router as a provider in `~/.openclaw/openclaw.json`:
```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.
### Set as Default Model (Optional)
To use the router for all agents by default, add:
```json
{
"agents": {
"defaults": {
"model": {
"primary": "localrouter/llm-router"
}
}
}
}
```
### Using with OAuth Tokens
If your `config.yaml` uses an Anthropic OAuth token from OpenClaw's `~/.openclaw/auth-profiles.json`, the router automatically handles Claude Code identity headers.
### OpenClaw Compatibility Mode (Required)
**If using with OpenClaw, you MUST start the server with `--openclaw`:**
```bash
python server.py --openclaw
```
This flag enables compatibility features required for OpenClaw:
- Rewrites model names in responses so OpenClaw shows the actual model being used
- Handles tool name and ID remapping for proper tool call routing
Without this flag, you may encounter errors when using the router with OpenClaw.
## Common Tasks
- **Check server status**: `curl http://localhost:4001/health`
- **View current config**: `cat config.yaml`
- **Test a classification**: `python classifier.py "your message"`
- **Run classification tests**: `python classifier.py --test`
- **Restart server**: Stop and run `python server.py` again
- **View logs** (if running as service): `tail -f logs/stdout.log`
## Troubleshooting
### "externally-managed-environment" error
Python 3.11+ requires virtual environments. Create one:
```bash
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
### "Connection refused" on port 4001
Server isn't running. Start it:
```bash
source venv/bin/activate && python server.py
```
### Classification returns wrong complexity
Edit `ROUTES.md` to tune classification rules. The classifier reads this file to determine complexity levels.
### Ollama errors / "model not found"
Ensure Ollama is running and the model is pulled:
```bash
ollama serve # Start Ollama if not running
ollama pull qwen2.5:3b
```
### OAuth token not working
Ensure your token in `config.yaml` starts with `sk-ant-oat`. The router auto-detects OAuth tokens and adds required identity headers.
### LaunchAgent not starting
Check logs and ensure paths are absolute:
```bash
cat ~/Library/LaunchAgents/com.llmrouter.plist # Verify paths
cat /path/to/llmrouter/logs/stderr.log # Check for errors
```Related Skills
---
name: article-factory-wechat
humanizer
Remove signs of AI-generated writing from text. Use when editing or reviewing text to make it sound more natural and human-written. Based on Wikipedia's comprehensive "Signs of AI writing" guide. Detects and fixes patterns including: inflated symbolism, promotional language, superficial -ing analyses, vague attributions, em dash overuse, rule of three, AI vocabulary words, negative parallelisms, and excessive conjunctive phrases.
find-skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
tavily-search
Use Tavily API for real-time web search and content extraction. Use when: user needs real-time web search results, research, or current information from the web. Requires Tavily API key.
baidu-search
Search the web using Baidu AI Search Engine (BDSE). Use for live information, documentation, or research topics.
agent-autonomy-kit
Stop waiting for prompts. Keep working.
Meeting Prep
Never walk into a meeting unprepared again. Your agent researches all attendees before calendar events—pulling LinkedIn profiles, recent company news, mutual connections, and conversation starters. Generates a briefing doc with talking points, icebreakers, and context so you show up informed and confident. Triggered automatically before meetings or on-demand. Configure research depth, advance timing, and output format. Walking into meetings blind is amateur hour—missed connections, generic small talk, zero leverage. Use when setting up meeting intelligence, researching specific attendees, generating pre-meeting briefs, or automating your prep workflow.
self-improvement
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Claude ('No, that's wrong...', 'Actually...'), (3) User requests a capability that doesn't exist, (4) An external API or tool fails, (5) Claude realizes its knowledge is outdated or incorrect, (6) A better approach is discovered for a recurring task. Also review learnings before major tasks.
botlearn-healthcheck
botlearn-healthcheck — BotLearn autonomous health inspector for OpenClaw instances across 5 domains (hardware, config, security, skills, autonomy); triggers on system check, health report, diagnostics, or scheduled heartbeat inspection.
linkedin-cli
A bird-like LinkedIn CLI for searching profiles, checking messages, and summarizing your feed using session cookies.
notebooklm
Google NotebookLM 非官方 Python API 的 OpenClaw Skill。支持内容生成(播客、视频、幻灯片、测验、思维导图等)、文档管理和研究自动化。当用户需要使用 NotebookLM 生成音频概述、视频、学习材料或管理知识库时触发。
小红书长图文发布 Skill
## 概述