Skip to content

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]

make sure metadata available and have a value (#9764)

Chaos Yu001043ba0592
diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.py
index dade6c933e6..785ad8dc290 100644
--- a/litellm/proxy/litellm_pre_call_utils.py
+++ b/litellm/proxy/litellm_pre_call_utils.py
@@ -528,7 +528,7 @@ async def add_litellm_data_to_request( # noqa: PLR0915
_metadata_variable_name = _get_metadata_variable_name(request)
- if _metadata_variable_name not in data:
+ if data.get(_metadata_variable_name, None) is None:
data[_metadata_variable_name] = {}
# We want to log the "metadata" from the client side request. Avoid circular reference by not directly assigning metadata to itself.