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
Clarify responses API streaming context
LingXuanYind101990342a7
diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.pyindex f571da3cd17..ac621b11b52 100644--- a/litellm/llms/custom_httpx/llm_http_handler.py+++ b/litellm/llms/custom_httpx/llm_http_handler.py@@ -2005,6 +2005,10 @@ class BaseLLMHTTPHandler:"""Handles responses API requests.When _is_async=True, returns a coroutine instead of making the call directly.++ Keeps the pre-transform request context for streaming so post-call hooks/metadata+ (added for Responses API parity with chat) receive the original params instead of+ the provider-shaped body that caused them to be skipped before."""if _is_async:@@ -2061,11 +2065,16 @@ class BaseLLMHTTPHandler:if extra_body:data.update(extra_body)+ # Preserve the OpenAI-style request context (not sent to the provider) for streaming+ # hooks/metadata; the streaming iterator now consumes this to run deployment hooks+ # with the same info as chat, including litellm_params.request_context: Dict[str, Any] = {"input": input}try:request_context.update(response_api_optional_request_params)except Exception:pass+ # Needed by streaming callbacks/metadata helpers to reconstruct api_base/model_id+ # but never included in the outbound provider payload.request_context["litellm_params"] = dict(litellm_params)## LOGGING@@ -2201,11 +2210,16 @@ class BaseLLMHTTPHandler:if extra_body:data.update(extra_body)+ # Preserve the OpenAI-style request context (not sent to the provider) for streaming+ # hooks/metadata; the streaming iterator now consumes this to run deployment hooks+ # with the same info as chat, including litellm_params.request_context: Dict[str, Any] = {"input": input}try:request_context.update(response_api_optional_request_params)except Exception:pass+ # Needed by streaming callbacks/metadata helpers to reconstruct api_base/model_id+ # but never included in the outbound provider payload.request_context["litellm_params"] = dict(litellm_params)## LOGGING