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: Azure OpenAI GA path relies soley on model paramter as deployment

abi_jey4cf7a74e6092
diff --git a/litellm/llms/azure/realtime/handler.py b/litellm/llms/azure/realtime/handler.py
index 0dc42dad43e..217a05c83a4 100644
--- a/litellm/llms/azure/realtime/handler.py
+++ b/litellm/llms/azure/realtime/handler.py
@@ -12,6 +12,7 @@ from ....litellm_core_utils.litellm_logging import Logging as LiteLLMLogging
from ....litellm_core_utils.realtime_streaming import RealTimeStreaming
from ....llms.custom_httpx.http_handler import get_shared_realtime_ssl_context
from ..azure import AzureChatCompletion
+from litellm._logging import verbose_proxy_logger
# BACKEND_WS_URL = "ws://localhost:8080/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01"
@@ -51,18 +52,18 @@ class AzureOpenAIRealtime(AzureChatCompletion):
Examples:
beta/default: "wss://.../openai/realtime?api-version=2024-10-01-preview&deployment=gpt-4o-realtime-preview"
- GA/v1: "wss://.../openai/v1/realtime?api-version=2024-10-01-preview&deployment=gpt-4o-realtime-preview"
+ GA/v1: "wss://.../openai/v1/realtime?model=gpt-realtime-deployment"
"""
api_base = api_base.replace("https://", "wss://")
# Determine path based on realtime_protocol
if realtime_protocol in ("GA", "v1"):
- path = "/openai/v1/realtime"
+ path = "/openai/v1/realtime"
+ return f"{api_base}{path}?model={model}"
else:
# Default to beta path for backwards compatibility
path = "/openai/realtime"
-
- return f"{api_base}{path}?api-version={api_version}&deployment={model}"
+ return f"{api_base}{path}?api-version={api_version}&deployment={model}"
async def async_realtime(
self,
@@ -107,4 +108,5 @@ class AzureOpenAIRealtime(AzureChatCompletion):
except websockets.exceptions.InvalidStatusCode as e: # type: ignore
await websocket.close(code=e.status_code, reason=str(e))
except Exception:
+ verbose_proxy_logger.exception("Error in AzureOpenAIRealtime.async_realtime")
pass
diff --git a/tests/test_litellm/llms/azure/realtime/test_azure_realtime_handler.py b/tests/test_litellm/llms/azure/realtime/test_azure_realtime_handler.py
index ca8d01e158f..2a110c8f9a7 100644
--- a/tests/test_litellm/llms/azure/realtime/test_azure_realtime_handler.py
+++ b/tests/test_litellm/llms/azure/realtime/test_azure_realtime_handler.py
@@ -117,6 +117,7 @@ async def test_construct_url_beta_protocol_explicit():
async def test_construct_url_ga_protocol():
"""
Test that realtime_protocol='GA' uses /openai/v1/realtime (GA path).
+ GA path uses ?model= instead of ?api-version=&deployment= format.
"""
from litellm.llms.azure.realtime.handler import AzureOpenAIRealtime
@@ -132,8 +133,10 @@ async def test_construct_url_ga_protocol():
assert "/openai/v1/realtime?" in url
# Ensure it doesn't have both paths
assert url.count("/realtime") == 1
- assert "api-version=2024-10-01-preview" in url
- assert "deployment=gpt-4o-realtime-preview" in url
+ # GA path uses model= query param, not api-version and deployment
+ assert "model=gpt-4o-realtime-preview" in url
+ assert "api-version" not in url
+ assert "deployment" not in url
@pytest.mark.asyncio
@@ -203,8 +206,10 @@ async def test_async_realtime_uses_ga_protocol_end_to_end():
called_url = mock_ws_connect.call_args[0][0]
assert "/openai/v1/realtime" in called_url
assert called_url.startswith("wss://")
- assert "api-version=2024-10-01-preview" in called_url
- assert "deployment=gpt-4o-realtime-preview" in called_url
+ # GA path uses model= query param, not api-version and deployment
+ assert "model=gpt-4o-realtime-preview" in called_url
+ assert "api-version" not in called_url
+ assert "deployment" not in called_url
@pytest.mark.asyncio