How it works
Setstrategy.mode to "conditional" and define a list of conditions. Each condition specifies:
query— a filter object evaluated against the request contextthen— the name of the target to route to when the condition matches
default target is used.
Passing metadata
Attach metadata to your request using thex-portkey-metadata header. Metadata values must be strings.
Query operators
Condition queries support MongoDB-style comparison and logical operators:Numeric comparison example
Route high-token-budget requests to a more capable model:Multi-condition with $or
Routing context keys
Queries can reference two namespaces:Metadata values are always strings. Use string comparisons for
$gte, $lte, and similar numeric operators — the gateway parses them as floats for comparison.