BerriAI/litellm · error · ValueError

fallback_models must contain at least one model

Error message

fallback_models must contain at least one model

What it means

Pydantic field_validator on FallbackCreateRequest.fallback_models: the list is empty after validation. A fallback configuration with zero fallback models is a no-op and is rejected (min_length is also enforced).

Source

Thrown at litellm/types/management_endpoints/router_settings_endpoints.py:29

class FallbackCreateRequest(BaseModel):
    """Request model for creating/updating fallbacks"""

    model: str = Field(description="The model name to configure fallbacks for (e.g., 'gpt-3.5-turbo')")
    fallback_models: list[str] = Field(
        description="List of fallback model names in order of priority",
        min_length=1,
    )
    fallback_type: Literal["general", "context_window", "content_policy"] = Field(
        default="general",
        description="Type of fallback: 'general' (default), 'context_window', or 'content_policy'",
    )

    @field_validator("fallback_models")
    @classmethod
    def validate_fallback_models(cls, v: list[str]) -> list[str]:
        if not v:
            raise ValueError("fallback_models must contain at least one model")
        if len(v) != len(set(v)):
            raise ValueError("fallback_models must not contain duplicates")
        return v

    @field_validator("model")
    @classmethod
    def validate_model(cls, v: str) -> str:
        if not v or not v.strip():
            raise ValueError("model must be a non-empty string")
        return v.strip()


class FallbackResponse(BaseModel):
    """Response model for fallback operations"""

    model: str = Field(description="The model name")
    fallback_models: list[str] = Field(description="List of fallback model names")
    fallback_type: str = Field(description="Type of fallback")

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Provide at least one model name in fallback_models.
  2. Remove the fallback_models setting if no fallbacks are desired.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/types/management_endpoints/router_settings_endpoints.py:29 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/d304d678a2c5cf54. Report an issue: GitHub.