From e7d3615feec965bcad4877dd5b3cc4de94d67ae4 Mon Sep 17 00:00:00 2001 From: mrigasiyer Date: Tue, 10 Mar 2026 14:21:21 -0700 Subject: [PATCH] docs: note that LITELLM_ENFORCE_STREAMED_USAGE requires a server restart Add a comment in code and a note in docs clarifying that the env var is cached at module load time and changing it at runtime has no effect. Co-Authored-By: Claude Sonnet 4.6 --- docs/my-website/docs/completion/usage.md | 2 ++ litellm/proxy/common_request_processing.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/my-website/docs/completion/usage.md b/docs/my-website/docs/completion/usage.md index d65fc1e655f..ea41c166bb3 100644 --- a/docs/my-website/docs/completion/usage.md +++ b/docs/my-website/docs/completion/usage.md @@ -70,6 +70,8 @@ Or set the environment variable (no config file change needed): LITELLM_ENFORCE_STREAMED_USAGE=true ``` +> **Note:** This value is read once at server startup. Changing it at runtime has no effect — a server restart is required. + Alternatively, configure it through the UI: 1. Navigate to the LiteLLM Proxy UI diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py index 55182cafe61..6331db18f5c 100644 --- a/litellm/proxy/common_request_processing.py +++ b/litellm/proxy/common_request_processing.py @@ -53,7 +53,8 @@ StreamChunkSerializer = Callable[[Any], str] # Type alias for streaming error serializer (ProxyException -> wire format) StreamErrorSerializer = Callable[[ProxyException], str] -# Cached at module load time to avoid repeated env var lookups on every request +# Cached at module load time to avoid repeated env var lookups on every request. +# NOTE: changing this env var at runtime has no effect; a server restart is required. _ENFORCE_STREAMED_USAGE = ( os.environ.get("LITELLM_ENFORCE_STREAMED_USAGE", "false").lower() == "true" )