Skip to content

Heuristic Router

The heuristic router uses a rule-based scoring system to select the optimal model for each query. It analyzes query features (length, complexity, tool requirements) and matches them against model capability profiles.

How It Works

  1. Feature extraction -- analyze the query for length, keyword patterns, and tool requirements
  2. Capability scoring -- score each model's suitability based on extracted features
  3. Cost weighting -- apply cost preferences to favor cheaper models for simple queries
  4. Selection -- choose the highest-scoring model that meets minimum quality thresholds

Scoring Factors

FactorWeightDescription
Capability match0.4Model's ability to handle the query type
Elo rating0.2Historical model performance
Cost efficiency0.2Tokens per dollar
Latency0.1Average response time
Context window0.1Fits the conversation context

Configuration

toml
[router]
strategy = "heuristic"

[router.heuristic]
complexity_threshold = 0.6
prefer_cheap_below = 0.4
elo_weight = 0.2
cost_weight = 0.2

Released under the Apache-2.0 License.