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 Vertex label metadata fallback
Cursor Agent21c7864d752b
diff --git a/litellm/llms/vertex_ai/common_utils.py b/litellm/llms/vertex_ai/common_utils.pyindex 4f69e3bbad4..fae175612b1 100644--- a/litellm/llms/vertex_ai/common_utils.py+++ b/litellm/llms/vertex_ai/common_utils.py@@ -69,7 +69,7 @@ def pop_vertex_request_labels(raw = optional_params.pop("labels")if isinstance(raw, dict):labels = {k: v for k, v in raw.items() if isinstance(v, str)}- if labels is None:+ if not labels:labels = vertex_request_labels_from_litellm_params(litellm_params)return labels if labels else Nonediff --git a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.pyindex 01c11e15543..7cb3faf6177 100644--- a/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py+++ b/tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py@@ -1482,6 +1482,9 @@ def test_pop_vertex_request_labels_prefers_explicit_labels_then_metadata():optional2: dict = {}assert pop_vertex_request_labels(optional2, litellm_params) == {"team": "x"}+ optional3 = {"labels": {"team": 123}}+ assert pop_vertex_request_labels(optional3, litellm_params) == {"team": "x"}+def test_pop_vertex_request_labels_uses_litellm_metadata_when_metadata_absent():optional: dict = {}