Multi-provider LLM resilience in Python without provider-specific code
OpenAI, Anthropic, and Google expose different APIs, message formats, tool-calling conventions, error types, and response structures. That difference is manageable while an application uses only one provider. It becomes more expensive when the application needs retries, circuit breakers, fallback routes, observability, and recovery across several providers. Without a shared abstraction, resilience logic tends to be implemented repeatedly: OpenAI integration ├── request conversion ├── retry logic ├── error classification ├── circuit breaker └── tool-call recovery Anthropic integration ├── request conversion ├── retry logic ├── error classification ├── circuit breaker └── tool-call recovery Google integration ├── request conversion ├── retry logic ├── error classification ├── circuit breaker └── tool-call recovery I did not want to build resilience three times. I wanted to define the recovery policy once and apply it across every provider supported by the application. That became llm-api-resilience , a Python library for retries, ordered failover, circuit breakers, and checkpoint recovery across multiple LLM providers. Quick start pip install llm-api-resilience Once the provider adapters are configured, an ordered fallback plan takes only a few lines: from llm_api_resilience import RecoveryPlan , ResilientLLM , Route llm = ResilientLLM ( RecoveryPlan ( [ Route ( " openai-primary " , openai_adapter ), Route ( " anthropic-backup " , anthropic_adapter ), Route ( " google-last-resort " , google_adapter ), ] ) ) response = llm . chat ( [{ " role " : " user " , " content " : " Explain circuit breakers briefly. " }] ) print ( response . selected_route ) print ( response . content ) GitHub: llm-api-resilience Provider adapter: llm-api-adapter The library is built on top of llm-api-adapter , which provides one interface for OpenAI, Anthropic, and Google. Because provider-specific differences are handled by the adapter, the resilience layer can operate on a shared contract inst