From 8140f6caf260bbeb8e8e8fb72024a4fad172225c Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Wed, 18 Feb 2026 12:33:15 -0800 Subject: [PATCH] fix(proxy): remove per-chunk debug log and use _usage_stripped flag - Remove verbose_proxy_logger.debug that formatted every streaming chunk - Honor _usage_stripped flag from streaming handler to exclude usage during model_dump_json serialization instead of reconstructing objects --- litellm/proxy/proxy_server.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 7d1067f7b05..c536baa23d5 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -5074,10 +5074,6 @@ async def async_data_generator( response=response, request_data=request_data, ): - verbose_proxy_logger.debug( - "async_data_generator: received streaming chunk - {}".format(chunk) - ) - ### CALL HOOKS ### - modify outgoing data chunk = await proxy_logging_obj.async_post_call_streaming_hook( user_api_key_dict=user_api_key_dict, @@ -5098,7 +5094,14 @@ async def async_data_generator( ) if isinstance(chunk, BaseModel): - chunk = chunk.model_dump_json(exclude_none=True, exclude_unset=True) + if getattr(chunk, "_usage_stripped", False): + chunk = chunk.model_dump_json( + exclude_none=True, exclude_unset=True, exclude={"usage"} # type: ignore + ) + else: + chunk = chunk.model_dump_json( + exclude_none=True, exclude_unset=True + ) elif isinstance(chunk, str) and chunk.startswith("data: "): error_message = chunk break