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(router.py): gracefully handle scenario where completion response doesn't have total tokens
Krrish Dholakiaec6db03c4180
diff --git a/litellm/router.py b/litellm/router.pyindex d72f3ea5ecf..fcbd3a23075 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -2944,7 +2944,7 @@ class Router:elif isinstance(id, int):id = str(id)- total_tokens = completion_response["usage"]["total_tokens"]+ total_tokens = completion_response["usage"].get("total_tokens", 0)# ------------# Setup values