Skip to content

feat: add fallbackModel option for automatic model failover on provider errors#1136

Merged
homanp merged 4 commits intomainfrom
feat/model-fallback-on-provider-errors
Mar 10, 2026
Merged

feat: add fallbackModel option for automatic model failover on provider errors#1136
homanp merged 4 commits intomainfrom
feat/model-fallback-on-provider-errors

Conversation

@homanp
Copy link
Copy Markdown
Collaborator

@homanp homanp commented Mar 10, 2026

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

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Testing

Checklist

  • Code follows project style guidelines
  • Tests pass locally
  • Documentation updated (if needed)

…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.
@homanp homanp self-assigned this Mar 10, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Mar 10, 2026 2:51pm

Request Review

homanp added 2 commits March 10, 2026 15:31
…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.
@homanp homanp merged commit 0ee3e23 into main Mar 10, 2026
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant