feat: add fallbackModel option for automatic model failover on provider errors#1136
Merged
feat: add fallbackModel option for automatic model failover on provider errors#1136
Conversation
…er errors When a primary model returns a retryable HTTP status (429, 500, 502, 503), the SDK now automatically re-issues the request to a user-specified fallback model. This unblocks users hitting transient "high demand" errors on models like Gemini 2.5 Flash Lite by transparently offloading to a backup model (e.g., Gemini 2.5 Pro). The fallback model gets a single attempt to prevent infinite loops and can be from a completely different provider. Adds fallbackModel/fallback_model to GuardOptions, RedactOptions, and ScanOptions in both TypeScript and Python SDKs with full test coverage.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…rences Adds a "Model Fallback" section under Client Configuration explaining the feature with code examples, and adds the fallbackModel/fallback_model field to the guard, redact, and scan options tables in both SDK pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a primary model returns a retryable HTTP status (429, 500, 502, 503), the SDK now automatically re-issues the request to a user-specified fallback model. This unblocks users hitting transient "high demand" errors on models like Gemini 2.5 Flash Lite by transparently offloading to a backup model (e.g., Gemini 2.5 Pro). The fallback model gets a single attempt to prevent infinite loops and can be from a completely different provider.
Adds fallbackModel/fallback_model to GuardOptions, RedactOptions, and ScanOptions in both TypeScript and Python SDKs with full test coverage.
Type of Change
Testing
Checklist