What is Model Fallback?
When enabled, the proxy monitors quota exhaustion across all accounts. If every account runs out of quota for a requested model, the proxy automatically falls back to a pre-configured alternate model instead of returning an error.Fallback is disabled by default. Enable it with the
--fallback flag or FALLBACK=true environment variable.Why Use Fallback?
Continuous Availability
Keep your workflow running even when quota is exhausted for your preferred model.
Automatic Recovery
No manual intervention needed—the proxy handles failover automatically.
Similar Capabilities
Fallback models are chosen to match the original model’s capabilities (thinking, performance tier).
Transparent Logging
The proxy logs when fallback occurs so you can monitor quota usage.
Enabling Fallback
Enable fallback when starting the proxy:- CLI Flag
- Environment Variable
- Development Mode
Fallback Mappings
The proxy uses pre-configured fallback mappings between models. Thinking models fall back to other thinking models to preserve reasoning capabilities.Claude → Gemini Fallback
claude-opus-4-6-thinking
Falls back to gemini-3.1-pro-highBoth are high-capability thinking models optimized for complex reasoning.
claude-sonnet-4-5-thinking
Falls back to gemini-3-flashBoth are balanced thinking models with good speed and capability.
Gemini → Claude Fallback
gemini-3.1-pro-high
Falls back to claude-opus-4-6-thinkingHigh-performance thinking models for demanding tasks.
Fallback Map Table
| Primary Model | Fallback Model |
|---|---|
gemini-3.1-pro-high | claude-opus-4-6-thinking |
gemini-3.1-pro-low | claude-sonnet-4-5 |
gemini-3-flash | claude-sonnet-4-5-thinking |
claude-opus-4-6-thinking | gemini-3.1-pro-high |
claude-sonnet-4-5-thinking | gemini-3-flash |
claude-sonnet-4-5 | gemini-3-flash |
How Fallback Works
Exhaustion detected
If all accounts are exhausted or rate-limited for the requested model:
- Without fallback: Return error to client
- With fallback: Check if a fallback model exists
Example Scenario
Use Cases
Continuous Development
Testing & CI/CD
Production Resilience
Production Deployment
Monitoring Fallback Events
The proxy logs all fallback events for monitoring and debugging.Log Output
Checking Fallback Usage
In the Web Console:- Navigate to Logs
- Filter for “fallback” events
- Review which models triggered fallback
- Monitor quota recovery times
Limitations
Cross-model signature incompatibility
Cross-model signature incompatibility
When falling back between Claude and Gemini, thinking signatures may be incompatible and will be dropped automatically.
- Claude uses
signaturefield - Gemini uses
thoughtSignaturefield - The proxy detects incompatibility and cleans up signatures
- May lose some conversation context during fallback
No recursive fallback
No recursive fallback
If the fallback model is also exhausted, the proxy returns an error instead of trying another fallback.Example:
Performance differences
Performance differences
Fallback models have similar but not identical capabilities:
- Response quality may vary slightly
- Speed/latency characteristics differ
- Context window limits may differ
Quota consumption
Quota consumption
Fallback uses quota from the alternate model’s pool. If you frequently fall back, you may exhaust both model families.Best practice: Monitor quota usage and add accounts if fallback occurs frequently.
Best Practices
Monitor logs
Track fallback frequency to identify quota bottlenecks.
Add accounts
If fallback occurs regularly, add more Google accounts to increase quota.
Use quota thresholds
Set quota thresholds to switch accounts before exhaustion, reducing fallback needs.
Test both families
Regularly test with both Claude and Gemini to ensure fallback works as expected.
Recommended Configuration
For production use with fallback:~/.config/antigravity-proxy/config.json
Fallback API Reference
The fallback configuration is defined insrc/fallback-config.js and src/constants.js.
getFallbackModel()
Get the fallback model for a given primary model:hasFallback()
Check if a model has a fallback configured:MODEL_FALLBACK_MAP
Direct access to the fallback mapping:Troubleshooting
Fallback not triggering
Fallback not triggering
Check that:
- Fallback is enabled (
--fallbackorFALLBACK=true) - The requested model has a fallback mapping
- All accounts are actually exhausted (check
/account-limits) - Developer mode is enabled to see debug logs
Thinking signatures lost after fallback
Thinking signatures lost after fallback
This is expected behavior when switching between Claude and Gemini.
- The proxy automatically cleans up incompatible signatures
- Check logs for “signature cleanup” warnings
- Use the same model family (all Claude or all Gemini) to preserve signatures
Still getting quota errors with fallback enabled
Still getting quota errors with fallback enabled
Possible causes:
- Both primary and fallback models are exhausted
- Fallback is disabled on recursive calls
- Account selection strategy is excluding all accounts
Advanced: Custom Fallback Mappings
You can modify the fallback mappings by editingsrc/constants.js:
src/constants.js