BerriAI/litellm · error · HTTPException

soft_budget ( ) must be strictly lower than max_budget ( )

Error message

soft_budget ({data.soft_budget}) must be strictly lower than max_budget ({data.max_budget})

What it means

Cross-field rule in _check_team_project_limits: when both soft_budget and max_budget are set, soft_budget must be strictly lower; equal or greater values return HTTP 400 with both numbers. soft_budget is meant as an alert threshold before the hard cap.

Solutions

  1. Set soft_budget strictly below max_budget (e.g. 80% of it)
  2. Omit soft_budget if no early-warning threshold is needed
  3. Generate soft_budget programmatically as max_budget * 0.8

Example fix

# before
{"max_budget": 100, "soft_budget": 100}

# after
{"max_budget": 100, "soft_budget": 80}
Defensive patterns

Strategy: validation

Validate before calling

def validate_budget_pair(data: dict) -> dict:
    sb, mb = data.get("soft_budget"), data.get("max_budget")
    if sb is not None and mb is not None and sb >= mb:
        raise ValueError(f"soft_budget ({sb}) must be strictly lower than max_budget ({mb})")
    return data

Try / catch

try:
    await post("/project/new", json=data)
except HTTPStatusError as e:
    if e.response.status_code == 400 and "strictly lower" in e.response.text:
        data["soft_budget"] = data["max_budget"] * 0.8
        retry()
    raise

Prevention

When it happens

Trigger: POST/PUT project with soft_budget equal to max_budget (e.g. both 100) or soft_budget above max_budget.

Common situations: Configs written with soft == max intending 'alert exactly at the cap'; templates that copy the same number into both fields; defaults regenerated without scaling.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/8c1bd03028f68c03. Report an issue: GitHub.

Appendix: source

Thrown at enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py:156

    - Budget values are non-negative
    - soft_budget < max_budget
    """
    # --- Budget non-negativity checks ---
    if data.max_budget is not None and data.max_budget < 0:
        raise HTTPException(
            status_code=400,
            detail={"error": f"max_budget cannot be negative. Received: {data.max_budget}"},
        )
    if data.soft_budget is not None and data.soft_budget < 0:
        raise HTTPException(
            status_code=400,
            detail={"error": f"soft_budget cannot be negative. Received: {data.soft_budget}"},
        )

    # --- soft_budget < max_budget ---
    if data.soft_budget is not None and data.max_budget is not None:
        if data.soft_budget >= data.max_budget:
            raise HTTPException(
                status_code=400,
                detail={
                    "error": f"soft_budget ({data.soft_budget}) must be strictly lower than max_budget ({data.max_budget})"
                },
            )

    # --- Validate project models are a subset of team models ---
    project_models = data.models
    team_models: list[str] = team_object.models or []
    if project_models and len(team_models) > 0:
        # If team has 'all-proxy-models', skip validation as it allows all models
        if SpecialModelNames.all_proxy_models.value not in team_models:
            for m in project_models:
                if m not in team_models:
                    raise HTTPException(
                        status_code=400,
                        detail={
                            "error": f"Model '{m}' not in team's allowed models. Team allowed models={team_models}. Team: {team_object.team_id}"

View on GitHub (pinned to 77b7c6c40c)