BerriAI/litellm · error · ValueError

Unsupported duration unit, passed duration

Error message

Unsupported duration unit, passed duration: {duration}

What it means

Generic guard in the duration-to-seconds calculator: the parsed unit is not one of the supported units (s, m, h, d, w, mo), so the duration cannot be converted to seconds. Fires when a duration string parses but uses a unit the calculator has no branch for.

Solutions

  1. Use a supported duration unit (s, m, h, d, w, mo); the passed duration uses an unsupported unit.
  2. Convert the value to a supported unit before passing.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/litellm_core_utils/duration_parser.py:106 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/2ee6b5e953b50c42. Report an issue: GitHub.

Appendix: source

Thrown at litellm/litellm_core_utils/duration_parser.py:106

        target_day = min(target_day, last_day_of_target_month)

        next_month: Final = datetime(
            year=target_year,
            month=target_month,
            day=target_day,
            hour=current_time.hour,
            minute=current_time.minute,
            second=current_time.second,
            microsecond=current_time.microsecond,
        )

        # Calculate the duration until the first day of the next month
        duration_until_next_month: Final = next_month - current_time
        return int(duration_until_next_month.total_seconds())

    else:
        raise ValueError(f"Unsupported duration unit, passed duration: {duration}")


def get_next_standardized_reset_time(
    duration: str,
    current_time: datetime,
    timezone_str: str = "UTC",
    reset_time_of_day: time = time(0, 0),
) -> datetime:
    """
    Get the next standardized reset time based on the duration.

    All durations will reset at predictable intervals, aligned from the current time:
    - Nd: If N=1, reset at the next `reset_time_of_day`; if N>1, reset every N days from now
    - Nh: Every N hours, aligned to hour boundaries (e.g., 1:00, 2:00)
    - Nm: Every N minutes, aligned to minute boundaries (e.g., 1:05, 1:10)
    - Ns: Every N seconds, aligned to second boundaries

    Parameters:

View on GitHub (pinned to 77b7c6c40c)