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
[Bug]: `/responses` endpoint proxy ignores extra_headers in GitHub Copilot (#13775)
Sam Xieee13c6570146
diff --git a/litellm/responses/litellm_completion_transformation/handler.py b/litellm/responses/litellm_completion_transformation/handler.pyindex 7b3243309b2..9317bf26178 100644--- a/litellm/responses/litellm_completion_transformation/handler.py+++ b/litellm/responses/litellm_completion_transformation/handler.py@@ -2,7 +2,7 @@Handler for transforming responses api requests to litellm.completion requests"""-from typing import Any, Coroutine, Optional, Union+from typing import Any, Coroutine, Dict, Optional, Unionimport litellmfrom litellm.responses.litellm_completion_transformation.streaming_iterator import (@@ -30,6 +30,7 @@ class LiteLLMCompletionTransformationHandler:custom_llm_provider: Optional[str] = None,_is_async: bool = False,stream: Optional[bool] = None,+ extra_headers: Optional[Dict[str, Any]] = None,**kwargs,) -> Union[ResponsesAPIResponse,@@ -45,6 +46,7 @@ class LiteLLMCompletionTransformationHandler:responses_api_request=responses_api_request,custom_llm_provider=custom_llm_provider,stream=stream,+ extra_headers=extra_headers,**kwargs,))diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.pyindex ba453edbf66..82d3980b370 100644--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@ -99,6 +99,7 @@ class LiteLLMCompletionResponsesConfig:responses_api_request: ResponsesAPIOptionalRequestParams,custom_llm_provider: Optional[str] = None,stream: Optional[bool] = None,+ extra_headers: Optional[Dict[str, Any]] = None,**kwargs,) -> dict:"""@@ -126,6 +127,7 @@ class LiteLLMCompletionResponsesConfig:"web_search_options": web_search_options,# litellm specific params"custom_llm_provider": custom_llm_provider,+ "extra_headers": extra_headers,}# Responses API `Completed` events require usage, we pass `stream_options` to litellm.completion to include usagediff --git a/litellm/responses/main.py b/litellm/responses/main.pyindex 6757e1ad31f..9584baf7368 100644--- a/litellm/responses/main.py+++ b/litellm/responses/main.py@@ -455,6 +455,7 @@ def responses(custom_llm_provider=custom_llm_provider,_is_async=_is_async,stream=stream,+ extra_headers=extra_headers,**kwargs,)diff --git a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.pyindex 8e38011279d..00fa0851a7b 100644--- a/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py+++ b/tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py@@ -541,7 +541,8 @@ class TestFunctionCallTransformation:result = LiteLLMCompletionResponsesConfig.transform_responses_api_request_to_chat_completion_request(model="gemini/gemini-2.0-flash",input=test_input,- responses_api_request=responses_api_request+ responses_api_request=responses_api_request,+ extra_headers={"X-Test-Header": "test-value"})assert "messages" in result@@ -563,6 +564,8 @@ class TestFunctionCallTransformation:tool_msg = messages[2]assert tool_msg["role"] == "tool"+ assert result["extra_headers"] == {"X-Test-Header": "test-value"}+def test_function_call_without_call_id_fallback_to_id(self):"""Test that function_call items can use 'id' field when 'call_id' is missing"""function_call_item = {