BerriAI/litellm · error · ValueError
/global/spend/logs Error: User ID is None
Error message
/global/spend/logs Error: User ID is None
What it means
Error "/global/spend/logs Error: User ID is None" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/spend_tracking/spend_management_endpoints.py:3193
async def global_spend_for_internal_user(
api_key: str | None = None,
user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),
):
from litellm.proxy.proxy_server import prisma_client
if prisma_client is None:
raise ProxyException(
message="Prisma Client is not initialized",
type="internal_error",
param="None",
code=status.HTTP_500_INTERNAL_SERVER_ERROR,
)
try:
user_id: Final = user_api_key_dict.user_id
if user_id is None:
raise ValueError("/global/spend/logs Error: User ID is None")
if api_key is not None:
sql_query = """
SELECT * FROM "MonthlyGlobalSpendPerUserPerKey"
WHERE "api_key" = $1 AND "user" = $2
ORDER BY "date";
"""
response: Sequence[Mapping[str, object]] = await _query_raw(prisma_client, sql_query, api_key, user_id)
return response
sql_query = """SELECT * FROM "MonthlyGlobalSpendPerUserPerKey" WHERE "user" = $1 ORDER BY "date";"""
response = await _query_raw(prisma_client, sql_query, user_id)
return response
except Exception as e:
verbose_proxy_logger.error("/global/spend/logs Error: %s", e)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Authenticate with a valid virtual key or user session so a user_id is resolved before calling /global/spend/logs.
- If calling programmatically, include the Authorization header with a valid key.
When it happens
Trigger: Thrown at litellm/proxy/spend_tracking/spend_management_endpoints.py:3193 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/5dab48393cfad261.
Report an issue: GitHub.