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
- Open the flow in LangFlow and ensure it terminates with a Chat Output component
- Test the flow directly in the LangFlow playground to confirm it produces chat output
- If the flow is intentional non-chat, wrap it or use a custom integration instead of the langflow chat provider
- 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
- Validate new flows once in the LangFlow playground (chat mode) before registering them as langflow/* models
- Include a canary completion call in CI for each registered flow
- Enable verbose logging during integration to capture the raw response JSON on extraction failures
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
- flow_id cannot be set via request parameters; use model lang
- flow_id is required; use model langflow/{flow_id}
- api_base is required for LangFlow. Set it via LANGFLOW_API_B
- tweaks cannot be set via request parameters; they would over
- LangFlow returned a non-JSON response: {e}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/8c5c5b421ffdc6c4.
Report an issue: GitHub.