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]

add get_request_route

Ishaan Jaff13f01ed57fe7
diff --git a/litellm/proxy/auth/auth_utils.py b/litellm/proxy/auth/auth_utils.py
index f9be71c35da..aa48a6396ab 100644
--- a/litellm/proxy/auth/auth_utils.py
+++ b/litellm/proxy/auth/auth_utils.py
@@ -80,6 +80,19 @@ def is_llm_api_route(route: str) -> bool:
return False
+def get_request_route(request: Request) -> str:
+ """
+ Helper to get the route from the request
+
+ remove base url from path if set e.g. `/genai/chat/completions` -> `/chat/completions
+ """
+ if request.url.path.startswith(request.base_url.path):
+ # remove base_url from path
+ return request.url.path[len(request.base_url.path) - 1 :]
+ else:
+ return request.url.path
+
+
async def check_if_request_size_is_safe(request: Request) -> bool:
"""
Enterprise Only: