BerriAI/litellm · error · LangFlowError
tweaks cannot be set via request parameters; they would…
Error message
tweaks cannot be set via request parameters; they would override the operator-configured LangFlow flow components
What it means
LangFlowConfig deliberately rejects caller-supplied 'tweaks'. Tweaks override flow components that the LangFlow operator configured, so letting a request set them would let any caller re-route or re-configure the flow behind a shared API key. _reject_caller_tweaks enforces this in both transform_request (optional_params) and sign_request (request body), raising LangFlowError with status 400.
Solutions
- Remove the tweaks parameter from the litellm call entirely
- Configure the flow components in the LangFlow UI / flow definition so the operator sets them
- If you need per-request variants, deploy separate flows and select them via the model name langflow/{flow_id}
- Use only the supported per-request params: session_id, input_type, output_type (and stream)
Example fix
// before
litellm.completion(
model="langflow/my-flow",
messages=[{"role": "user", "content": "hi"}],
tweaks={"openai-0": {"model_name": "gpt-4o"}}, # LangFlowError 400
)
// after
litellm.completion(
model="langflow/my-flow", # component config lives in the flow itself
messages=[{"role": "user", "content": "hi"}],
session_id="user-123", # supported optional params only
) Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_LANGFLOW_PARAMS = {"stream", "session_id", "input_type", "output_type"}
def sanitize_langflow_params(params: dict) -> dict:
return {k: v for k, v in params.items() if k in SUPPORTED_LANGFLOW_PARAMS}
# usage: litellm.completion(model="langflow/<flow_id>", messages=msgs, **sanitize_langflow_params(user_params)) Type guard
def is_langflow_safe_params(params: dict) -> bool:
return "tweaks" not in params or params.get("tweaks") is None Try / catch
try:
litellm.completion(model="langflow/<flow_id>", messages=msgs, **params)
except Exception as e:
status = getattr(e, "status_code", None)
if status == 400 and "tweaks" in str(e):
raise UserInputError("tweaks are not allowed; configure the flow in LangFlow") from e
raise Prevention
- Never forward raw LangFlow REST payloads through litellm params; whitelist the few supported keys
- Document that per-request flow overrides (tweaks, flow_id) are intentionally rejected for security
- Validate user-supplied extra kwargs against a supported-params whitelist before calling completion
When it happens
Trigger: Any langflow completion call that includes a 'tweaks' entry in optional_params or extra kwargs, e.g. litellm.completion(model="langflow/<flow_id>", messages=[...], tweaks={"component-id": {"param": "value"}}).
Common situations: Porting code from the raw LangFlow REST API (where tweaks are a documented body field) to litellm; trying to change model temperature or component settings per-request via tweaks; forwarding a full LangFlow payload through the OpenAI-compatible params.
Related errors
- api_base is required for LangFlow. Set it via…
- BedrockException
- BFL initial request failed
- Client-side 'metadata.tags' not allowed in request…
- Could not extract a message from the LangFlow response…
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/8e6498ef0b8fd6e2.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/langflow/chat/transformation.py:130
content = convert_content_list_to_str(msg)
if not isinstance(content, str):
content = str(content)
return content
# Fallback: use last message regardless of role
if messages:
content = messages[-1].get("content", "")
if isinstance(content, list):
content = convert_content_list_to_str(messages[-1])
if not isinstance(content, str):
content = str(content)
return content
return ""
def _reject_caller_tweaks(self, params: dict) -> None:
if params.get("tweaks") is not None:
raise LangFlowError(
status_code=400,
message=(
"tweaks cannot be set via request parameters; they would "
"override the operator-configured LangFlow flow components"
),
)
def transform_request(
self,
model: str,
messages: list[AllMessageValues],
optional_params: dict,
litellm_params: dict,
headers: dict,
) -> dict:
"""
Transform the request to LangFlow format.
View on GitHub (pinned to 77b7c6c40c)