Back to library
AI
best practice

Implement Automatic Model Failovers for Refused Requests

Ensure continuous uptime by setting up automatic model fallbacks for refusals.

Implement the 'fallbacks' API parameter to automatically re-run prompts on a secondary model if the primary model issues a safety refusal.

Claude

The Scenario

Your AI application is being used by diverse users and occasionally hits safety 'refusal' stop reasons. You want to ensure the user experience isn't interrupted by a hard error.

Before & after

The old way

When a request was blocked by a safety classifier, the application would simply fail or require complex 'try-catch' logic to manually retry with a different model. Designing this error handling manually usually took 15–20 minutes.

With AI

By using the 'fallbacks' parameter in the Claude API, the system automatically redirects a blocked request to your chosen backup model. This fail-safe mechanism takes 1 minute to add to your API call code.

The Prompt

Review my existing Claude API request code and show me how to implement the 'fallbacks' parameter to ensure that if [MODEL_NAME] refuses a request, it automatically fails over to [BACKUP_MODEL]. [PASTE_CODE_HERE]

Claude Fable 5 introduces an opt-in 'fallbacks' parameter. If the primary model refuses a request due to safety filters, the system can automatically re-run the prompt on a different model (like a smaller, faster one) without requiring a new round-trip request from your application.

Source

Claude Platform - Claude API Docs
"An opt-in fallbacks parameter... re-runs refused requests on another model, billed at the fallback model's rates."