Model Router

The Model Router automatically selects the appropriate model size based on message complexity, optimizing cost and latency.

Warning

Disabled by default. Smart model routing is off by default because it conflicts with Claude Code CLI’s built-in model routing. When using the Claude Agent SDK backend (recommended), Claude Code already picks the best model for each task. Enable the model router only if you want explicit control over model tiers or are using the Mudabbir Native backend.

How It Works

The router classifies each message into one of three complexity levels:

LevelDescriptionTypical Model
SIMPLEGreetings, simple questions, short responsesSmaller/faster model
MODERATEMulti-step tasks, moderate reasoningDefault model
COMPLEXCoding, deep analysis, multi-tool chainsLargest model

Classification Heuristics

The router uses several signals to determine complexity:

  1. Message length — Longer messages tend to be more complex
  2. Keyword detection — Certain words indicate complexity:
    • Code-related: “write code”, “debug”, “refactor”, “implement”
    • Analysis: “analyze”, “compare”, “explain in detail”
    • Multi-step: “step by step”, “plan”, “research”
  3. Tool mentions — References to specific tools suggest higher complexity
  4. Question depth — Follow-up questions in a chain indicate growing complexity

Threshold

A message is classified as COMPLEX if it has at least 1 complex signal AND is longer than 30 characters.

Configuration

The model router is disabled by default (smart_routing_enabled: false). Enable it in the dashboard under Settings → Behavior & Safety, or via environment variable:

Terminal window
export MUDABBIR_SMART_ROUTING_ENABLED=true
# Customize model tiers
export MUDABBIR_MODEL_TIER_SIMPLE="claude-haiku-4-5-20251001"
export MUDABBIR_MODEL_TIER_MODERATE="claude-sonnet-4-5-20250929"
export MUDABBIR_MODEL_TIER_COMPLEX="claude-opus-4-6"

The router works with the Claude Agent SDK and Mudabbir Native backends.

Example Classifications

MessageClassification
”Hi!”SIMPLE
”What time is it?”SIMPLE
”Write a Python web scraper that handles pagination”COMPLEX
”Analyze the performance of my database queries”COMPLEX
”Search for news about AI”MODERATE
Info

The model router is a heuristic system. For most users, leaving it disabled and letting Claude Code handle model selection produces the best results. Enable it only if you want to optimize API costs or need explicit control over which models are used for different task types.

Warning

Ollama users: The model router is automatically skipped when using Ollama, since Ollama runs a single local model. There are no tiers to route between.