BerriAI/litellm · warning · HTTPException
Please provide start_date and end_date
Error message
Please provide start_date and end_date
What it means
get_daily_activity requires an explicit query window: if start_date or end_date is None it raises HTTP 400 'Please provide start_date and end_date'. The dates are parsed downstream (dateutil/SQL), so any parsable string works, but they must be present — there is no default range. This check runs after the DB check, so a 400 here means the DB is fine and only the query params are missing.
Source
Thrown at litellm/proxy/management_endpoints/common_daily_activity.py:1010
resolve_entity_metadata: Callable[[Sequence[DailySpendRecord]], Awaitable[dict[str, dict[str, object]]]]
| None = None,
) -> SpendAnalyticsPaginatedResponse:
"""Common function to get daily activity for any entity type.
``resolve_entity_metadata`` lets a caller resolve entity metadata from the
rows actually on the page (e.g. user_id -> user_email) instead of fetching
the whole entity table upfront, which matters when the entity set is
unbounded.
"""
if prisma_client is None:
raise HTTPException(
status_code=500,
detail={"error": CommonProxyErrors.db_not_connected_error.value},
)
if start_date is None or end_date is None:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail={"error": "Please provide start_date and end_date"},
)
try:
where_conditions: Final = _build_where_conditions(
entity_id_field=entity_id_field,
entity_id=entity_id,
start_date=start_date,
end_date=end_date,
model=model,
api_key=api_key,
exclude_entity_ids=exclude_entity_ids,
timezone_offset_minutes=timezone_offset_minutes,
include_current_utc_day=include_current_utc_day,
)
# Get total count for paginationView on GitHub (pinned to 77b7c6c40c)
Solutions
- Add both query parameters, e.g. ?start_date=2026-08-01&end_date=2026-08-18
- Use the exact snake_case parameter names start_date and end_date
- For 'all time', compute a wide explicit range client-side rather than omitting the params
Example fix
# before curl http://localhost:4000/global/spend -H "Authorization: Bearer $KEY" # 400 Please provide start_date and end_date # after curl "http://localhost:4000/global/spend?start_date=2026-08-01&end_date=2026-08-18" -H "Authorization: Bearer $KEY"
Defensive patterns
Strategy: validation
Validate before calling
from datetime import datetime, timezone
def make_params(start: str, end: str) -> dict:
# Fail before the call if either bound is missing or unparsable
if not start or not end:
raise ValueError("start_date and end_date are both required")
datetime.fromisoformat(start)
datetime.fromisoformat(end)
return {"start_date": start, "end_date": end} Type guard
from typing import TypeGuard
def has_date_range(params: dict) -> TypeGuard[dict]:
"""True when params carry non-empty, ISO-formatted start/end dates."""
for k in ("start_date", "end_date"):
v = params.get(k)
if not isinstance(v, str) or not v:
return False
try:
datetime.fromisoformat(v)
except ValueError:
return False
return True Try / catch
import httpx
try:
r = httpx.get(f"{PROXY_URL}/global/spend", params=params, headers=hdrs)
r.raise_for_status()
except httpx.HTTPStatusError as e:
if e.response.status_code == 400 and "start_date and end_date" in e.response.text:
params.update({"start_date": DEFAULT_START, "end_date": today_iso()})
r = httpx.get(f"{PROXY_URL}/global/spend", params=params, headers=hdrs)
r.raise_for_status()
else:
raise Prevention
- Build analytics URLs from a helper that always injects both dates
- Use ISO 8601 (YYYY-MM-DD) everywhere to also avoid the downstream 500 parse error
When it happens
Trigger: Calling any daily-activity/spend endpoint without ?start_date=...&end_date=...; passing only one bound of the range; passing an empty string (parsed as absent by the endpoint's query handling).
Common situations: Dashboard code that builds URLs conditionally and omits params for 'all time'; copied curl examples with the dates stripped; time-zone-aware clients sending dates under differently named params (startDate vs start_date).
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Failed to fetch analytics: {e}
- Invalid sort order. Must be 'asc' or 'desc'
- urn:litellm:error:unknown-query-parameter
- urn:litellm:error:unknown-query-parameter
- mcp_tools_config must be a list of dictionaries
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/84242eb71a2885ab.
Report an issue: GitHub.