BerriAI/litellm · error · HTTPException

ptu_effective_from is required when PTU fields are set. Flat

Error message

ptu_effective_from is required when PTU fields are set. Flat cost accrues from that instant, so without it the start would have to be inferred and a deployment configured today could be billed for days it did not exist

What it means

Error "ptu_effective_from is required when PTU fields are set. Flat cost accrues from that instant, so without it the start would have to be inferred and a deployment configured today could be billed for days it did not exist" thrown in BerriAI/litellm.

Source

Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:331

    Window ordering is checked before the count/rate gate. A patch that touches only one
    end of the window carries no count or rate, and ModelInfo sees one field at a time, so
    leaving it to either would let an inverted window reach the row; the next load then
    fails to parse it and drops the deployment out of the router, where no further patch
    can repair it because each one re-parses the stored value first.
    """
    effective_from: Final = _coerce_ptu_datetime(model_info.get("ptu_effective_from"))
    effective_to: Final = _coerce_ptu_datetime(model_info.get("ptu_effective_to"))
    if effective_from is not None and effective_to is not None and effective_to <= effective_from:
        raise HTTPException(status_code=400, detail="ptu_effective_to must be after ptu_effective_from")

    has_count: Final = model_info.get("ptu_count") is not None
    has_rate: Final = model_info.get("cost_per_ptu_per_hour") is not None
    if not has_count and not has_rate:
        return
    if has_count != has_rate:
        raise HTTPException(status_code=400, detail="ptu_count and cost_per_ptu_per_hour must be set together")
    if effective_from is None:
        raise HTTPException(
            status_code=400,
            detail=(
                "ptu_effective_from is required when PTU fields are set. Flat cost accrues from that "
                "instant, so without it the start would have to be inferred and a deployment configured "
                "today could be billed for days it did not exist"
            ),
        )
    if not model_info.get("team_id"):
        raise HTTPException(
            status_code=400, detail="team_id is required when PTU fields are set (one model maps to one team)"
        )


# The mirrored per-token pricing fields plus the three remaining fields
# Router._inherit_builtin_cache_pricing back-fills from the public cost map. An unset field is
# what that back-fill targets, so a field left out here is one a PTU deployment still bills.
# tiered_pricing is the one mirrored field that is a table of ranges, not a rate, so it is stored
# empty (see _PTU_EMPTIED_PRICING_FIELDS): its tiers outrank the zeros written beside them, so

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Provide ptu_effective_from when setting PTU fields.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:331 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/113ce832444cc898. Report an issue: GitHub.