fix(proxy): include access group models in /v1/models for teams and keys - #35846
devin-ai-integration[bot] wants to merge 4 commits into
Conversation
Models granted to a team or key through a unified access group were callable but absent from the model listing, because get_available_models_for_user only read team.models / key.models while request-time auth falls back to access_group_ids. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThe PR makes
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| litellm/proxy/auth/auth_checks.py | Broadens access-group helper inputs from lists to sequences without changing authorization behavior. |
| litellm/proxy/utils.py | Extends model discovery with authorized team and key access-group models while preserving existing special modes. |
| tests/test_litellm/proxy/utils/helpers/test_model_access.py | Adds isolated regression tests covering access-group expansion, deduplication, and unchanged fallback behavior. |
Reviews (2): Last reviewed commit: "style(proxy): drop added comments and do..." | Re-trigger Greptile
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…access_groups Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…access_groups Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
Closing in favor of #36230, which merged the same access group resolution into get_available_models_for_user and fully covers LIT-5242 |
TLDR
Problem this solves:
/v1/modelsteam.models, never the granted access groups/team/infoshowed the access group, the models endpoint did notHow it solves it:
access_group_idswhen listing modelsRelevant issues
Linear ticket
Resolves LIT-5242
https://linear.app/litellm-ai/issue/LIT-5242/v1modelsinclude-model-access-groupstrue-omits-models-granted-via-team
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Same team, same access group, same DB across both runs. Team is restricted to
anthropic-haiku-4-5, and a unified access group grantinggpt-5.5andgpt-4o-miniis assigned to it. Real OpenAI calls through the proxy, no mocksSetup, run once against the proxy
Before, at base commit
e2950a89957e459e662105fecb3d2e44056b08b5gpt-5.5bills a real request and returns a real completion, so the key can clearly call it, yet the listing hides it. That mismatch is the bugAfter, at commit
8390e6d9664f98365b575d100455b1b2e357f0b4, the code as it stands,2c1b566e12on top of it only strips commentsThe listing now matches what the key can call. Nothing new is granted, a model outside both
team.modelsand the access group is still refusedType
🐛 Bug Fix
Changes
get_available_models_for_userbuilt its listing purely fromkey.models,team.models, and the router level model access groups. It never looked ataccess_group_ids, the unifiedLiteLLM_AccessGroupTableassignment the dashboard and/v1/access_groupwrite. Request time auth does look at them: bothcan_team_access_modelandcan_key_call_modelfall back to those groups when the direct model list rejects a model. So a team could call a model that/v1/modelsrefused to advertise, and callers had to reach for/team/infoto discover itThe listing now resolves the same grants through the same helpers rather than duplicating the lookup
_get_models_from_unified_access_groupsmirrors auth exactly: team assigned groups go throughauth_checks._get_models_from_access_groups, key assigned groups go throughget_authorized_resources_from_key_access_groups, which keeps the ownership check so a key cannot surface a group it was never authorized for. The team object already fetched for an explicit?team_id=is reused, otherwise the caller's own team is looked up through the existing cache backedget_team_object, and a failed lookup degrades to listing nothing extra instead of erroring the endpointonly_model_access_groups=trueis untouched, it still returns access group names rather than their members.access_group_idson_get_resources_from_access_groupsand_get_models_from_access_groupswidened fromlist[str]toSequence[str]so a tuple can be passed without a defensive copyRegression coverage lives in
tests/test_litellm/proxy/utils/helpers/test_model_access.py, stubbing only the access group DB boundary. Three of the five new tests fail on base and pass here, the other two pin the behavior that must not drift, a team with no access groups listing exactly its own models andonly_model_access_groupsnot expanding membersFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/5be9aaa48f104a4ba378283d70e26290