{"record":{"id":"8e6498ef0b8fd6e2","repo":"BerriAI/litellm","slug":"tweaks-cannot-be-set-via-request-parameters-they","errorCode":null,"errorMessage":"tweaks cannot be set via request parameters; they would override the operator-configured LangFlow flow components","messagePattern":"tweaks cannot be set via request parameters; they would override the operator-configured LangFlow flow components","errorType":"http","errorClass":"LangFlowError","httpStatus":400,"severity":"error","filePath":"litellm/llms/langflow/chat/transformation.py","lineNumber":130,"sourceCode":"                    content = convert_content_list_to_str(msg)\n                if not isinstance(content, str):\n                    content = str(content)\n                return content\n\n        # Fallback: use last message regardless of role\n        if messages:\n            content = messages[-1].get(\"content\", \"\")\n            if isinstance(content, list):\n                content = convert_content_list_to_str(messages[-1])\n            if not isinstance(content, str):\n                content = str(content)\n            return content\n\n        return \"\"\n\n    def _reject_caller_tweaks(self, params: dict) -> None:\n        if params.get(\"tweaks\") is not None:\n            raise LangFlowError(\n                status_code=400,\n                message=(\n                    \"tweaks cannot be set via request parameters; they would \"\n                    \"override the operator-configured LangFlow flow components\"\n                ),\n            )\n\n    def transform_request(\n        self,\n        model: str,\n        messages: list[AllMessageValues],\n        optional_params: dict,\n        litellm_params: dict,\n        headers: dict,\n    ) -> dict:\n        \"\"\"\n        Transform the request to LangFlow format.\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/langflow/chat/transformation.py#L112-L148","documentation":"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.","triggerScenarios":"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\"}}).","commonSituations":"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.","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)"],"exampleFix":"// before\nlitellm.completion(\n    model=\"langflow/my-flow\",\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n    tweaks={\"openai-0\": {\"model_name\": \"gpt-4o\"}},  # LangFlowError 400\n)\n\n// after\nlitellm.completion(\n    model=\"langflow/my-flow\",           # component config lives in the flow itself\n    messages=[{\"role\": \"user\", \"content\": \"hi\"}],\n    session_id=\"user-123\",              # supported optional params only\n)","handlingStrategy":"validation","validationCode":"SUPPORTED_LANGFLOW_PARAMS = {\"stream\", \"session_id\", \"input_type\", \"output_type\"}\n\ndef sanitize_langflow_params(params: dict) -> dict:\n    return {k: v for k, v in params.items() if k in SUPPORTED_LANGFLOW_PARAMS}\n\n# usage: litellm.completion(model=\"langflow/<flow_id>\", messages=msgs, **sanitize_langflow_params(user_params))","typeGuard":"def is_langflow_safe_params(params: dict) -> bool:\n    return \"tweaks\" not in params or params.get(\"tweaks\") is None","tryCatchPattern":"try:\n    litellm.completion(model=\"langflow/<flow_id>\", messages=msgs, **params)\nexcept Exception as e:\n    status = getattr(e, \"status_code\", None)\n    if status == 400 and \"tweaks\" in str(e):\n        raise UserInputError(\"tweaks are not allowed; configure the flow in LangFlow\") from e\n    raise","preventionTips":["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"],"tags":["langflow","tweaks","invalid-parameter","bad-request"],"backgroundTag":"forbidden-request-parameter","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}