Home Tutorials Categories Skills About
ZH EN JA KO
Advanced

Intelligent Model Routing Configuration Guide

· 6 min read

Model Routing Overview

In a multi-model environment, different types of requests suit different models. OpenClaw's intelligent model routing automatically selects the most appropriate model based on message content, user attributes, and channel settings, achieving the optimal balance of performance and cost.

Basic Routing Configuration

{
  "routing": {
    "enabled": true,
    "defaultModel": "fast",
    "rules": [
      { "name": "code-tasks", "match": {"content": "code|programming|bug|function|debug|Python|JavaScript"}, "model": "code-expert" },
      { "name": "complex-reasoning", "match": {"content": "analyze|compare|reasoning|planning|strategy"}, "model": "smart" },
      { "name": "translation", "match": {"content": "translate|translation"}, "model": "translator" }
    ]
  }
}

Match Conditions

Supports matching by content (with regex), user, channel, message length, and combinations (AND logic). Rules are matched by priority from highest to lowest; the first match wins.

AI Classifier Routing

Use a lightweight model for intent classification, then route to the appropriate model:

{
  "routing": {
    "classifier": {
      "enabled": true,
      "model": "fast",
      "categories": {
        "coding": {"model": "code-expert"},
        "creative": {"model": "smart"},
        "translation": {"model": "translator"},
        "general": {"model": "fast"}
      }
    }
  }
}

Cost-Aware Routing

Route based on budget:

{
  "routing": {
    "costAware": {
      "enabled": true,
      "dailyBudget": 20.00,
      "thresholds": [
        {"usage": 0.8, "model": "fast"},
        {"usage": 0.5, "model": "smart"},
        {"usage": 0.0, "model": "premium"}
      ]
    }
  }
}

When daily spend is below 50% of budget, the best model is used; above 80%, it automatically downgrades.

Test Routing Rules

openclaw routing test "Help me write a Python sorting function"

Summary

Intelligent model routing lets OpenClaw make optimal selections in a multi-model environment. Through content-based, user-based, and budget-based routing rules, you can maximize resource efficiency while maintaining service quality.

OpenClaw is a free, open-source personal AI assistant that supports WhatsApp, Telegram, Discord, and many more platforms