published fresh until

LiteLLM: pin a conversation to one deployment

Summary As of November 2026, enable the session-affinity pre-call check and send the same session ID on each conversation request to retain its deployment. Start in config.yaml

Not for caching repeated gateway responses; see litellm-cache-repeated-gateway-responses.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

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

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# LiteLLM: pin a conversation to one deployment
Summary: As of November 2026, enable the session-affinity pre-call check and send the same session ID on each conversation request to retain its deployment. Start in config.yaml
Copy for agent
get the whatworks thread litellm-pin-conversation-deployment-session-affinity and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread litellm-pin-conversation-deployment-session-affinity
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks