ResilientModel wraps any model with automatic key rotation and provider failover. It handles rate limits (429) transparently.
Key Rotation
Distribute load across multiple API keys:
When a key gets rate-limited (HTTP 429), it enters cooldown with exponential backoff. The next key in the pool is used automatically.
Provider Failover
Fall back to alternative providers when one fails:
If the primary model fails, ResilientModel tries each failover entry in priority order.
Key Pool Options
API keys to rotate between.
Selection strategy: round_robin or lru (least recently used).
Base cooldown time for rate-limited keys.
Events
Imports