BerriAI/litellm · error · ValueError
QualityRouter: model '{name}' has invalid litellm_routing_pr
Error message
QualityRouter: model '{name}' has invalid litellm_routing_preferences: {e} What it means
Model-registration validation in QualityRouter: a deployment named 'name' carries model_info.litellm_routing_preferences, but the dict failed RoutingPreferences validation (missing quality_tier, wrong types, etc.); the Pydantic error is included.
Source
Thrown at litellm/router_strategy/quality_router/quality_router.py:194
f"but has no model_info.litellm_routing_preferences"
)
# Validate via the Pydantic model so we get a clear error for
# missing quality_tier, wrong types, etc. This also means
# `RoutingPreferences` is the single source of truth for the
# accepted shape — readers relied on raw dicts before.
try:
if isinstance(raw_prefs, RoutingPreferences):
prefs = raw_prefs
elif isinstance(raw_prefs, dict):
prefs = RoutingPreferences(**raw_prefs)
else:
# A Pydantic object of some other shape — coerce via its dict.
prefs = RoutingPreferences(
**(raw_prefs.model_dump() if hasattr(raw_prefs, "model_dump") else dict(raw_prefs))
)
except Exception as e:
raise ValueError(f"QualityRouter: model '{name}' has invalid litellm_routing_preferences: {e}") from e
tier_int = int(prefs.quality_tier)
tier_to_models.setdefault(tier_int, []).append(name)
self._model_keywords[name] = [str(k).lower() for k in prefs.keywords if k]
self._model_quality[name] = tier_int
self._model_cost[name] = self._get_deployment_input_cost(deployment)
self._model_order[name] = prefs.order
seen[name] = True
missing: Final = [name for name, found in seen.items() if not found]
if missing:
raise ValueError(
f"QualityRouter: the following available_models are not present in "
f"the router's model_list (or are missing routing preferences): {missing}"
)
# Sort each tier's model list so `_resolve_model_for_quality_tier`
# (which picks index [0]) honors (order ASC, cost ASC, name ASC).View on GitHub (pinned to 77b7c6c40c)
Solutions
- Fix the model's litellm_routing_preferences per the reported validation error.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/router_strategy/quality_router/quality_router.py:194 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/180570bab7c88725.
Report an issue: GitHub.