BerriAI/litellm · error · HTTPException

Not authorized to view team spend for team_id={team_id}

Error message

Not authorized to view team spend for team_id={team_id}

What it means

Error "Not authorized to view team spend for team_id={team_id}" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/spend_tracking/spend_management_endpoints.py:2454

            await _get_permitted_team_ids_for_spend_logs_or_empty(
                prisma_client=prisma_client,
                user_api_key_dict=user_api_key_dict,
            )
            if user_scope_applies
            else ()
        )
        explicit_user_requires_caller_scope: Final = (
            user_scope_applies and not permitted_team_ids and user_id is not None
        )
        if not is_request_id_lookup and not is_admin_view:
            if team_id is not None:
                can_view_team: Final = await _can_team_member_view_log(
                    prisma_client=prisma_client,
                    user_api_key_dict=user_api_key_dict,
                    team_id=team_id,
                )
                if not can_view_team:
                    raise HTTPException(
                        status_code=status.HTTP_403_FORBIDDEN,
                        detail={"error": f"Not authorized to view team spend for team_id={team_id}"},
                    )
                where_conditions["team_id"] = team_id
            elif user_scope_applies:
                if permitted_team_ids:
                    if user_id is None:
                        where_conditions.pop("user", None)
                    where_conditions["OR"] = [
                        {"user": user_api_key_dict.user_id},
                        {"team_id": {"in": permitted_team_ids}},
                    ]
                else:
                    if user_id is None:
                        where_conditions["user"] = user_api_key_dict.user_id
                    else:
                        where_conditions["AND"] = where_conditions.get("AND", []) + [
                            {"user": user_api_key_dict.user_id}

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use an API key or user role that has permission to view spend for the given team_id, or ask a proxy admin to grant team spend access.
  2. Verify the team_id in the request matches a team your key/user belongs to.

When it happens

Trigger: Thrown at litellm/proxy/spend_tracking/spend_management_endpoints.py:2454 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/6f536b4d2a183de2. Report an issue: GitHub.