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): guard None model_info and deduplicate team index logic
Sameer Kankute298df75066bb
diff --git a/litellm/proxy/management_endpoints/model_management_endpoints.py b/litellm/proxy/management_endpoints/model_management_endpoints.pyindex c38a00e18a1..4b06c4460e7 100644--- a/litellm/proxy/management_endpoints/model_management_endpoints.py+++ b/litellm/proxy/management_endpoints/model_management_endpoints.py@@ -491,7 +491,8 @@ async def _update_existing_team_model_assignment(dfor d in responseif d.model_name != db_model.model_name- and d.model_info.get("team_public_model_name") == old_public_name+ and (d.model_info or {}).get("team_public_model_name")+ == old_public_name]if not other_deployments_with_old_name:diff --git a/litellm/router.py b/litellm/router.pyindex 7f428b18edf..130979d25bc 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -7173,6 +7173,24 @@ class Router:else:del self.team_model_to_deployment_indices[key]+ def _update_team_model_index(self, model: dict, idx: int) -> None:+ """+ Helper to update team_model_to_deployment_indices for a single deployment.++ Parameters:+ - model: dict - the deployment to index+ - idx: int - the index in model_list+ """+ team_id = model.get("model_info", {}).get("team_id")+ team_public_model_name = model.get("model_info", {}).get(+ "team_public_model_name"+ )+ if team_id and team_public_model_name:+ key = (team_id, team_public_model_name)+ if key not in self.team_model_to_deployment_indices:+ self.team_model_to_deployment_indices[key] = []+ self.team_model_to_deployment_indices[key].append(idx)+def _add_model_to_list_and_index_map(self, model: dict, model_id: Optional[str] = None) -> None:@@ -7202,15 +7220,7 @@ class Router:self.model_name_to_deployment_indices[model_name].append(idx)# Update team_model index for O(1) team-scoped lookup- team_id = model.get("model_info", {}).get("team_id")- team_public_model_name = model.get("model_info", {}).get(- "team_public_model_name"- )- if team_id and team_public_model_name:- key = (team_id, team_public_model_name)- if key not in self.team_model_to_deployment_indices:- self.team_model_to_deployment_indices[key] = []- self.team_model_to_deployment_indices[key].append(idx)+ self._update_team_model_index(model, idx)def upsert_deployment(self, deployment: Deployment) -> Optional[Deployment]:"""@@ -8051,15 +8061,7 @@ class Router:self.model_name_to_deployment_indices[model_name] = []self.model_name_to_deployment_indices[model_name].append(idx)- team_id = model.get("model_info", {}).get("team_id")- team_public_model_name = model.get("model_info", {}).get(- "team_public_model_name"- )- if team_id and team_public_model_name:- key = (team_id, team_public_model_name)- if key not in self.team_model_to_deployment_indices:- self.team_model_to_deployment_indices[key] = []- self.team_model_to_deployment_indices[key].append(idx)+ self._update_team_model_index(model, idx)def _build_model_id_to_deployment_index_map(self, model_list: list):"""