This feature is available on all Portkey plans.

Enabling Fallback on LLMs
To enable fallbacks, you can modify the config object to include thefallback
mode.
Here’s a quick example of a config to fallback to Anthropic’s claude-3.5-sonnet
if OpenAI’s gpt-4o
fails.
Triggering fallback on specific error codes
By default, fallback is triggered on any request that returns a non-2xx status code. You can change this behaviour by setting the optionalon_status_codes
param in your fallback config and manually inputting the status codes on which fallback will be triggered.
429
error code from the OpenAI request (i.e. rate limiting error)
Tracing Fallback Requests on Portkey
Portkey logs all the requests that are sent as a part of your fallback config. This allows you to easily trace and see which targets failed and see which ones were eventually successful. To see your fallback trace,- On the Logs page, first filter the logs with the specific
Config ID
where you’ve setup the fallback - this will show all the requests that have been sent with that config. - Now, trace an individual request and all the failed + successful logs for it by filtering further on
Trace ID
- this will show all the logs originating from a single request.

Caveats and Considerations
While the Fallback on LLMs feature greatly enhances the reliability and resilience of your application, there are a few things to consider:- Ensure the LLMs in your fallback list are compatible with your use case. Not all LLMs offer the same capabilities.
- Keep an eye on your usage with each LLM. Depending on your fallback list, a single request could result in multiple LLM invocations.
- Understand that each LLM has its own latency and pricing. Falling back to a different LLM could have implications on the cost and response time.