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(responses): add int tokens before summing usage totals
Yang Yang1705f86d50dc
diff --git a/litellm/responses/utils.py b/litellm/responses/utils.pyindex c923831b3de..6d2cce5449f 100644--- a/litellm/responses/utils.py+++ b/litellm/responses/utils.py@@ -1063,13 +1063,11 @@ class ResponseAPILoggingUtils:usage_input["input_tokens_details"] = usage_input["input_token_details"]if usage_input.get("output_tokens_details") is None and "output_token_details" in usage_input:usage_input["output_tokens_details"] = usage_input["output_token_details"]- total_tokens = usage_input.get("total_tokens")- if total_tokens is None:+ if usage_input.get("total_tokens") is None:input_tokens: Final = usage_input.get("input_tokens")output_tokens: Final = usage_input.get("output_tokens")- if input_tokens is not None and output_tokens is not None:- total_tokens = input_tokens + output_tokens- usage_input["total_tokens"] = total_tokens+ if isinstance(input_tokens, int) and isinstance(output_tokens, int):+ usage_input["total_tokens"] = input_tokens + output_tokensresponse_api_usage = ResponseAPIUsage(**usage_input)else:response_api_usage = usage_input