From 4cf7a74e6092b7f73d4da12f1bdd3d57e3857a86 Mon Sep 17 00:00:00 2001 From: abi_jey Date: Fri, 28 Nov 2025 14:27:57 +0000 Subject: [PATCH] fix: Azure OpenAI GA path relies soley on model paramter as deployment --- litellm/llms/azure/realtime/handler.py | 10 ++++++---- .../azure/realtime/test_azure_realtime_handler.py | 13 +++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/litellm/llms/azure/realtime/handler.py b/litellm/llms/azure/realtime/handler.py index 0dc42dad43..217a05c83a 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 ca8d01e158..2a110c8f9a 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