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
Allow DB fallback for failure metadata enrichment lookups
yuneng-jiangaa48a7ec0000
diff --git a/litellm/proxy/hooks/proxy_track_cost_callback.py b/litellm/proxy/hooks/proxy_track_cost_callback.pyindex 214c92b6470..0734756d8ed 100644--- a/litellm/proxy/hooks/proxy_track_cost_callback.py+++ b/litellm/proxy/hooks/proxy_track_cost_callback.py@@ -263,7 +263,7 @@ class _ProxyDBLogger(CustomLogger):async def _enrich_failure_metadata_with_key_info(metadata: dict) -> dict:"""Enriches failure spend log metadata by looking up the key object (and team object)- from cache when key fields are missing.+ from cache/DB when key fields are missing.This handles two scenarios:1. Auth errors (401): UserAPIKeyAuth is created with only api_key set, all other@@ -291,7 +291,6 @@ class _ProxyDBLogger(CustomLogger):prisma_client=prisma_client,user_api_key_cache=user_api_key_cache,proxy_logging_obj=proxy_logging_obj,- check_cache_only=True,)if metadata.get("user_api_key_alias") is None:metadata["user_api_key_alias"] = key_obj.key_alias@@ -316,7 +315,6 @@ class _ProxyDBLogger(CustomLogger):prisma_client=prisma_client,user_api_key_cache=user_api_key_cache,proxy_logging_obj=proxy_logging_obj,- check_cache_only=True,)if team_obj.team_alias is not None:metadata["user_api_key_team_alias"] = team_obj.team_alias