Skip to content

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]

Merge branch 'main' into litellm_project_management_apis

Harshit Jain66ce7513f665
diff --cc litellm/proxy/auth/auth_checks.py
index dc5d5d749b1,5a8a9f4e4df..e3f4534b231
--- a/litellm/proxy/auth/auth_checks.py
+++ b/litellm/proxy/auth/auth_checks.py
@@@ -2277,35 -2441,39 +2508,57 @@@ async def can_team_access_model
"""
Returns True if the team can access a specific model.
+ 1. First checks native team-level model permissions (current implementation)
+ 2. If not allowed natively, falls back to access_group_ids on the team
"""
- return _can_object_call_model(
- model=model,
- llm_router=llm_router,
- models=team_object.models if team_object else [],
- team_model_aliases=team_model_aliases,
- team_id=team_object.team_id if team_object else None,
- object_type="team",
- )
+ try:
+ return _can_object_call_model(
+ model=model,
+ llm_router=llm_router,
+ models=team_object.models if team_object else [],
+ team_model_aliases=team_model_aliases,
+ team_id=team_object.team_id if team_object else None,
+ object_type="team",
+ )
+ except ProxyException:
+ # Fallback: check team's access_group_ids
+ team_access_group_ids = (
+ (team_object.access_group_ids or []) if team_object else []
+ )
+ if team_access_group_ids:
+ models_from_groups = await _get_models_from_access_groups(
+ access_group_ids=team_access_group_ids,
+ )
+ if models_from_groups:
+ return _can_object_call_model(
+ model=model,
+ llm_router=llm_router,
+ models=models_from_groups,
+ team_model_aliases=team_model_aliases,
+ team_id=team_object.team_id if team_object else None,
+ object_type="team",
+ )
+ raise
+def can_project_access_model(
+ model: Union[str, List[str]],
+ project_object: LiteLLM_ProjectTableCachedObj,
+ llm_router: Optional[Router],
+) -> Literal[True]:
+ """
+ Returns True if the project can access a specific model.
+
+ Raises ProxyException if access is denied.
+ """
+ return _can_object_call_model(
+ model=model,
+ llm_router=llm_router,
+ models=project_object.models if project_object else [],
+ object_type="project",
+ )
+
+
async def can_user_call_model(
model: Union[str, List[str]],
llm_router: Optional[Router],