BerriAI/litellm · error · ValueError

QualityRouter: no user message and no default_model configur

Error message

QualityRouter: no user message and no default_model configured

What it means

Routing failure in QualityRouter: none of the supplied messages contain user-role text to classify for complexity, and no default_model is configured to fall back on, so a routing decision cannot be made.

Source

Thrown at litellm/router_strategy/quality_router/quality_router.py:358

        for msg in reversed(messages):
            role = msg.get("role", "")
            content = msg.get("content") or ""
            if isinstance(content, list):
                text_parts = [
                    part.get("text", "") for part in content if isinstance(part, dict) and part.get("type") == "text"
                ]
                content = " ".join(text_parts).strip()
            if isinstance(content, str) and content:
                if role == "user" and user_message is None:
                    user_message = content
                elif role == "system" and system_prompt is None:
                    system_prompt = content

        if user_message is None:
            verbose_router_logger.debug("QualityRouter: No user message found, routing to default model")
            if not self.config.default_model:
                raise ValueError("QualityRouter: no user message and no default_model configured")
            return PreRoutingHookResponse(
                model=self.config.default_model,
                messages=messages,
                routing_decision=StandardLoggingRoutingDecision(
                    router_model_name=self.model_name,
                    router_type="quality",
                    routed_model=self.config.default_model,
                    cause="default_fallback",
                ),
            )

        # Try keyword override first — it short-circuits complexity classification.
        keyword_match: Final = self._keyword_override(user_message)
        if keyword_match is not None:
            routed_model, matched_keyword = keyword_match
            verbose_router_logger.info(
                "QualityRouter: keyword override matched='%s' routed_model=%s (quality_tier=%s, input_cost_per_token=%s)",
                matched_keyword,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Include a user message in the request, or configure default_model for the QualityRouter.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/router_strategy/quality_router/quality_router.py:358 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/0330ae9fc0d3b45d. Report an issue: GitHub.