BerriAI/litellm · error · HTTPException

Not authorized to view spend log for request_id={request_id}

Error message

Not authorized to view spend log for request_id={request_id}

What it means

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

Source

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

    Raises HTTP 403 if not.
    """
    row: Final = await _find_spend_log_row(prisma_client, request_id)
    if row is None:
        return

    if row.user is not None and row.user == user_api_key_dict.user_id:
        return

    if row.team_id:
        can_view: Final = await _can_team_member_view_log(
            prisma_client=prisma_client,
            user_api_key_dict=user_api_key_dict,
            team_id=row.team_id,
        )
        if can_view:
            return

    raise HTTPException(
        status_code=status.HTTP_403_FORBIDDEN,
        detail={"error": f"Not authorized to view spend log for request_id={request_id}"},
    )


async def _get_permitted_team_ids_for_spend_logs(
    prisma_client: PrismaClient,
    user_api_key_dict: UserAPIKeyAuth,
) -> list[str]:
    """
    Return team IDs where the user is either a team admin or has the
    ``/spend/logs`` permission, allowing them to view team-wide spend logs.
    """
    # Imported here to avoid circular import: proxy_server imports this module.
    from litellm.proxy.auth.auth_checks import get_user_object
    from litellm.proxy.management_endpoints.common_utils import (
        _is_user_team_admin,
        _team_member_has_permission,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Use a key/user that owns the given request_id, or a proxy admin key, to view its spend log.
  2. Confirm the request_id belongs to your team or key.

When it happens

Trigger: Thrown at litellm/proxy/spend_tracking/spend_management_endpoints.py:4248 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/5a4f95bfb69ffedc. Report an issue: GitHub.