Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix _success_handler_helper_fn

Ishaan Jaffer9e3a8c4b0d98
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py
index 782f6dd2259..4d6fd351858 100644
--- a/litellm/litellm_core_utils/litellm_logging.py
+++ b/litellm/litellm_core_utils/litellm_logging.py
@@ -1571,12 +1571,14 @@ class Logging(LiteLLMLoggingBaseClass):
# MAP RESPONSES API USAGE OBJECT TO LITELLM USAGE OBJECT
if isinstance(result, ResponsesAPIResponse):
result = result.model_copy()
+ transformed_usage = ResponseAPILoggingUtils._transform_response_api_usage_to_chat_usage(
+ result.usage
+ )
+ # Set as dict instead of Usage object so model_dump() serializes it correctly
setattr(
result,
"usage",
- ResponseAPILoggingUtils._transform_response_api_usage_to_chat_usage(
- result.usage
- ),
+ transformed_usage.model_dump() if hasattr(transformed_usage, 'model_dump') else dict(transformed_usage),
)
if (