BerriAI/litellm · error · HTTPException

User={user_api_key_dict.user_id} not assigned to team={team_

Error message

User={user_api_key_dict.user_id} not assigned to team={team_table.team_id}

What it means

Error "User={user_api_key_dict.user_id} not assigned to team={team_table.team_id}" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:363

    if assigned_user_id is not None:
        key_assigned_user_in_team: Final = _get_user_in_team(team_table=team_table, user_id=assigned_user_id)

        if key_assigned_user_in_team is None:
            raise HTTPException(
                status_code=400,
                detail=f"User={assigned_user_id} not assigned to team={team_table.team_id}",
            )

    team_member_object: Final = _get_user_in_team(team_table=team_table, user_id=user_api_key_dict.user_id)

    is_admin: Final = (
        user_api_key_dict.user_role is not None and user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value
    )

    if is_admin:
        return True
    elif team_member_object is None:
        raise HTTPException(
            status_code=400,
            detail=f"User={user_api_key_dict.user_id} not assigned to team={team_table.team_id}",
        )
    elif (
        "allowed_team_member_roles" in team_key_generation
        and team_member_object.role not in team_key_generation["allowed_team_member_roles"]
    ):
        raise HTTPException(
            status_code=400,
            detail=f"Team member role {team_member_object.role} not in allowed_team_member_roles={team_key_generation['allowed_team_member_roles']}",
        )

    TeamMemberPermissionChecks.does_team_member_have_permissions_for_endpoint(
        team_member_object=team_member_object,
        team_table=team_table,
        route=route,
    )
    return True

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Add your user to the team first (via /team/member_add), then create the key.
  2. Verify the team_id in the request matches the intended team.

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:363 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/4dfc18ef47002e31. Report an issue: GitHub.