BerriAI/litellm · error · HTTPException
Only proxy admin roles can view tool spend across the deploy
Error message
Only proxy admin roles can view tool spend across the deployment
What it means
Error "Only proxy admin roles can view tool spend across the deployment" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/management_endpoints/tool_management_endpoints.py:264
Reads the ``LiteLLM_DailyToolSpend`` rollup, written at request time from invoked
tools only (MCP tool calls and response tool_calls; declaring a tool without
invoking it does not count). A request that invoked multiple tools counts its
full spend toward each of them, so per-tool numbers are attributions and do not
sum to a deduplicated total.
``by_tool`` is the top ``TOOL_SPEND_TOP_TOOLS`` tools by spend, aggregated in
SQL, and ``daily`` covers only those tools, so the response is bounded by
days x TOOL_SPEND_TOP_TOOLS regardless of the requested range or how many
distinct tool names exist.
"""
from litellm.proxy.proxy_server import prisma_client
if user_api_key_dict.user_role not in (
LitellmUserRoles.PROXY_ADMIN,
LitellmUserRoles.PROXY_ADMIN_VIEW_ONLY,
):
raise HTTPException(
status_code=403,
detail="Only proxy admin roles can view tool spend across the deployment",
)
if prisma_client is None:
raise HTTPException(status_code=500, detail=CommonProxyErrors.db_not_connected_error.value)
end_day: Final = _parse_day_start(end_date) or datetime.now(timezone.utc)
start_day: Final = _parse_day_start(start_date) or end_day - timedelta(days=30)
start_str: Final = start_day.strftime("%Y-%m-%d")
end_str: Final = end_day.strftime("%Y-%m-%d")
date_window: Final = {"date": {"gte": start_str, "lte": end_str}}
table: Final = _typed_table(DailyToolSpendRepository(prisma_client))
top_tools: Final = _TOP_TOOL_ROWS.validate_python(
await table.group_by(
by=["tool_name"],
sum={"spend": True, "total_tokens": True, "request_count": True},View on GitHub (pinned to 77b7c6c40c)
Solutions
- Call this endpoint with a PROXY_ADMIN key.
When it happens
Trigger: Thrown at litellm/proxy/management_endpoints/tool_management_endpoints.py:264 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/9346af8abe655978.
Report an issue: GitHub.