BerriAI/litellm · error · HTTPException

Cannot authorize spend log access without a database connect

Error message

Cannot authorize spend log access without a database connection. Connect a database or use a proxy admin key.

What it means

Error "Cannot authorize spend log access without a database connection. Connect a database or use a proxy admin key." thrown in BerriAI/litellm.

Source

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

        description="Time from which to start viewing key spend",
    ),
    end_date: str | None = fastapi.Query(
        default=None,
        description="Time till which to view key spend",
    ),
    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
):
    """
    View request / response for a specific request_id

    - goes through all callbacks, checks if any of them have a @property -> has_request_response_payload
    - if so, it will return the request and response payload
    """
    from litellm.proxy.proxy_server import prisma_client

    if not _is_admin_view_safe(user_api_key_dict=user_api_key_dict):
        if prisma_client is None:
            raise HTTPException(
                status_code=status.HTTP_403_FORBIDDEN,
                detail={
                    "error": (
                        "Cannot authorize spend log access without a database "
                        "connection. Connect a database or use a proxy admin key."
                    )
                },
            )
        await _assert_user_can_view_request_id(
            prisma_client=prisma_client,
            user_api_key_dict=user_api_key_dict,
            request_id=request_id,
        )

    custom_loggers: Final = litellm.logging_callback_manager.get_active_additional_logging_utils_from_custom_logger()
    start_date_obj: datetime | None = None
    end_date_obj: datetime | None = None
    if start_date is not None:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Connect a database by setting DATABASE_URL to a PostgreSQL connection string and restarting the proxy.
  2. Alternatively use a proxy admin key (master key) to authorize spend log access without a database.

When it happens

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