BerriAI/litellm · error · ValueError

Limit must be greater than 0

Error message

Limit must be greater than 0

What it means

Error "Limit must be greater than 0" thrown in BerriAI/litellm.

Source

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

    response: Sequence[Mapping[str, object]]
    if (
        user_api_key_dict.user_role == LitellmUserRoles.INTERNAL_USER
        or user_api_key_dict.user_role == LitellmUserRoles.INTERNAL_USER_VIEW_ONLY
    ):
        response = await global_spend_key_internal_user(user_api_key_dict=user_api_key_dict)

        return response
    if prisma_client is None:
        raise HTTPException(status_code=500, detail={"error": "No db connected"})
    sql_query = """SELECT * FROM "Last30dKeysBySpend";"""

    if limit is None:
        response = await _query_raw(prisma_client, sql_query)
        return response
    try:
        limit = int(limit)
        if limit < 1:
            raise ValueError("Limit must be greater than 0")
        sql_query = """SELECT * FROM "Last30dKeysBySpend" LIMIT $1 ;"""
        response = await _query_raw(prisma_client, sql_query, limit)
    except ValueError as e:
        raise HTTPException(status_code=422, detail={"error": f"Invalid limit: {limit}, error: {e}"}) from e

    return response


@router.get(
    "/global/spend/teams",
    tags=["Budget & Spend Tracking"],
    dependencies=[Depends(user_api_key_auth)],
    include_in_schema=False,
)
async def global_spend_per_team():
    """
    [BETA] This is a beta endpoint. It will change.

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass a positive integer for the limit query parameter (e.g., limit=100).
  2. Remove the limit parameter to use the default page size.

When it happens

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