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(guardrails): avoid mutable dict literal in guardrail metadata population
Yucheng Zhuca9e121eb671
diff --git a/litellm/proxy/hooks/proxy_track_cost_callback.py b/litellm/proxy/hooks/proxy_track_cost_callback.pyindex ca8341822e9..b78884f7d95 100644--- a/litellm/proxy/hooks/proxy_track_cost_callback.py+++ b/litellm/proxy/hooks/proxy_track_cost_callback.py@@ -273,13 +273,16 @@ class _ProxyDBLogger(CustomLogger):# guardrail_information is missing from SLP. Populate it from post-call evals# before spend-log write so reports show accurate guardrail results.if sl_object is not None:+ litellm_metadata: Final = kwargs.get("litellm_metadata")guardrail_info_from_hooks: Final = (- kwargs.get("litellm_metadata", {}).get("standard_logging_guardrail_information")- if isinstance(kwargs.get("litellm_metadata"), dict)+ litellm_metadata.get("standard_logging_guardrail_information")+ if isinstance(litellm_metadata, dict)else None)if guardrail_info_from_hooks is not None and not sl_object.get("guardrail_information"):- sl_object["guardrail_information"] = guardrail_info_from_hooks+ sl_object["guardrail_information"] = (+ guardrail_info_from_hooks # mutable-ok: populate SLP before spend-log write+ )if response_cost is not None:user_api_key: Final = metadata.get("user_api_key", None)