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 is llm api route check (#7631)

Ishaan Jaff48d4f792063c
diff --git a/litellm/proxy/auth/route_checks.py b/litellm/proxy/auth/route_checks.py
index ae3f7fff9f3..26b9eb73a94 100644
--- a/litellm/proxy/auth/route_checks.py
+++ b/litellm/proxy/auth/route_checks.py
@@ -177,6 +177,9 @@ class RouteChecks:
):
return True
+ if RouteChecks._is_azure_openai_route(route=route):
+ return True
+
# Pass through Bedrock, VertexAI, and Cohere Routes
if "/bedrock/" in route:
return True
@@ -196,6 +199,22 @@ class RouteChecks:
return True
return False
+ @staticmethod
+ def _is_azure_openai_route(route: str) -> bool:
+ """
+ Check if route is a route from AzureOpenAI SDK client
+
+ eg.
+ route='/openai/deployments/vertex_ai/gemini-1.5-flash/chat/completions'
+ """
+ # Add support for deployment and engine model paths
+ deployment_pattern = r"^/openai/deployments/[^/]+/[^/]+/chat/completions$"
+ engine_pattern = r"^/engines/[^/]+/chat/completions$"
+
+ if re.match(deployment_pattern, route) or re.match(engine_pattern, route):
+ return True
+ return False
+
@staticmethod
def _route_matches_pattern(route: str, pattern: str) -> bool:
"""
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 a8bba211ffa..541ce59e7a2 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
@@ -63,6 +63,25 @@ def test_is_llm_api_route():
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(
+ "/openai/deployments/vertex_ai/gemini-1.5-flash/chat/completions"
+ )
+ is True
+ )
+ assert (
+ RouteChecks.is_llm_api_route(
+ "/openai/deployments/gemini/gemini-1.5-flash/chat/completions"
+ )
+ is True
+ )
+ assert (
+ RouteChecks.is_llm_api_route(
+ "/openai/deployments/anthropic/claude-3-5-sonnet-20240620/chat/completions"
+ )
+ is True
+ )
+
# check non-matching routes
assert RouteChecks.is_llm_api_route("/some/random/route") is False
assert RouteChecks.is_llm_api_route("/key/regenerate/82akk800000000jjsk") is False