BerriAI/litellm · error · HTTPException

{param_name} must be a YYYY-MM-DD date, got {value!r}

Error message

{param_name} must be a YYYY-MM-DD date, got {value!r}

What it means

Raised by the _parse_date helper (used for start_date/end_date query params on analytics endpoints) when datetime.strptime(value, '%Y-%m-%d') fails. The offending parameter name and raw value are embedded; common causes are full timestamps ('2024-01-01T00:00:00') or slashed dates ('01/02/2024') where the plain ISO calendar date is required.

Source

Thrown at litellm/proxy/analytics_endpoints/analytics_endpoints.py:19

#### Analytics Endpoints #####
from datetime import datetime, timezone
from typing import Annotated, Final

import fastapi
from fastapi import APIRouter, Depends, HTTPException, status

from litellm.proxy._types import *
from litellm.proxy.analytics_endpoints.cache_activity import CacheActivityResponse, get_cache_activity
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth

router: Final = APIRouter()


def _parse_date(value: str, param_name: str) -> datetime:
    try:
        return datetime.strptime(value, "%Y-%m-%d").replace(tzinfo=timezone.utc)
    except ValueError:
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail={"error": f"{param_name} must be a YYYY-MM-DD date, got {value!r}"},
        )


@router.get(
    "/global/activity/cache_hits",
    tags=["Budget & Spend Tracking"],
    dependencies=[Depends(user_api_key_auth)],
    response_model=CacheActivityResponse,
    include_in_schema=False,
)
async def get_global_activity(
    start_date: Annotated[str, fastapi.Query(description="Time from which to start viewing spend")],
    end_date: Annotated[str, fastapi.Query(description="Time till which to view spend")],
    key_aliases: Annotated[
        list[str] | None, fastapi.Query(description="Only include spend from these key aliases")
    ] = None,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass the parameter as a YYYY-MM-DD date string.

Example fix

start_date='2026-08-01'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/analytics_endpoints/analytics_endpoints.py:19 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/3819498db281fc63. Report an issue: GitHub.