BerriAI/litellm · error · LangFlowError

Could not extract a message from the LangFlow response; ensu

Error message

Could not extract a message from the LangFlow response; ensure the flow ends in a Chat Output component

What it means

LiteLLM parsed the LangFlow JSON response but _extract_content_from_response could not find a message (it looks for the outputs of a flow whose final component exposes a chat/message output). It raises LangFlowError 500 advising that the flow ends in a Chat Output component. This usually means the flow's structure is not what the chat extraction expects.

Source

Thrown at litellm/llms/langflow/chat/transformation.py:242

        optional_params: dict,
        litellm_params: dict,
        encoding: Any,
        api_key: str | None = None,
        json_mode: bool | None = None,
    ) -> ModelResponse:
        try:
            response_json: Final = raw_response.json()
        except Exception as e:
            raise LangFlowError(
                message=f"LangFlow returned a non-JSON response: {e}",
                status_code=raw_response.status_code,
            )

        verbose_logger.debug("LangFlow response: %s", response_json)

        content: Final = self._extract_content_from_response(response_json)
        if content is None:
            raise LangFlowError(
                message=(
                    "Could not extract a message from the LangFlow response; "
                    "ensure the flow ends in a Chat Output component"
                ),
                status_code=500,
            )

        message: Final = Message(content=content, role="assistant")
        choice: Final = Choices(finish_reason="stop", index=0, message=message)

        model_response.choices = [choice]
        model_response.model = model

        try:
            from litellm.utils import token_counter

            prompt_tokens: Final = token_counter(model=model, messages=messages)
            completion_tokens: Final = token_counter(model=model, text=content, count_response_tokens=True)

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Open the flow in LangFlow and ensure it terminates with a Chat Output component
  2. Test the flow directly in the LangFlow playground to confirm it produces chat output
  3. If the flow is intentional non-chat, wrap it or use a custom integration instead of the langflow chat provider
  4. Enable verbose logging (litellm.verbose = True / set_verbose) to inspect the raw response JSON that failed extraction
Defensive patterns

Strategy: try-catch

Try / catch

try:
    resp = litellm.completion(model=f"langflow/{flow_id}", messages=msgs)
except LangFlowError as e:
    if e.status_code == 500 and "Chat Output component" in str(e):
        raise RuntimeError(
            f"Flow {flow_id} is not chat-shaped; fix its terminal component in LangFlow"
        ) from e

Prevention

When it happens

Trigger: The LangFlow flow ends in a plain Text/Data output component instead of Chat Output; the flow errored server-side and returned an outputs structure with no message; a flow built for a different endpoint (e.g. a simple API flow) being called via the chat interface; empty outputs array in the response.

Common situations: Pointing langflow/{flow_id} at a data-pipeline flow rather than a chat flow; recently edited flow where the Chat Output component was removed; LangFlow version changing the response envelope for outputs.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/8c5c5b421ffdc6c4. Report an issue: GitHub.