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]

[Bug fix]: Proxy Auth Layer - Allow Azure Realtime routes as llm_api_routes (#7684)

Ishaan Jaff02f5c44a3508
diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py
index 92522616fd8..6f3261fbd7a 100644
--- a/litellm/proxy/_types.py
+++ b/litellm/proxy/_types.py
@@ -229,6 +229,11 @@ class LiteLLMRoutes(enum.Enum):
# rerank
"/rerank",
"/v1/rerank",
+ # realtime
+ "/realtime",
+ "/v1/realtime",
+ "/realtime?{model}",
+ "/v1/realtime?{model}",
]
mapped_pass_through_routes = [
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index 7dc3ae1be2f..17b17687aef 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -4389,6 +4389,7 @@ from litellm import _arealtime
@app.websocket("/v1/realtime")
[email protected]("/realtime")
async def websocket_endpoint(
websocket: WebSocket,
model: str,
diff --git a/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py b/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py
index 541ce59e7a2..79c9d194e5b 100644
--- a/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py
+++ b/tests/proxy_admin_ui_tests/test_route_check_unit_tests.py
@@ -62,7 +62,13 @@ def test_is_llm_api_route():
assert RouteChecks.is_llm_api_route("/anthropic/messages") is True
assert RouteChecks.is_llm_api_route("/anthropic/v1/messages") is True
assert RouteChecks.is_llm_api_route("/azure/endpoint") is True
-
+ assert (
+ RouteChecks.is_llm_api_route("/v1/realtime?model=gpt-4o-realtime-preview")
+ is True
+ )
+ assert (
+ RouteChecks.is_llm_api_route("/realtime?model=gpt-4o-realtime-preview") is True
+ )
assert (
RouteChecks.is_llm_api_route(
"/openai/deployments/vertex_ai/gemini-1.5-flash/chat/completions"
diff --git a/tests/proxy_unit_tests/test_proxy_routes.py b/tests/proxy_unit_tests/test_proxy_routes.py
index 31ff7d2ede2..c2dc0542f17 100644
--- a/tests/proxy_unit_tests/test_proxy_routes.py
+++ b/tests/proxy_unit_tests/test_proxy_routes.py
@@ -53,7 +53,11 @@ def test_routes_on_litellm_proxy():
print("ALL OPENAI ROUTES:", LiteLLMRoutes.openai_routes.value)
for route in LiteLLMRoutes.openai_routes.value:
- assert route in _all_routes
+ # realtime routes - /realtime?model=gpt-4o
+ if "realtime" in route:
+ assert "/realtime" in _all_routes
+ else:
+ assert route in _all_routes
@pytest.mark.parametrize(