diff --git a/litellm/proxy/auth/auth_utils.py b/litellm/proxy/auth/auth_utils.py index f9be71c35d..aa48a6396a 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: