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]

docs: add inline comment clarifying intentional falsy id behavior

Ryan Crabbec039e505baa1
diff --git a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
index a4a68255e80..0f7779e8b5c 100644
--- a/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
+++ b/litellm/litellm_core_utils/llm_response_utils/convert_dict_to_response.py
@@ -628,6 +628,8 @@ def convert_to_model_response_object( # noqa: PLR0915
)
if "id" in response_object:
+ # Preserve the auto-generated id from ModelResponse.__init__
+ # when the provider returns a falsy id (None, "")
model_response_object.id = response_object["id"] or model_response_object.id
if "system_fingerprint" in response_object: