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: Change extra_headers to additional_headers (#17950)

Lucas Sugi9f88d61d1038
diff --git a/litellm/llms/azure/realtime/handler.py b/litellm/llms/azure/realtime/handler.py
index 217a05c83a4..e533978e07a 100644
--- a/litellm/llms/azure/realtime/handler.py
+++ b/litellm/llms/azure/realtime/handler.py
@@ -94,7 +94,7 @@ class AzureOpenAIRealtime(AzureChatCompletion):
ssl_context = get_shared_realtime_ssl_context()
async with websockets.connect( # type: ignore
url,
- extra_headers={
+ additional_headers={
"api-key": api_key, # type: ignore
},
max_size=REALTIME_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES,
diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py
index 4b38f542159..a777ea3c42e 100644
--- a/litellm/llms/custom_httpx/llm_http_handler.py
+++ b/litellm/llms/custom_httpx/llm_http_handler.py
@@ -3646,7 +3646,7 @@ class BaseLLMHTTPHandler:
ssl_context = get_shared_realtime_ssl_context()
async with websockets.connect( # type: ignore
url,
- extra_headers=headers,
+ additional_headers=headers,
max_size=REALTIME_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES,
ssl=ssl_context,
) as backend_ws:
diff --git a/litellm/llms/openai/realtime/handler.py b/litellm/llms/openai/realtime/handler.py
index 882309bb2fa..3ae4d2bc9f7 100644
--- a/litellm/llms/openai/realtime/handler.py
+++ b/litellm/llms/openai/realtime/handler.py
@@ -59,7 +59,7 @@ class OpenAIRealtime(OpenAIChatCompletion):
ssl_context = get_shared_realtime_ssl_context()
async with websockets.connect( # type: ignore
url,
- extra_headers={
+ additional_headers={
"Authorization": f"Bearer {api_key}", # type: ignore
"OpenAI-Beta": "realtime=v1",
},
diff --git a/litellm/realtime_api/main.py b/litellm/realtime_api/main.py
index e73004c5e1f..fe686598141 100644
--- a/litellm/realtime_api/main.py
+++ b/litellm/realtime_api/main.py
@@ -196,7 +196,7 @@ async def _realtime_health_check(
ssl_context = get_shared_realtime_ssl_context()
async with websockets.connect( # type: ignore
url,
- extra_headers={
+ additional_headers={
"api-key": api_key, # type: ignore
},
max_size=REALTIME_WEBSOCKET_MAX_MESSAGE_SIZE_BYTES,
diff --git a/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py b/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py
index 3a446a2048e..eb9f8027761 100644
--- a/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py
+++ b/tests/test_litellm/llms/openai/realtime/test_openai_realtime_handler.py
@@ -195,10 +195,10 @@ async def test_async_realtime_url_contains_model():
# Verify proper headers were set
called_kwargs = mock_ws_connect.call_args[1]
- assert "extra_headers" in called_kwargs
- extra_headers = called_kwargs["extra_headers"]
- assert extra_headers["Authorization"] == f"Bearer {api_key}"
- assert extra_headers["OpenAI-Beta"] == "realtime=v1"
+ assert "additional_headers" in called_kwargs
+ additional_headers = called_kwargs["additional_headers"]
+ assert additional_headers["Authorization"] == f"Bearer {api_key}"
+ assert additional_headers["OpenAI-Beta"] == "realtime=v1"
assert called_kwargs["ssl"] is shared_context
mock_realtime_streaming.assert_called_once()