BerriAI/litellm · error · ValueError
Time range must be specified in days, e.g., '7d'
Error message
Time range must be specified in days, e.g., '7d'
What it means
Error "Time range must be specified in days, e.g., '7d'" thrown in BerriAI/litellm.
Source
Thrown at litellm/integrations/SlackAlerting/slack_alerting.py:1676
):
"""
Send a spend report for a configurable time range.
Args:
time_range: A string specifying the time range for the report, e.g., "1d", "7d", "30d"
"""
if self.alerting is None or "spend_reports" not in self.alert_types:
return
try:
from litellm.proxy.spend_tracking.spend_management_endpoints import (
_get_spend_report_for_time_range,
)
# Parse the time range
days: Final = int(time_range[:-1])
if time_range[-1].lower() != "d":
raise ValueError("Time range must be specified in days, e.g., '7d'")
todays_date: Final = datetime.datetime.now().date()
start_date: Final = todays_date - datetime.timedelta(days=days)
_event_cache_key: Final = (
f"weekly_spend_report_sent_{start_date.strftime('%Y-%m-%d')}_{todays_date.strftime('%Y-%m-%d')}"
)
if await self.internal_usage_cache.async_get_cache(key=_event_cache_key):
return
_resp: Final = await _get_spend_report_for_time_range(
start_date=start_date.strftime("%Y-%m-%d"),
end_date=todays_date.strftime("%Y-%m-%d"),
)
if _resp is None or _resp == ([], []):
return
spend_per_team, spend_per_tag = _respView on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass the time range in days with a 'd' suffix, e.g. '7d'.
When it happens
Trigger: Thrown at litellm/integrations/SlackAlerting/slack_alerting.py:1676 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/6dade294ff257465.
Report an issue: GitHub.