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