From 2056c94c4fdc21f0673029de676682d1c6dd657a Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Thu, 26 Feb 2026 11:23:06 -0800 Subject: [PATCH] add LITELLM_MAX_STREAMING_DURATION_SECONDS --- litellm/constants.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/litellm/constants.py b/litellm/constants.py index b1a0021bcc6..d34c369e4cf 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -49,6 +49,14 @@ DEFAULT_REPLICATE_POLLING_DELAY_SECONDS = int( ) DEFAULT_IMAGE_TOKEN_COUNT = int(os.getenv("DEFAULT_IMAGE_TOKEN_COUNT", 250)) +# Maximum wall-clock seconds a streaming response is allowed to run. +# Streams exceeding this duration are terminated with a Timeout error. +# None (default) = no limit. Set env var to a number of seconds to enable globally. +_max_stream_duration_env = os.getenv("LITELLM_MAX_STREAMING_DURATION_SECONDS", None) +MAX_STREAMING_CHUNK_DURATION_S = ( + float(_max_stream_duration_env) if _max_stream_duration_env is not None else None +) + # Maximum number of base64 characters to keep in logging payloads. # Data URIs exceeding this are replaced with a size placeholder. # Set to 0 to disable truncation.