Why fallbacks matter
AI provider reliability is not guaranteed. Providers can:- Go down — planned or unplanned outages affect even major providers
- Rate limit your account — high-traffic periods can trigger 429 responses
- Introduce latency spikes — cold model starts or traffic surges slow responses significantly
Setting up fallbacks
Using the x-portrix-fallback header
Pass a comma-separated list of fallback model IDs in the x-portrix-fallback header. Portrix tries the primary model first, then each fallback in the order listed.
- Attempt
openai/gpt-4ofirst - If that fails, attempt
anthropic/claude-3-5-sonnet - If that also fails, attempt
mistral/mistral-large - If all three fail, return an error to the caller
Fallback conditions
Portrix triggers a fallback when the upstream provider returns any of the following:
Fallbacks are not triggered for client errors (
4xx other than 429), such as invalid request shapes or authentication failures. Those are returned immediately.
Load balancing
Using x-portrix-route: balanced
When you want to spread traffic evenly across multiple models — distributing cost or staying within per-provider rate limits — set the routing strategy to balanced alongside a fallback list:
balanced routing, Portrix distributes requests round-robin across openai/gpt-4o, anthropic/claude-3-5-sonnet, and google/gemini-2.0-flash. If any node is unhealthy, it is temporarily removed from the rotation and the remaining nodes absorb its share.
Available routing strategies:
Dashboard configuration
Sending headers on every request works well for dynamic configurations, but for stable production setups you can define named routes in the Portrix dashboard:1
Open the Routes section
Navigate to Gateway → Routes in the Portrix dashboard.
2
Create a new route
Click New Route, give it a name (e.g.
production-chat), and add your primary model plus ordered fallbacks.3
Set the routing strategy
Choose
balanced, cheapest, or fastest from the dropdown.4
Use the route name in requests
Reference the route by name instead of a model ID:
Testing fallbacks
To verify your fallback chain is working, temporarily swap the primary model for an invalid model ID. Portrix will fail on the primary and cascade to your first fallback:model field in the response reflects whichever model actually served the request, making it easy to confirm which fallback was used.