{"record":{"id":"180570bab7c88725","repo":"BerriAI/litellm","slug":"qualityrouter-model-name-has-invalid-litellm","errorCode":null,"errorMessage":"QualityRouter: model '{name}' has invalid litellm_routing_preferences: {e}","messagePattern":"QualityRouter: model '(.+?)' has invalid litellm_routing_preferences: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/router_strategy/quality_router/quality_router.py","lineNumber":194,"sourceCode":"                    f\"but has no model_info.litellm_routing_preferences\"\n                )\n\n            # Validate via the Pydantic model so we get a clear error for\n            # missing quality_tier, wrong types, etc. This also means\n            # `RoutingPreferences` is the single source of truth for the\n            # accepted shape — readers relied on raw dicts before.\n            try:\n                if isinstance(raw_prefs, RoutingPreferences):\n                    prefs = raw_prefs\n                elif isinstance(raw_prefs, dict):\n                    prefs = RoutingPreferences(**raw_prefs)\n                else:\n                    # A Pydantic object of some other shape — coerce via its dict.\n                    prefs = RoutingPreferences(\n                        **(raw_prefs.model_dump() if hasattr(raw_prefs, \"model_dump\") else dict(raw_prefs))\n                    )\n            except Exception as e:\n                raise ValueError(f\"QualityRouter: model '{name}' has invalid litellm_routing_preferences: {e}\") from e\n\n            tier_int = int(prefs.quality_tier)\n            tier_to_models.setdefault(tier_int, []).append(name)\n            self._model_keywords[name] = [str(k).lower() for k in prefs.keywords if k]\n            self._model_quality[name] = tier_int\n            self._model_cost[name] = self._get_deployment_input_cost(deployment)\n            self._model_order[name] = prefs.order\n            seen[name] = True\n\n        missing: Final = [name for name, found in seen.items() if not found]\n        if missing:\n            raise ValueError(\n                f\"QualityRouter: the following available_models are not present in \"\n                f\"the router's model_list (or are missing routing preferences): {missing}\"\n            )\n\n        # Sort each tier's model list so `_resolve_model_for_quality_tier`\n        # (which picks index [0]) honors (order ASC, cost ASC, name ASC).","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/router_strategy/quality_router/quality_router.py#L176-L212","documentation":"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.","triggerScenarios":"Thrown at litellm/router_strategy/quality_router/quality_router.py:194 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the model's litellm_routing_preferences per the reported validation error."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}