Skip to content

mikemorgenstern/model-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Model Router

Intelligent routing across AI models based on task type, budget, and availability.

Route your AI tasks to the best model automatically - whether it's Claude, ChatGPT, Gemini, or local Ollama models. Model Router helps you use the right tool for the job while managing costs and preserving your Claude usage for complex work.

License: MIT Claude Code Plugin

Quick Start

# Add the marketplace to Claude Code
/plugin marketplace add mikemorgenstern/model-router

# Install Model Router
/plugin install model-router@mikemorgenstern-model-router

# Run setup wizard
/model-router:setup

That's it! Model Router will now help you choose the best model for each task.

What It Does

Model Router is a recommendation system for Claude Code that:

  • πŸ“Š Recommends the best model for your task (code review, reasoning, bulk work, etc.)
  • πŸ’° Saves money by routing to cheaper models when appropriate
  • 🎯 Preserves Claude usage for complex tasks that need the best quality
  • πŸ†“ Supports free local models via Ollama (Llama, DeepSeek, etc.)
  • πŸ“ˆ Learns from your usage to personalize recommendations
  • πŸ”„ Stays updated with community-driven model benchmarks

Example

You: "I need to review this PR"

Model Router: Based on your setup:
  1. GPT-5.2 via Codex CLI (preserves Claude, ChatGPT included)
  2. Gemini 3 Pro via Gemini CLI (good quality, Gemini included)
  3. Claude Sonnet (best quality, uses Claude subscription)

Run: codex exec -m gpt-5.2 "Review this PR: [paste diff]"
Or tell me and I'll use Claude.

Supported Models

Provider Models Access Cost
Claude Opus 4.5, Sonnet 4.5, Haiku 4.5 Built-in $20/mo subscription
ChatGPT GPT-5.2, GPT-5.2 Codex Codex CLI $20/mo subscription
Gemini 3.0 Pro, 3.0 Flash Gemini CLI $20/mo subscription
Ollama Llama 3.3 70B, DeepSeek R1 70B, Qwen 2.5 32B Local Free

All model recommendations are backed by published benchmarks (HumanEval, SWE-bench, MMLU, etc.)

Features

Smart Routing

Choose how tasks are routed:

  • Preserve Claude - Use ChatGPT/Gemini first, save Claude for complex work (default)
  • Quality First - Always use the best model available
  • Budget First - Maximize free/cheap models
  • Ask Each Time - Review recommendations before routing

Task Type Recommendations

Model Router knows which models excel at:

  • Critical Code - Production code, security-critical β†’ Claude Opus
  • Code Review - Refactoring, general coding β†’ Claude Sonnet / GPT-5.2
  • Reasoning - Math, logic, algorithms β†’ DeepSeek R1 70B (free!)
  • Simple Edits - Typos, formatting β†’ Gemini Flash / Haiku
  • Bulk Operations - Batch processing β†’ Llama 3.3 70B (free!)

Learning & Personalization

Enable tracking to let Model Router learn from your usage:

/model-router:configure tracking

Then analyze patterns:

/model-router:learn

Model Router will suggest improvements like:

  • "GPT-5.2 has 100% success rate for your code reviews - promote to best?"
  • "Gemini Flash struggled with reasoning - try DeepSeek R1 instead?"

Testing Models

Test any model with your own prompts:

/model-router:test gemini-3-pro

Choose between:

  • Standard test suite (built-in prompts)
  • Your folder prompts (Model Router scans your project for real examples)
  • Custom prompts

After testing, optionally update your recommendations based on results.

Commands

Command Purpose
/model-router:setup First-time setup wizard
/model-router:help Show all commands and config
/model-router:status Check available models and subscriptions
/model-router:recommend [task] Get recommendation for a task
/model-router:configure Change settings
/model-router:test [model] Test a model's performance
/model-router:learn Analyze usage and improve recommendations
/model-router:update-models Pull latest community recommendations

How It Works

Model Router is a recommendation system - it doesn't intercept requests automatically (Claude Code doesn't expose those hooks yet). Instead:

  1. Session start - Shows status and routing recommendations
  2. Ask for recommendations - /model-router:recommend code_review
  3. Natural language - "What model should I use for reasoning?"
  4. You route - Tell Claude "use Gemini" or run CLI command directly

Configuration

After setup, Model Router stores config in ~/.model-router/:

~/.model-router/
β”œβ”€β”€ config.yaml         # Your preferences
β”œβ”€β”€ models.yaml         # Model recommendations (customizable)
└── tracking.jsonl      # Usage data (if tracking enabled)

Requirements

  • Claude Code (you're already using it!)
  • Python 3.9+ for environment detection
  • Optional: Codex CLI for ChatGPT models
  • Optional: Gemini CLI for Gemini models
  • Optional: Ollama for free local models

The setup wizard guides you through installing what you need.

Session Start Display

Every Claude Code session shows your routing status:

β”Œβ”€ Model Router ────────────────────────────────────────┐
β”‚ Profile: balanced β”‚ Routing: ChatGPT + Gemini first  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Subscriptions: Claude βœ“  ChatGPT βœ“  Gemini βœ“          β”‚
β”‚ Local models: Ollama βœ“ (2 models)                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Recommended routing:                                  β”‚
β”‚   β€’ Code tasks β†’ GPT-5.2 (preserve Claude)           β”‚
β”‚   β€’ Reasoning β†’ DeepSeek R1 (free, local)            β”‚
β”‚   β€’ Critical β†’ Claude Opus (best quality)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Community Model Recommendations

Model Router ships with research-backed defaults, updated regularly:

  • SWE-bench - Real GitHub issues (Claude Opus 80.9%)
  • HumanEval - Coding benchmark (DeepSeek R1 96.1%)
  • GPQA - Graduate-level reasoning (DeepSeek R1 94.5%)
  • MMLU - Knowledge benchmark (Llama 3.3 86%)

See data/models.yaml for full benchmarks and citations.

Contributing Model Updates

Found a better model for a task? Submit a PR!

See CONTRIBUTING.md for guidelines.

FAQ

Q: Does this use my API keys? A: No. Model Router only reads environment variables to check if keys exist. It never stores or transmits them.

Q: Can I use this without subscriptions? A: Yes! Ollama models are free. Claude is always available (you're using Claude Code). Subscriptions are optional for ChatGPT/Gemini access.

Q: Does tracking send data anywhere? A: No. All tracking is local (~/.model-router/tracking.jsonl). Nothing is transmitted unless you explicitly choose to share anonymized stats with the community.

Q: Why doesn't it route automatically? A: Claude Code doesn't expose hooks to intercept requests. If that changes, we'll add automatic routing. For now, Model Router shows recommendations and you follow them.

Q: Can I customize model recommendations? A: Yes! Edit ~/.model-router/models.yaml or use /model-router:learn to personalize based on your usage.

Roadmap

  • VS Code extension for automatic routing
  • Cost tracking across all services
  • Team sharing of customized recommendations
  • Integration with Claude Desktop (mobile)

License

MIT License - see LICENSE

Support


Made by Mike Morgenstern Built for the Claude Code community πŸš€

About

Intelligent AI model routing for Claude Code - choose the best model for each task

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors