-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat: Add 'All Org Models' option for API key model access #12907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added all_org_models to SpecialModelNames enum - Implemented async model resolution for organization-level access - Updated UI components to show "All Org Models" option when creating/editing keys - Added backend logic to resolve org models during API calls - Organization models provide hierarchical access control: Org → Team → Key This allows organizations to grant API keys access to all models available at the organization level, making it easier to manage model access across different teams and environments.
- Test get_org_models function with various scenarios - Test get_key_models_async resolution of all-org-models - Test can_key_call_model authentication with org models - Test /v1/models and /v2/model/info endpoints - Test model access validation in chat completion flow
- Simplified test structure to focus on core functionality - Added tests for SpecialModelNames enum - Test sync and async model resolution - Test authentication flow with all-org-models - All tests passing locally
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
if i select a team, which does not have access to all org models, will i still see 'all-org-models' as an option? |
@@ -124,6 +151,42 @@ def get_key_models( | |||
return all_models | |||
|
|||
|
|||
async def get_key_models_async( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need a new async implementation? if get_key_models worked for teams and keys, it should work for orgs as well
Title
Add 'All Org Models' option for API key model access
Relevant issues
N/A - Feature enhancement
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/
directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit
Type
🆕 New Feature
Changes
Summary
This PR adds an "All Org Models" option that allows API keys to inherit all models available at the organization level. This provides better hierarchical model access control and makes it easier to manage model permissions across different teams and environments.
Demo Video
🎥 Watch the UI Demo on Loom
What Changed
Backend Changes:
all_org_models = "all-org-models"
to theSpecialModelNames
enum in_types.py
get_org_models()
async function to fetch organization models from the databaseget_key_models_async()
to handle async resolution of org modelscan_key_call_model()
to resolve org models during API calls/v1/models
and/v2/model/info
endpoints to use async model resolution when neededFrontend Changes:
create_key_button.tsx
to show "All Org Models" option when creating API keys (only shown if team has an organization)key_edit_view.tsx
to show "All Org Models" option when editing API keysgetModelDisplayName()
to display "All Org Models" properlyHow It Works
["all-org-models"]
Benefits
Testing Done
$ python -m pytest tests/test_litellm/proxy/auth/test_all_org_models.py -v ============================== 9 passed in 0.64s ===============================
Test Coverage
test_special_model_name_exists
- Verifies the enum value existstest_get_key_models_recognizes_all_org_models
- Tests sync recognitiontest_get_key_models_async_with_org_models
- Tests async resolutiontest_auth_checks_integration
- Tests full authentication flowNotes
models
field inLiteLLM_OrganizationTable
)