Topic Routing
Route by detected topic using a custom topic guard and cost-optimized models.
Use Case
Prerequisites
Configuration
{
"model": "router/dynamic",
"router": {
"type": "conditional",
"pre_request": [
{
"name": "topic_guard",
"type": "guard",
"guard_id": "{{topic_guard_slug}}"
}
],
"routes": [
{
"conditions": {
"all": [
{
"pre_request.topic_guard.passed": {
"$eq": true
}
}
]
},
"name": "faq_route",
"targets": {
"$any": [
"openai/gpt-4.1",
"openai/gpt-4.1-nano",
"openai/gpt-4.1-mini"
],
"sort_by": "price",
"sort_order": "min"
}
},
{
"conditions": {},
"name": "fallback_route",
"targets": {
"$any": [
"gemini/*"
],
"sort_by": "ttft",
"sort_order": "min"
}
}
]
}
}How It Works
Variables Used
Customization
Last updated
Was this helpful?