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(router): use set membership in team deployment filter (#21210)
Emerson Gomesddb48fa1164c
diff --git a/litellm/router_utils/common_utils.py b/litellm/router_utils/common_utils.pyindex 10acc343abd..3b0273f4c5d 100644--- a/litellm/router_utils/common_utils.py+++ b/litellm/router_utils/common_utils.py@@ -58,7 +58,7 @@ def filter_team_based_models(request_team_id = metadata.get("user_api_key_team_id") or litellm_metadata.get("user_api_key_team_id")- ids_to_remove = []+ ids_to_remove = set()if isinstance(healthy_deployments, dict):return healthy_deploymentsfor deployment in healthy_deployments:@@ -67,7 +67,7 @@ def filter_team_based_models(if model_team_id is None:continueif model_team_id != request_team_id:- ids_to_remove.append(deployment.get("model_info", {}).get("id"))+ ids_to_remove.add(_model_info.get("id"))return [deployment@@ -125,4 +125,3 @@ def filter_web_search_deployments(if len(healthy_deployments) > 0 and len(final_deployments) == 0:verbose_logger.warning("No deployments support web search for request")return final_deployments-