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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ResponseAPILoggingUtils): extract input tokens details as dict
Rhyse95b9b8015cb
diff --git a/litellm/responses/utils.py b/litellm/responses/utils.pyindex 469eeb3da06..39aebb262fe 100644--- a/litellm/responses/utils.py+++ b/litellm/responses/utils.py@@ -462,12 +462,17 @@ class ResponseAPILoggingUtils:completion_tokens: int = response_api_usage.output_tokens or 0prompt_tokens_details: Optional[PromptTokensDetailsWrapper] = Noneif response_api_usage.input_tokens_details:- prompt_tokens_details = PromptTokensDetailsWrapper(- cached_tokens=getattr(response_api_usage.input_tokens_details, "cached_tokens", None),- audio_tokens=getattr(response_api_usage.input_tokens_details, "audio_tokens", None),- text_tokens=getattr(response_api_usage.input_tokens_details, "text_tokens", None),- image_tokens=getattr(response_api_usage.input_tokens_details, "image_tokens", None),- )+ if isinstance(response_api_usage.input_tokens_details, dict):+ prompt_tokens_details = PromptTokensDetailsWrapper(+ **response_api_usage.input_tokens_details+ )+ else:+ prompt_tokens_details = PromptTokensDetailsWrapper(+ cached_tokens=getattr(response_api_usage.input_tokens_details, "cached_tokens", None),+ audio_tokens=getattr(response_api_usage.input_tokens_details, "audio_tokens", None),+ text_tokens=getattr(response_api_usage.input_tokens_details, "text_tokens", None),+ image_tokens=getattr(response_api_usage.input_tokens_details, "image_tokens", None),+ )completion_tokens_details: Optional[CompletionTokensDetailsWrapper] = Noneoutput_tokens_details = getattr(response_api_usage, "output_tokens_details", None)if output_tokens_details: