Content
List
**One model can't handle all tasks. You want to use DeepSeek for daily reasoning, Doubao for image analysis, and GPT-5.4 for complex architecture planning. Switching models, managing API keys, and remembering which model is suitable for what task - these are all cognitive burdens.**
## The Problem
The current model landscape is as follows:
| Model | Advantages | Disadvantages |
|------|------------|--------------|
| DeepSeek | Strong reasoning, affordable, large context | No multi-modal capabilities |
| | Excellent visual understanding, affordable | Complex reasoning not as good as Deep| GPT-5.4 | Top-notch architecture design, in-depth Expensive, wasteful for daily use |
| Gemini 2.5 Flash | High-quality multi-language translation, affordable | Average code capabilities |
## Solution
model-gateway is a **model router**. You use Claude Code as usual, and it automatically distributes different tasks to the most suitable model behind the scenes:
```
Your Task → Routed to
──────────────────────────────────────────
Analyze the screenshot for buttons → Doubao Seed 2.1 Pro (visual, affordable)
Design a microservice transaction compensation scheme → GPT-5.4 (in-depth reasoning, expensive but worth it)
Review auth.py for security vulnerabilities → GPT-5.4 (security audit, can't save money)
"Redis cluster vs sentinel, which one to choose?" → GPT-5.4 (decision analysis)
Translate to Japanese → Gemini 2.5 Flash (translation, affordable)
All other tasks → (your current default model)
```
**Good models used where they matter, expensive models only where they're worth it.**
## Quick Start
```bash
# 1. Installation
pip install -e .
# 2. Set API Key (in ~/.claude/settings.json's env block)
# "OPENROUTER_API_KEY": "sk-or-v1-xxx", # For GPT-5.4, Gemini, etc.
# "ARK": "your-ark-key" # For Doub
# 3. Add a tool - modify config add a JSON block:
"tool": "translate_to_japanese",
#description": "Translate text to Japanese",
# "provider": "openrouter",
# "model":/gemini-2.ash",
# "": "Translate to natural Japanese tone.",
# "inputSchema": {
# "type":",
# "properties": {
# "text": { " "string", "description": "Text to translate" }
## "required": ["text"]
# }
# }
# Restart Claude Code - new automatically.
```
## ArchitectureClaude Code (you'reSeek, no matter)
├── "Help me analyze this architecture diagram" ──→ ask ──→ Doubao Seed 2.1 Pro
├── "Design a migration plan" ──→ gpt_plan ──→ GPT-5.4
├── this code" ── gpt_review ── GPT-5.4
├── "Translate to Chinese"─→ gpt_translate ──→ Gemini 2.
└── ...more tools, just add a JSON block to
```
Core idea: **config.json defines "what task → what what prompt", server.py handles and API calls. Adding requires zero Python code.**
## Built-in Tools
| Tool | Model | Why this model |
|------|-------|------|------------------|
|_ask` | Doubao Seed 2.1 Pro | Image analysis, screenshot understanding, chart interpretation visual understanding, affordable |
| `gpt_plan` | GPT-5.4 | Architecture design, implementation plan planning | In-depth reasoning, can't save money on complex tasks |
| `gpt_review` | GPT-5.4 | Code review (security/c/architecture) | Need in-depth analysis to find hidden vulnerabilities |
| `gpt_decide` | GPT-5.4 | Multi-scheme decision analysis | Requires strong reasoning for trade-offs |
| `gpt_design_workflow` | GPT-5.4 | Generate workflow orchestration scripts | Need a global perspective for multi-step orchestration |
| `gpt_translate` | Gemini 2.5 Flash | Multi-language translation | High translation quality, affordable |
## CLI Usage
```bash
mg vision photo.jpg "Describe this image"
mg plan "Design a microservice transaction compensation mechanism" --budget high
mg review auth.py --focus security
mg decide "Redis cluster" "sentinel scheme" "cloud service" --criteria "performance,cost,maintenance"
mg workflow "Migrate authentication system to JWT, zero downtime" --quality exhaustive
mg translate "Hello world" Chinese
```
## Claude Code Integration
```json
"mcpServers": {
"model-gateway": {
"command": "pythonargs": ["-m", "model_gateway.mcp_server "cwd": "/path/to/model-gateway"
}
}
}
```
## Security
- **API Keys are not in the repository environment variables are used
- `config.json` is excludedgitignore`, won't be committed- Configured keys are automatically stripped of resolved keys during writing
## License
MIT