BerriAI/litellm · error · ValueError
model must be a non-empty string
Error message
model must be a non-empty string
What it means
Pydantic field validator on the 'model' field of the fallback request model: it fires when model is empty or blank, i.e. the caller never specified which model the fallbacks attach to. Supply a non-empty model name.
Source
Thrown at litellm/types/management_endpoints/router_settings_endpoints.py:38
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")
message: str = Field(description="Success message")
class FallbackGetResponse(BaseModel):
"""Response model for getting fallbacks"""
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
- Pass a non-empty model string, e.g. 'gpt-4o'.
- Trim whitespace before validation.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/types/management_endpoints/router_settings_endpoints.py:38 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/09c5efbf042c81e9.
Report an issue: GitHub.