LiteLLM Proxy with Fallbacks and Load Balancing
An OpenAI-compatible gateway that load-balances deployments and falls back across providers on errors.
config.yaml
model_list:
- model_name: chat-default
litellm_params:
model: openai/gpt-6-luna
api_key: os.environ/OPENAI_API_KEY
- model_name: chat-default # same name = load-balanced group
litellm_params:
model: azure/my-gpt4o-mini-deployment
api_base: os.environ/AZURE_API_BASE
api_key: os.environ/AZURE_API_KEY
- model_name: chat-backup
litellm_params:
model: anthropic/claude-haiku-5-5
api_key: os.environ/ANTHROPIC_API_KEY
router_settings:
routing_strategy: simple-shuffle
num_retries: 2
timeout: 30
fallbacks:
- chat-default: [chat-backup]Run
pip install 'litellm[proxy]'
litellm --config config.yaml --port 4000
curl http://localhost:4000/v1/chat/completions -H 'Content-Type: application/json' \
-d '{"model":"chat-default","messages":[{"role":"user","content":"hi"}]}'Point any OpenAI SDK at http://localhost:4000 as the base URL. Check model identifiers against your providers' current model lists.
Failure modes
- Fallbacks hide outages; log which model actually answered.
- Backup models format structured output differently; test them on the same prompts.
- Retries multiply cost and latency; keep num_retries low and set a timeout.
Markdown version: /blueprints/litellm-fallback-router.md
Want a deeper build of this?
Vote for an extended, fully tested version (more tools, a full workflow file). Votes decide what we build next.
Get one fully built blueprint a week
A weekly email: one blueprint with config, cost, setup time and failure modes, plus a vote on what we build next.
Related blueprints
Complexity-Based Cheap/Strong Model Router
Route easy requests to a cheap model and hard ones to a strong model using a lightweight classifier plus escalation.
Local-First Routing with Ollama and Cloud Fallback
Serve requests from a local Ollama model, falling back to a cloud model only when local fails or the task needs it.
OpenRouter Model Fallback and Provider Ordering
Use OpenRouter's request-level models array and provider preferences for automatic failover.