diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py index 96fb34c11b8..4a3e92798da 100644 --- a/litellm/proxy/common_request_processing.py +++ b/litellm/proxy/common_request_processing.py @@ -789,6 +789,10 @@ class ProxyBaseLLMRequestProcessing: self.data["litellm_call_id_from_client"] = True else: self.data["litellm_call_id"] = str(uuid.uuid4()) + # Defensive: explicitly clear the flag so a body-injected + # `litellm_call_id_from_client: true` cannot flip precedence + # in get_spend_logs_id when no header was actually supplied. + self.data["litellm_call_id_from_client"] = False DDSpanTagger.tag_call_id(self.data.get("litellm_call_id")) DDSpanTagger.tag_request( user_api_key_dict=user_api_key_dict, diff --git a/litellm/proxy/google_endpoints/endpoints.py b/litellm/proxy/google_endpoints/endpoints.py index bf74fcacbf7..aa287ce3f16 100644 --- a/litellm/proxy/google_endpoints/endpoints.py +++ b/litellm/proxy/google_endpoints/endpoints.py @@ -64,6 +64,10 @@ async def google_generate_content( data["litellm_call_id_from_client"] = True else: data["litellm_call_id"] = str(uuid.uuid4()) + # Defensive: explicitly clear the flag so a body-injected + # `litellm_call_id_from_client: true` cannot flip precedence + # in get_spend_logs_id when no header was actually supplied. + data["litellm_call_id_from_client"] = False logging_obj, data = litellm.utils.function_setup( original_function="agenerate_content", rules_obj=litellm.utils.Rules(), @@ -130,6 +134,10 @@ async def google_stream_generate_content( data["litellm_call_id_from_client"] = True else: data["litellm_call_id"] = str(uuid.uuid4()) + # Defensive: explicitly clear the flag so a body-injected + # `litellm_call_id_from_client: true` cannot flip precedence + # in get_spend_logs_id when no header was actually supplied. + data["litellm_call_id_from_client"] = False logging_obj, data = litellm.utils.function_setup( original_function="agenerate_content_stream", rules_obj=litellm.utils.Rules(),