{"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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/langflow/chat/transformation.py#L80-L116","documentation":"Raised by LangFlowConfig.get_complete_url when building the LangFlow run URL ({api_base}/api/v1/run/{flow_id}) with api_base=None. LiteLLM cannot form a request without a base URL, so it raises ValueError instead of guessing. The base URL is normally resolved from the api_base parameter or the LANGFLOW_API_BASE environment variable.","triggerScenarios":"Any langflow completion call (e.g. litellm.completion(model=\"langflow/<flow_id>\", ...)) where the URL-building path receives no api_base: neither an api_base kwarg nor a resolvable LANGFLOW_API_BASE env var reached get_complete_url (for example when the config is invoked directly, bypassing _get_openai_compatible_provider_info which would otherwise default to http://localhost:7860).","commonSituations":"LANGFLOW_API_BASE exported in one shell but the proxy/worker/container runs in a different environment; .env file not loaded by the process; typo in the variable name (e.g. LANGFLOW_APIBASE); passing the base URL under a kwarg the config does not read.","solutions":["Pass api_base explicitly: litellm.completion(model=\"langflow/<flow_id>\", api_base=\"http://localhost:7860\", ...)","Or set the env var in the process that makes the call: export LANGFLOW_API_BASE=http://localhost:7860, then restart the process","If calling through the LiteLLM proxy, add api_base to the langflow model deployment in config.yaml","Verify the variable is visible in the same process: printenv LANGFLOW_API_BASE"],"exampleFix":"// before\nresponse = litellm.completion(\n    model=\"langflow/abc123-flow-id\",\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n)  # ValueError: api_base is required for LangFlow\n\n// after\nresponse = litellm.completion(\n    model=\"langflow/abc123-flow-id\",\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n    api_base=\"http://localhost:7860\",  # or export LANGFLOW_API_BASE=http://localhost:7860\n)","handlingStrategy":"validation","validationCode":"import os\n\nLANGFLOW_BASE = os.getenv(\"LANGFLOW_API_BASE\")\nif not LANGFLOW_BASE:\n    raise SystemExit(\"Set LANGFLOW_API_BASE before starting (e.g. http://localhost:7860)\")\n# then: litellm.completion(model=\"langflow/<flow_id>\", api_base=LANGFLOW_BASE, ...)","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"langflow/<flow_id>\", messages=msgs, api_base=base)\nexcept ValueError as e:\n    if \"api_base is required\" in str(e):\n        raise ConfigError(\"LANGFLOW_API_BASE missing\") from e\n    raise","preventionTips":["Set provider base URLs via env vars in a single checked startup step and fail fast at boot, not per request","Include api_base explicitly when calling non-default providers instead of relying on ambient env state","Add printenv-style smoke checks to container entrypoints for LANGFLOW_API_BASE"],"tags":["langflow","api-base","configuration","env-var"],"backgroundTag":"missing-api-base-url","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}