Cut LLM Costs with Automatic Provider Fallback
Route one model id across upstreams so AnyRouter picks the cheapest healthy provider and falls back when one fails.
Add a provider block to a Chat Completions request and AnyRouter picks among the upstreams that serve the model, skipping any that are failing. Prices are US dollars per million tokens.
| Field | Effect |
|---|---|
sort | Preference, such as "price" (cheapest healthy first) |
order | Explicit provider sequence |
max_price | Skip upstreams above the cap |
allow_fallbacks | Move on when an upstream errors or is rate-limited; false fails fast |
Cheapest healthy provider first, with fallback:
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-v1-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-120b",
"messages": [{"role": "user", "content": "Summarize this changelog in 3 bullets."}],
"provider": {
"sort": "price",
"max_price": { "prompt": 0.5, "completion": 1.5 },
"allow_fallbacks": true
}
}'To control the order instead, use "order": ["deepinfra", "cerebras"]: AnyRouter tries those first, then any other healthy upstream when allow_fallbacks is on. If no upstream is under max_price, the request returns an error rather than picking a pricier provider.
Save these preferences once as a preset and use its slug as the model.
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer