What this thread does
Do first: Set keepalive_seconds: 15 under a deployment's litellm_params.
When you need it
Long silent gaps before a model's first token can make load balancers or reverse proxies close an idle-looking stream. Keepalive pings address these gaps separately from the total duration allowed by timeout and stream_timeout.
The setting
keepalive_seconds is a per-deployment interval in seconds. The effective enabled value is clamped to 1–300 seconds, and deployment-level 0 hard-disables pings. The feature stays off until an interval is set; client overrides are disabled by default. Timeouts states "The effective value is clamped to the range 1-300 seconds."
Trade-off
SSE comment frames do not change application content. Once a ping commits status 200, a later error arrives as an SSE frame instead of an HTTP error status. Allowing clients to extend idle-looking streams can also hold a max_parallel_requests slot longer than intended.
Steps
1. Use the page's deployment configuration (the page's entry also names its provider key through the environment variable ANTHROPIC_API_KEY; that line is omitted here):
model_list:
- model_name: claude-opus
litellm_params:
model: anthropic/claude-opus-5
keepalive_seconds: 15
2. Use the page's streaming request:
curl http://0.0.0.0:4000/v1/chat/completions \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LITELLM_API_KEY" \
-d '{
"model": "claude-opus",
"messages": [{"role": "user", "content": "Think step by step about..."}],
"stream": true
}'
3. If clients need control, the page allows allow_client_keepalive_override: true under the same litellm_params. Only then can a request's keepalive_seconds field or x-litellm-keepalive-seconds header override the deployment interval.
Check it worked
The page describes : ping SSE comment frames after silence exceeds the configured interval. They repeat at that interval until real content resumes; clients and intermediate proxies are expected to ignore these comments as content.
Limits
A deployment-level keepalive_seconds: 0 cannot be re-enabled by a client, even when overrides are allowed. Without override permission, the client's field or header has no effect. Before an upstream responds, the deployment interval applies only if all deployments behind the model name agree; otherwise the global interval applies until the serving deployment is known. The page does not name a version for keepalive pings.
Not for: general Nginx or Cloudflare stream timeout diagnosis; see ai-chat-stream-dies-after-60-or-125-seconds-nginx-cloudflare.
Sources
- Timeouts, LiteLLM documentation, read 2026-11-24: "Once a ping has gone out, the response has already started with status 200,"
Checked
2026-11-24; read <https://docs.litellm.ai/docs/proxy/timeout>; no command was run.
Started from a post by @LiteLLM, packaged by the editor. Original post