Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion litellm/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -8593,14 +8593,21 @@ def resolve_model_name_from_model_id(
# No match found
return None

def map_team_model(self, team_model_name: str, team_id: str) -> Optional[str]:
def map_team_model(
self, team_model_name: Optional[str], team_id: str
) -> Optional[str]:
"""
Check if team_model_name resolves to team-specific deployments.

Returns the public model name (unchanged) so the router can find all
sibling deployments via team_id filtering, instead of collapsing to a
single internal model_name.

When team_model_name is None (e.g. vector store / file endpoints that
don't include a model in their request), returns the first matching
team deployment's team_public_model_name so the router can inject BYOK
credentials from the team-scoped deployment.

Returns:
- str: the team_model_name if team deployments exist for this team
- None: if no team-specific model is found
Expand All @@ -8610,6 +8617,13 @@ def map_team_model(self, team_model_name: str, team_id: str) -> Optional[str]:
return None
for model in models:
if model.get("model_info", {}).get("team_id") == team_id:
if team_model_name is None:
# No model was specified (e.g. vector store endpoints).
# Return the deployment's public model name so the router
# can route to it and inject the BYOK API key.
return model.get("model_info", {}).get(
"team_public_model_name"
) or model.get("model_name")
Comment on lines +8620 to +8626

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 No test for the new None-model path

git diff HEAD~1 HEAD shows only litellm/router.py changed — no test file was added or modified in tests/test_litellm/. The presubmission checklist marks the test requirement as done, but the new branch (team_model_name is None) has zero coverage. The sibling test test_arouter_test_team_model at tests/test_litellm/test_router.py:373 only covers the non-None case. A minimal test would be:

def test_map_team_model_none_model_returns_team_deployment():
    router = litellm.Router(
        model_list=[{
            "model_name": "gpt-4o",
            "litellm_params": {"model": "openai/gpt-4o"},
            "model_info": {
                "team_id": "team-1",
                "team_public_model_name": "team-gpt4",
            },
        }]
    )
    result = router.map_team_model(team_model_name=None, team_id="team-1")
    assert result == "team-gpt4"

return team_model_name

# No team-scoped deployment found; wildcard/pattern routes are
Expand Down
Loading