Skip to content

Routing Rules - Custom AI Model Routing Logic

Routing rules allow you to create deterministic routing logic based on request properties.

  1. Go to Console → Routing Rules
  2. Click Create Rule
  3. Define conditions and actions
  4. Save and activate

Route based on input content:

IF input contains "code"
THEN route to provider: anthropic, model: claude-3-7-sonnet-latest

Route based on request metadata:

IF metadata.task = "summarize"
THEN route to mode: cost

Force specific models for certain requests:

IF input contains "legal" OR input contains "compliance"
THEN route to provider: openai, model: gpt-4o

Rules are evaluated in order:

  1. Highest priority first (descending order)
  2. For rules with the same priority, older rules (lower ID) are evaluated first
  3. Once a rule matches and applies an action (e.g., set_provider), subsequent rules cannot override that specific action
  4. Multiple rules can match and apply different non-conflicting actions
  5. If no rules match, use default routing mode
  • Start with broad rules, refine over time
  • Use descriptive rule names
  • Test rules before activating
  • Monitor rule performance in analytics
Name: Code Questions → Claude
Condition: input contains "code" OR "function" OR "class"
Action: Route to Anthropic Claude 3.7 Sonnet
Priority: High
Name: Summaries → Cost Mode
Condition: metadata.task = "summarize"
Action: Route to mode: cost
Priority: Medium
Name: Legal/Compliance → GPT-4
Condition: input contains "legal" OR "gdpr" OR "compliance"
Action: Route to OpenAI GPT-4o
Priority: High