BerriAI/litellm · error · HTTPException

PTU cost attribution is disabled, so {', '.join(supplied)} c

Error message

PTU cost attribution is disabled, so {', '.join(supplied)} cannot be set. Set {PTU_COST_ATTRIBUTION_ENV_VAR}=true to enable it.

What it means

Opt-in guard for PTU cost attribution: the request's model_info supplies PTU pricing fields while the PTU_COST_ATTRIBUTION_ENV_VAR opt-in is false. Fields are rejected rather than silently dropped so a caller never believes flat cost is configured while the rollup job pricing it is not running; only the incoming request is checked, so unrelated patches of a legacy PTU model pass.

Source

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

def _raise_if_ptu_cost_attribution_disabled(incoming_model_info: Mapping[str, object]) -> None:
    """Reject PTU model_info fields unless the operator opted into PTU cost attribution.

    Takes the incoming request's model_info rather than the merged deployment, so an
    unrelated patch of a model that still stores PTU config from an earlier opt-in is
    left alone. The fields are rejected rather than dropped so a caller never believes
    a flat cost was configured while the rollup that would price it is not running.

    Only a value is rejected. An explicit null reaches the clear loop, which is gated on
    the same flag, so a disabled proxy neither writes PTU config nor erases what an
    earlier opt-in stored. Disabling pauses the feature rather than discarding its setup.
    """
    if is_ptu_cost_attribution_enabled():
        return
    supplied: Final = tuple(field for field in _PTU_MODEL_INFO_FIELDS if incoming_model_info.get(field) is not None)
    if not supplied:
        return
    raise HTTPException(
        status_code=400,
        detail=(
            f"PTU cost attribution is disabled, so {', '.join(supplied)} cannot be set. "
            f"Set {PTU_COST_ATTRIBUTION_ENV_VAR}=true to enable it."
        ),
    )


def _validate_ptu_model_info(model_info: Mapping[str, object]) -> None:
    """Enforce the PTU cross-field invariant on the effective model_info.

    ptu_count and cost_per_ptu_per_hour must be set together, and a team_id and a
    ptu_effective_from are required when they are. The start is mandatory rather than
    defaulted because flat cost accrues from it: inferring one would let a deployment
    configured today be billed for days it did not exist. Per-field bounds (positive
    count, non-negative rate) are enforced by ModelInfo itself.

    Window ordering is checked before the count/rate gate. A patch that touches only one

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set the PTU cost attribution environment variable to true, or remove the PTU pricing fields from the request.
Defensive patterns

Strategy: validation

When it happens

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