Skip to main content
The --router flag enables intelligent model selection, automatically choosing the best model based on task complexity.

Quick Start

Router Demo Router Selects Optimal Model

Usage

Basic Router

Expected Output:

Complex Task

Expected Output:

Specify Provider

Expected Output:

Combine with Other Features

How It Works

  1. Prompt Analysis: The router analyzes your prompt
  2. Complexity Assessment: Determines task complexity (simple/medium/complex)
  3. Model Selection: Chooses appropriate model based on complexity
  4. Execution: Runs the task with the selected model

Complexity Levels

Model Selection Matrix

OpenAI Models

Anthropic Models

Cost Savings Example

Without router (always using gpt-4-turbo):
With router (auto-selects gpt-4o-mini):
Expected Output:

Use Cases

Cost Optimization

Quality Assurance

Batch Processing

Complexity Indicators

The router considers these factors:

Simple Tasks

  • Short prompts (< 50 words)
  • Basic questions
  • Simple calculations
  • Factual lookups
  • Yes/no questions

Complex Tasks

  • Long prompts (> 200 words)
  • Technical analysis
  • Code generation
  • Multi-step reasoning
  • Creative writing
  • Research tasks

Best Practices

Use --router --metrics to see the cost savings from automatic model selection.
The router adds a small overhead for complexity analysis. For known simple tasks, you may prefer to specify the model directly with --llm.

Cost Monitoring

Use --metrics to track savings

Provider Preference

Use --router-provider for specific needs

Override When Needed

Use --llm to override router selection

Batch Operations

Router is ideal for varied batch tasks