BerriAI/litellm · error · HTTPException
Team key for team={user_api_key_dict.team_id} not authorized
Error message
Team key for team={user_api_key_dict.team_id} not authorized to access this team={team_table.team_id} What it means
Error "Team key for team={user_api_key_dict.team_id} not authorized to access this team={team_table.team_id}" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/management_endpoints/team_endpoints.py:4027
records=records,
prisma_client=prisma_client,
)
async def validate_membership(user_api_key_dict: UserAPIKeyAuth, team_table: LiteLLM_TeamTable):
if (
user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value
or user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY.value
):
return
if user_api_key_dict.team_id == team_table.team_id: # allow team keys to check their info
return
# Handle case where user_id is None (e.g., team key accessing different team)
if user_api_key_dict.user_id is None:
if user_api_key_dict.team_id is not None:
raise HTTPException(
status_code=403,
detail={
"error": f"Team key for team={user_api_key_dict.team_id} not authorized to access this team={team_table.team_id}"
},
)
else:
raise HTTPException(
status_code=403,
detail={
"error": f"API key not authorized to access this team={team_table.team_id}. No user_id or team_id associated with this key."
},
)
# Check direct team membership
if user_api_key_dict.user_id in [m.user_id for m in team_table.members_with_roles]:
return
# Check if user is an org admin for the team's organizationView on GitHub (pinned to 77b7c6c40c)
Solutions
- Use an API key that belongs to the target team, or a proxy admin key.
When it happens
Trigger: Thrown at litellm/proxy/management_endpoints/team_endpoints.py:4027 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/aaf12a375ee792ec.
Report an issue: GitHub.