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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
perf: add LRU cache to normalize_request_route (#19812)
ryan-crabbed77d525ce770
diff --git a/litellm/proxy/auth/auth_utils.py b/litellm/proxy/auth/auth_utils.pyindex 2bd84a1d98d..fbfc88228c7 100644--- a/litellm/proxy/auth/auth_utils.py+++ b/litellm/proxy/auth/auth_utils.py@@ -1,6 +1,7 @@import osimport reimport sys+from functools import lru_cachefrom typing import Any, List, Optional, Tuplefrom fastapi import HTTPException, Request, status@@ -311,10 +312,11 @@ def get_request_route(request: Request) -> str:return request.url.path+@lru_cache(maxsize=256)def normalize_request_route(route: str) -> str:"""Normalize request routes by replacing dynamic path parameters with placeholders.-+This prevents high cardinality in Prometheus metrics by collapsing routes like:- /v1/responses/1234567890 -> /v1/responses/{response_id}- /v1/threads/thread_123 -> /v1/threads/{thread_id}