Skip to content
docs

Autorouting

With autorouting, the router picks the model instead of your client. Pass waibee/auto in the model field instead of a specific ID.

autorouting.sh
curl https://api.waibee.com/v1/chat/completions \
-H "Authorization: Bearer $WAIBEE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "waibee/auto",
"messages": [{ "role": "user", "content": "Reply with one word: ok" }]
}'

The model field in the response holds the model that actually ran, not waibee/auto:

{
"model": "google/gemini-3.7-flash",
"choices": [{ "index": 0, "finish_reason": "stop",
"message": { "role": "assistant", "content": "ok" } }],
"usage": { "prompt_tokens": 6, "completion_tokens": 75, "total_tokens": 81 }
}

Autorouting works on all three endpoints: POST /v1/chat/completions, POST /v1/messages, and POST /v1/responses.

A short question goes to a cheap model, a hard task to a strong one, and a request with an image to a model that accepts images. You do not have to watch the catalog or change IDs when new models appear.

The router looks at the request itself:

SignalEffect
Text of the request and the system promptEstimates how hard the task is: a quick lookup or system design
AttachmentsAn image or audio in the input leaves only models with that modality
toolsRequires tool calling support
reasoning_effort or reasoning.effort, or thinking with budget_tokens on /v1/messagesRequires a reasoning model
response_format (text.format on /v1/responses)json_schema requires structured outputs support, and json_object requires response_format support
cache_control markersLeaves only models that understand cache_control, currently Anthropic models
Request sizeDrops models whose context window is too small

The router picks among the models your group allows for autorouting. This is a separate setting: autorouting can pick a model you cannot request by name, and the other way around.

If autorouting is available to your group, waibee/auto is in the catalog.

The router recognizes a continuing conversation by its content and tries to keep the model it picked for it. It can switch models, for example when the conversation no longer fits that model’s context window.

This matters most with cache_control markers: the cache is held by a specific model, and switching to another one would reset cache hits. See Prompt caching.

Selection errors apply only to waibee/auto and come with status 422.

CodeWhen
auto_routing_no_matchNo suitable model is left after filtering by capabilities and policies
auto_routing_request_too_largeThe request does not fit the context window of any available model
auto_routing_caching_unavailablePrompt caching was requested, but no suitable model supports it
auto_routing_missing_contextInternal selection error: retry the request, and if it happens again, contact support

The details of the rejection are in extra (in details on /v1/messages and /v1/responses): which filter emptied the list of models, which capabilities were required, and what to do about it.

422
{
"error": {
"code": "auto_routing_request_too_large",
"message": "No model matches the auto-routing requirements",
"extra": {
"required_capabilities": [],
"filter_step_dropped_at": "context",
"pool_size_initial": 73,
"pool_size_after_filter": 0,
"recommendation": "The request is too large...",
"auto_routing_decision_id": "e0e62376-55c2-4e06-98cb-90dc6640d451",
"tier_attempted": "standard"
}
}
}

If you get these errors regularly, specify the model explicitly; see Models. Include auto_routing_decision_id when you contact support.

waibee/auto requires a minimum balance. Below it, the request is rejected with 402 and the code insufficient_funds, and message names the amount required. Top up your balance or specify the model explicitly.

  • The cost of a request depends on the model picked. Calculate it from the model and usage pair in the response; see Tokens and usage.
  • Where you need reproducible results, specify the model explicitly. Tests, benchmarks, prompt comparisons, and a prompt tuned for a specific model only make sense on a fixed model.