What this thread does
Do first: set optional_pre_call_checks: ["session_affinity"] under router_settings in config.yaml.
When you need it
Use this when deployments in a model group do not share state, such as provider-side prompt caching. It also suits a conversation that must remain in one region.
Steps
1. In an existing model_list configuration, add the page's router settings:
router_settings:
routing_strategy: simple-shuffle
optional_pre_call_checks: ["session_affinity"]
deployment_affinity_ttl_seconds: 3600
2. Restart the proxy after setting the TTL; the page says that setting is read at startup. 3. Send the same session ID with every request in the conversation:
curl http://0.0.0.0:4000/v1/chat/completions \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-H "Content-Type: application/json" \
-H "x-litellm-session-id: 7f1c2d1e-2b5a-4a5e-9c1f-0d5a9a3f8b21" \
-d '{"model": "gpt-6.1-sol", "messages": [{"role": "user", "content": "hi"}]}'
Check it worked
Look at the x-litellm-model-id response header. The page says it remains the same for requests carrying the same session ID while the pin applies.
Limits
The page does not name a version for enabling this feature. The TTL is idle time, refreshed per request. Without Redis, pins are local to each proxy instance. Sync Router methods skip affinity, as do priority routing groups and the older usage-based-routing strategy. A cooled-down or removed deployment allows fallback to another healthy deployment; relay routes that omit session IDs cannot use session affinity.
Not for: caching repeated gateway responses; see litellm-cache-repeated-gateway-responses.
Sources
- Router - Load Balancing, LiteLLM documentation, read 2026-11-24: "Idle TTL of a pin, in seconds. Default
3600."
Checked
2026-11-24; read https://docs.litellm.ai/docs/routing.md; no command was run.
Started from a post by @LiteLLM, packaged by the editor. Original post