{"record":{"id":"8c5c5b421ffdc6c4","repo":"BerriAI/litellm","slug":"could-not-extract-a-message-from-the-langflow-resp","errorCode":null,"errorMessage":"Could not extract a message from the LangFlow response; ensure the flow ends in a Chat Output component","messagePattern":"Could not extract a message from the LangFlow response; ensure the flow ends in a Chat Output component","errorType":"http","errorClass":"LangFlowError","httpStatus":500,"severity":"error","filePath":"litellm/llms/langflow/chat/transformation.py","lineNumber":242,"sourceCode":"        optional_params: dict,\n        litellm_params: dict,\n        encoding: Any,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        try:\n            response_json: Final = raw_response.json()\n        except Exception as e:\n            raise LangFlowError(\n                message=f\"LangFlow returned a non-JSON response: {e}\",\n                status_code=raw_response.status_code,\n            )\n\n        verbose_logger.debug(\"LangFlow response: %s\", response_json)\n\n        content: Final = self._extract_content_from_response(response_json)\n        if content is None:\n            raise LangFlowError(\n                message=(\n                    \"Could not extract a message from the LangFlow response; \"\n                    \"ensure the flow ends in a Chat Output component\"\n                ),\n                status_code=500,\n            )\n\n        message: Final = Message(content=content, role=\"assistant\")\n        choice: Final = Choices(finish_reason=\"stop\", index=0, message=message)\n\n        model_response.choices = [choice]\n        model_response.model = model\n\n        try:\n            from litellm.utils import token_counter\n\n            prompt_tokens: Final = token_counter(model=model, messages=messages)\n            completion_tokens: Final = token_counter(model=model, text=content, count_response_tokens=True)","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/langflow/chat/transformation.py#L224-L260","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=f\"langflow/{flow_id}\", messages=msgs)\nexcept LangFlowError as e:\n    if e.status_code == 500 and \"Chat Output component\" in str(e):\n        raise RuntimeError(\n            f\"Flow {flow_id} is not chat-shaped; fix its terminal component in LangFlow\"\n        ) from e","preventionTips":["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"],"tags":["langflow","response-parsing","config"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}