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: skip pattern_router.route() for non-wildcard models (#19664)
ryan-crabbe6e930c972487
diff --git a/litellm/router.py b/litellm/router.pyindex 62070d23755..c53f54984f8 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -6355,19 +6355,20 @@ class Router:elif custom_llm_provider != "azure":model = _model- potential_models = self.pattern_router.route(received_model_name)- if "*" in model and potential_models is not None: # if wildcard route- for potential_model in potential_models:- try:- if potential_model.get("model_info", {}).get(- "id"- ) == deployment.get("model_info", {}).get("id"):- model = potential_model.get("litellm_params", {}).get(- "model"- )- break- except Exception:- pass+ if "*" in model: # only call pattern_router for wildcard models+ potential_models = self.pattern_router.route(received_model_name)+ if potential_models is not None:+ for potential_model in potential_models:+ try:+ if potential_model.get("model_info", {}).get(+ "id"+ ) == deployment.get("model_info", {}).get("id"):+ model = potential_model.get("litellm_params", {}).get(+ "model"+ )+ break+ except Exception:+ pass## GET LITELLM MODEL INFO - raises exception, if model is not mappedif model is None: