{"record":{"id":"db221b199d3fef2a","repo":"BerriAI/litellm","slug":"api-base-is-required-for-langflow-set-it-via-lang","errorCode":null,"errorMessage":"api_base is required for LangFlow. Set it via LANGFLOW_API_BASE env var or api_base parameter.","messagePattern":"api_base is required for LangFlow\\. Set it via LANGFLOW_API_BASE env var or api_base parameter\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/langflow/chat/transformation.py","lineNumber":98,"sourceCode":"        flow_id: Final = (model.split(\"/\", 1)[1] if \"/\" in model else model).strip()\n        if not flow_id:\n            raise LangFlowError(\n                status_code=400,\n                message=\"flow_id is required; use model langflow/{flow_id}\",\n            )\n        return flow_id\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,\n    ) -> str:\n        if api_base is None:\n            raise ValueError(\n                \"api_base is required for LangFlow. Set it via LANGFLOW_API_BASE env var or api_base parameter.\"\n            )\n\n        api_base = api_base.rstrip(\"/\")\n        flow_id: Final = quote(self._get_flow_id(model, optional_params), safe=\"\")\n        return f\"{api_base}/api/v1/run/{flow_id}\"\n\n    def _get_last_user_message(self, messages: list[AllMessageValues]) -> str:\n        \"\"\"Extract the text of the last user message to use as input_value.\"\"\"\n        for msg in reversed(messages):\n            if msg.get(\"role\") == \"user\":\n                content = msg.get(\"content\", \"\")\n                if isinstance(content, list):\n                    content = convert_content_list_to_str(msg)\n                if not isinstance(content, str):\n                    content = str(content)\n                return content\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/langflow/chat/transformation.py#L80-L116","documentation":"Unlike most LiteLLM providers, LangFlow has no default public API base, so get_complete_url raises ValueError when api_base is None. The value must come from the api_base parameter or the LANGFLOW_API_BASE environment variable; the final URL is built as {api_base}/api/v1/run/{flow_id}.","triggerScenarios":"Calling completion(model=\"langflow/x\") with neither api_base=... passed nor LANGFLOW_API_BASE exported in the process environment; the env var set only in a different shell/deployment than the one running LiteLLM (common in Docker or systemd units).","commonSituations":"Missing or misspelled LANGFLOW_API_BASE (e.g. LANGFLOW_API_URL); env var set in .env but the file is not loaded by the proxy/worker; local LangFlow instance at http://localhost:7880 not configured after adding the provider.","solutions":["Set the env var: export LANGFLOW_API_BASE=\"http://localhost:7880\"","Or pass api_base explicitly: litellm.completion(model=\"langflow/x\", api_base=\"http://localhost:7880\", api_key=...)","For LiteLLM proxy, set api_base (or LITELLM_PROXY_API_BASE / environment config) on the langflow model_list entry so it is passed through litellm_params","If using .env files, confirm the runner actually loads them (docker-compose env_file, --env-file, etc.)"],"exampleFix":"# before\nlitellm.completion(model=\"langflow/my-flow\", messages=msgs, api_key=lf_key)\n\n# after\nlitellm.completion(\n    model=\"langflow/my-flow\",\n    messages=msgs,\n    api_key=lf_key,\n    api_base=\"http://localhost:7880\",\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef ensure_langflow_config(api_base: str | None = None) -> str:\n    base = api_base or os.getenv(\"LANGFLOW_API_BASE\")\n    if not base:\n        raise ValueError(\"LANGFLOW_API_BASE is not set; refusing to call LangFlow\")\n    return base","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"langflow/x\", messages=msgs, api_base=ensure_langflow_config())\nexcept ValueError as e:\n    if \"api_base is required for LangFlow\" in str(e):\n        # config/bootstrap error — alert ops, do not retry\n        ...","preventionTips":["Set LANGFLOW_API_BASE in the deployment manifest next to the API key, not ad hoc in shells","Add a startup health check that pings {api_base}/api/v1/flows before serving langflow traffic","Use the same env-loading path (e.g. docker-compose env_file) as other provider variables"],"tags":["langflow","config","environment"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}