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
[Fix] - Router: optimize unhealthy deployment filtering in retry path (O(n*m) → O(n+m)) (#15110)
Alexsander Hamir79c24be48b54
diff --git a/litellm/proxy/hooks/parallel_request_limiter_v3.py b/litellm/proxy/hooks/parallel_request_limiter_v3.pyindex 5ee5877347a..5fca0d1f909 100644--- a/litellm/proxy/hooks/parallel_request_limiter_v3.py+++ b/litellm/proxy/hooks/parallel_request_limiter_v3.py@@ -20,6 +20,8 @@ from typing import (cast,)+from fastapi import HTTPException+from litellm import DualCachefrom litellm._logging import verbose_proxy_loggerfrom litellm.integrations.custom_logger import CustomLoggerdiff --git a/litellm/router.py b/litellm/router.pyindex 9ae87316476..6f0eb51959c 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -4755,11 +4755,11 @@ class Router:unhealthy_deployments = await _async_get_cooldown_deployments(litellm_router_instance=self, parent_otel_span=parent_otel_span)+ # Convert to set for O(1) lookup instead of O(n)+ unhealthy_deployments_set = set(unhealthy_deployments)healthy_deployments: list = []for deployment in _all_deployments:- if deployment["model_info"]["id"] in unhealthy_deployments:- continue- else:+ if deployment["model_info"]["id"] not in unhealthy_deployments_set:healthy_deployments.append(deployment)return healthy_deployments, _all_deployments