Skip to content

fix(proxy): populate access_via_team_ids on /v1/model/info - #30274

Merged
mateo-berri merged 9 commits into
litellm_internal_stagingfrom
litellm_v1_model_info_team_access
Jun 12, 2026
Merged

fix(proxy): populate access_via_team_ids on /v1/model/info#30274
mateo-berri merged 9 commits into
litellm_internal_stagingfrom
litellm_v1_model_info_team_access

Conversation

@Sameerlite

@Sameerlite Sameerlite commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Populate model_info.access_via_team_ids and model_info.direct_access on GET /v1/model/info when the proxy database is connected
  • Add optional include_team_models and teamId query params to /v1/model/info for parity with /v2/model/info
  • Extract shared team-access enrichment into _populate_team_access_on_models

Test plan

  • poetry run pytest tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.py -q
  • poetry run pytest tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.py::test_model_info_v1_populates_access_via_team_ids -v
  • Verify locally: curl /v1/model/info returns access_via_team_ids per model
image

@Sameerlite
Sameerlite force-pushed the litellm_v1_model_info_team_access branch from bf68644 to 8ec8420 Compare June 12, 2026 07:04
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
litellm/proxy/proxy_server.py 86.20% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR populates model_info.access_via_team_ids and model_info.direct_access on GET /v1/model/info whenever a proxy database is connected, bringing v1 to parity with v2 for project model-picker flows. It also adds optional include_team_models and teamId query parameters to v1 (mirroring v2), and extracts the shared enrichment logic into _populate_team_access_on_models.

  • Refactors the old get_all_team_and_direct_access_models into two single-responsibility helpers: _populate_team_access_on_models (mutates access fields in-place, no filtering) and _filter_models_to_user_accessible (pure filter, no DB); the original function is retained as a thin shim calling both.
  • Early guard for teamId/include_team_models without a DB is placed before the litellm_model_id branch, so the fast-fail is uniform across all call paths.
  • Enrichment uses if k not in model_info semantics, so the newly populated direct_access and access_via_team_ids fields survive the enrichment and translation pipeline intact.

Confidence Score: 5/5

Safe to merge — all changes are additive, default behavior is preserved, and the no-DB guard is correctly placed before any model-list work.

Access-field population mutates a deep-copied model list so the router state is never touched; enrichment uses if-not-present semantics so populated fields survive the pipeline; the no-DB guard fires before the litellm_model_id branch; seven new tests cover the happy path, fail-fast paths, and single-model filtering.

No files require special attention.

Important Files Changed

Filename Overview
litellm/proxy/proxy_server.py Refactors get_all_team_and_direct_access_models into two focused helpers, adds include_team_models/teamId query params to /v1/model/info, and populates access fields on the v1 response whenever a DB is connected.
tests/test_litellm/proxy/proxy_server/test_team_model_name_translation.py Adds seven new tests covering access-field population, no-DB fast-fail paths, and single-model-lookup filtering. Modified test preserves its core BYOK-hiding assertion.
ui/litellm-dashboard/src/lib/http/schema.d.ts Generated OpenAPI schema updated to reflect the two new query parameters on /v1/model/info.

Reviews (8): Last reviewed commit: "fix(proxy): apply teamId/include_team_mo..." | Re-trigger Greptile

Comment thread litellm/proxy/proxy_server.py
Comment thread litellm/proxy/proxy_server.py Outdated
Team metadata enrichment previously only ran on /v2/model/info with
include_team_models=true, leaving /v1/model/info without
access_via_team_ids for project model-picker flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite
Sameerlite force-pushed the litellm_v1_model_info_team_access branch from 8ec8420 to dfbab84 Compare June 12, 2026 07:12
Add include_team_models and teamId to the generated schema for /model/info
and /v1/model/info after the proxy endpoint gained team-access filtering.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite

Copy link
Copy Markdown
Contributor Author

@greptileai

Set direct_access to true or false on every enriched model so clients
can filter without treating a missing field as ambiguous.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite

Copy link
Copy Markdown
Contributor Author

@greptileai

…v1/model/info

Raise the db_not_connected error before building, enriching, and translating the model list instead of after, so a teamId query against a proxy with no database no longer wastes the full enrichment pipeline.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

Comment thread litellm/proxy/proxy_server.py
include_team_models=True relies on _populate_team_access_on_models to set
direct_access/access_via_team_ids, which only runs when a database is connected.
Without one, _filter_models_to_user_accessible discarded every model and the
endpoint returned an empty list with HTTP 200. Mirror the teamId guard so the
request fails fast with a clear db_not_connected error before any model-list work.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

The /v1/model/info list path populates model_info.direct_access (and
access_via_team_ids) when a database is connected, but the
litellm_model_id single-model lookup returned early without it. This
made the two endpoints disagree, breaking the parity assertion in
test_get_specific_model. Run the same population on the single-model
path so both responses match.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

The teamId/include_team_models no-DB guard sat after the litellm_model_id
early return, so ?litellm_model_id=X&teamId=Y with no DB returned 200 with
unpopulated access fields instead of the 500 raised on every other path.
Move the guard ahead of the branch so the fast-fail is uniform.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

…lookup

The litellm_model_id early-return branch in model_info_v1 populated the
team access fields but returned before the teamId and include_team_models
filters ran, so a single-model lookup surfaced the deployment regardless
of team access when the DB was connected. Run both filters on the
single-model list before returning so the documented query params behave
the same with and without litellm_model_id.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri mateo-berri left a comment

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.

LGTM; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants