BerriAI/litellm · error · ValueError
api_base is required for LangFlow. Set it via LANGFLOW_API_B
Error message
api_base is required for LangFlow. Set it via LANGFLOW_API_BASE env var or api_base parameter.
What it means
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}.
Source
Thrown at litellm/llms/langflow/chat/transformation.py:98
flow_id: Final = (model.split("/", 1)[1] if "/" in model else model).strip()
if not flow_id:
raise LangFlowError(
status_code=400,
message="flow_id is required; use model langflow/{flow_id}",
)
return flow_id
def get_complete_url(
self,
api_base: str | None,
api_key: str | None,
model: str,
optional_params: dict,
litellm_params: dict,
stream: bool | None = None,
) -> str:
if api_base is None:
raise ValueError(
"api_base is required for LangFlow. Set it via LANGFLOW_API_BASE env var or api_base parameter."
)
api_base = api_base.rstrip("/")
flow_id: Final = quote(self._get_flow_id(model, optional_params), safe="")
return f"{api_base}/api/v1/run/{flow_id}"
def _get_last_user_message(self, messages: list[AllMessageValues]) -> str:
"""Extract the text of the last user message to use as input_value."""
for msg in reversed(messages):
if msg.get("role") == "user":
content = msg.get("content", "")
if isinstance(content, list):
content = convert_content_list_to_str(msg)
if not isinstance(content, str):
content = str(content)
return content
View on GitHub (pinned to 6c2dcb801b)
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.)
Example fix
# before
litellm.completion(model="langflow/my-flow", messages=msgs, api_key=lf_key)
# after
litellm.completion(
model="langflow/my-flow",
messages=msgs,
api_key=lf_key,
api_base="http://localhost:7880",
) Defensive patterns
Strategy: validation
Validate before calling
import os
def ensure_langflow_config(api_base: str | None = None) -> str:
base = api_base or os.getenv("LANGFLOW_API_BASE")
if not base:
raise ValueError("LANGFLOW_API_BASE is not set; refusing to call LangFlow")
return base Try / catch
try:
litellm.completion(model="langflow/x", messages=msgs, api_base=ensure_langflow_config())
except ValueError as e:
if "api_base is required for LangFlow" in str(e):
# config/bootstrap error — alert ops, do not retry
... Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Missing `LLM_GUARD_API_BASE` from environment
- ANTHROPIC_API_BASE/ANTHROPIC_BASE_URL or ANTHROPIC_API_KEY/A
- Missing Azure Document Intelligence API Key - Set AZURE_DOCU
- Missing Azure Document Intelligence Endpoint - Set AZURE_DOC
- Missing Azure AI API Key - A call is being made to Azure AI
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/db221b199d3fef2a.
Report an issue: GitHub.