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]

fix(streaming_handler.py): fix check when response id already set

Krrish Dholakiae156636b8e60
diff --git a/litellm/litellm_core_utils/streaming_handler.py b/litellm/litellm_core_utils/streaming_handler.py
index a0767c09ee2..dcc6ea36a30 100644
--- a/litellm/litellm_core_utils/streaming_handler.py
+++ b/litellm/litellm_core_utils/streaming_handler.py
@@ -697,11 +697,12 @@ class CustomStreamWrapper:
If a valid ID is received in any chunk, use it for the response.
"""
- if id and isinstance(id, str) and id.strip():
- self.response_id = id
- elif self.response_id is None:
+ if self.response_id is None and id and isinstance(id, str) and id.strip():
self.response_id = id
+ if id and isinstance(id, str) and id.strip():
+ model_response._hidden_params["received_model_id"] = id
+
if self.response_id is not None and isinstance(self.response_id, str):
model_response.id = self.response_id
return model_response