Build flows and components with Langflow Assistant
Langflow Assistant is an in-app virtual assistant pane accessible from the canvas toolbar.
It can answer questions about the application and help you get more out of Langflow.
Langflow Assistant understands the structure of the Langflow graph, so it can build complete flows or create individual components from natural language prompts.
Behind the scenes, Langflow Assistant runs a built-in Langflow flow on your Langflow server each time you send a message. This flow is distinct from the flow that is open in the canvas, and has its own language model. The language model in Langflow Assistant only has the currently opened flow in your workspace for context. To give Langflow Assistant context for a different flow, switch to that flow in your workspace, and open Langflow Assistant.
Prerequisites
-
Connect an LLM provider in the Global model providers page for Langflow Assistant to use
-
LANGFLOW_AGENTIC_EXPERIENCEmust betrue(default).Langflow Assistant is available out of the box. Set this to
falseto turn it off for a deployment, for example if you don't want model-generated component code running on your server. While it is off, the Assistant's endpoints return404. For more information, see Supported environment variables. -
Custom component creation must be enabled and permitted for your user role:
LANGFLOW_ALLOW_CUSTOM_COMPONENTSmust betrue(default).LANGFLOW_CUSTOM_COMPONENT_ADMIN_ONLYmust befalse(default) for non-superusers. For superusers, this option is irrelevant.
For more information, see Restrict custom component creation to superusers.
Create a custom component with Langflow Assistant
In this example, you'll prompt Langflow Assistant to create a custom component that validates and normalizes a list of URLs.
You'll then iterate on the code based on the results in the Playground.
-
In the canvas toolbar, click the Langflow icon. The Langflow Assistant pane opens.
-
Optionally, ask
What can you help me with?for a list of Langflow Assistant's capabilities. -
Prompt Langflow Assistant to generate a custom component. For example:
Create a custom component URLTitleExtractor with:input: textoutput: list of {url, title, status}timeout handling + per-URL error handlingclean docstring and typed methods.” -
Langflow Assistant generates component code from your prompt. Because generation is model-driven, your code may differ from the example below.
Python component code
import htmlimport refrom typing import Anyfrom urllib.error import HTTPError, URLErrorfrom urllib.request import Request, urlopenfrom lfx.custom import Componentfrom lfx.io import FloatInput, MessageTextInput, Outputfrom lfx.schema import DataFrameclass URLTitleExtractor(Component):"""Extract URLs from text, fetch each page, and return URL/title/status rows."""display_name = "URLTitleExtractor"description = "Extracts URLs from input text and fetches page titles with per-URL status handling."icon = "Link"inputs = [MessageTextInput(name="text",display_name="Text",info="Text that may contain one or more URLs.",required=True,),FloatInput(name="timeout",display_name="Timeout",value=5.0,info="HTTP request timeout in seconds for each URL.",range_spec={"min": 0.1, "max": 60.0, "step": 0.1, "step_type": "float"},),]outputs = [Output(name="dataframe",display_name="DataFrame",method="build_dataframe",),]URL_PATTERN = re.compile(r"https?://[^\s<>\]\"'`{}|\\^]+", re.IGNORECASE)TITLE_PATTERN = re.compile(r"<title\b[^>]*>(.*?)</title>", re.IGNORECASE | re.DOTALL)def build_dataframe(self) -> DataFrame:"""Build a DataFrame containing URL, extracted title, and request status."""urls = self._extract_urls(self.text)rows = [self._process_url(url, self.timeout) for url in urls]return DataFrame(rows)def _extract_urls(self, text: str) -> list[str]:"""Extract unique URLs from text using a conservative regex."""if not text:return []matches = self.URL_PATTERN.findall(text)cleaned_urls: list[str] = []seen: set[str] = set()for url in matches:cleaned = url.rstrip(".,);:!?]}")if cleaned and cleaned not in seen:seen.add(cleaned)cleaned_urls.append(cleaned)return cleaned_urlsdef _process_url(self, url: str, timeout: float) -> dict[str, Any]:"""Fetch a URL and return a row with url, title, and status."""request = Request(url,headers={"User-Agent": "Mozilla/5.0 (compatible; Langflow URLTitleExtractor/1.0)"},)try:with urlopen(request, timeout=float(timeout)) as response:status_code = getattr(response, "status", 200)content_bytes = response.read()content_type = response.headers.get_content_charset() or "utf-8"html_text = content_bytes.decode(content_type, errors="replace")title = self._extract_title(html_text)return {"url": url, "title": title, "status": str(status_code)}except HTTPError as exc:title = ""try:body = exc.read()charset = exc.headers.get_content_charset() if exc.headers else Noneif body:html_text = body.decode(charset or "utf-8", errors="replace")title = self._extract_title(html_text)except Exception:title = ""return {"url": url, "title": title, "status": str(exc.code)}except TimeoutError:return {"url": url, "title": "", "status": "timeout"}except URLError as exc:reason = getattr(exc, "reason", None)if isinstance(reason, TimeoutError):status = "timeout"else:status = "request_error"return {"url": url, "title": "", "status": status}except Exception:return {"url": url, "title": "", "status": "request_error"}def _extract_title(self, html_text: str) -> str:"""Extract and normalize the HTML title from a document string."""if not html_text:return ""match = self.TITLE_PATTERN.search(html_text)if not match:return ""title = html.unescape(match.group(1))title = re.sub(r"\s+", " ", title).strip()return titleTo inspect the code, click View Code. To add the component to the canvas, click Add to Canvas.
-
Connect the component to Chat Input and Chat Output components. At this point your flow has three connected components:
- Chat Input sends the text that contains URLs into the URLTitleExtractor so the flow runs when you chat in the Playground or send a prompt from an app.
- URLTitleExtractor reads that text, finds URLs, fetches each page, and outputs a Table with
url,title, andstatuscolumns. - Chat Output receives URLTitleExtractor's result and displays the Table back to the user or calling application.

-
Open the Playground, and tell Langflow to check a list of URLs. For example:
Check these links: https://langflow.orghttps://github.com/langflow-ai/langflowhttps://python.orghttps://this-domain-should-not-resolve-12345.invalid -
Run the flow. The output will be similar to the following, with a Table with one row per URL, including page titles and status codes.
url title status https://langflow.org Langflow | Low-code AI builder for agentic and RAG applications 200 https://github.com/langflow-ai/langflow GitHub - langflow-ai/langflow: Langflow is a powerful tool for building and deploying AI-powered agents and workflows. - GitHub 200 https://python.org Welcome to Python.org 200 https://this-domain-should-not-resolve-12345.invalid -
To iterate further, tell Langflow Assistant what you want. For example, prompt it to
Update URLTitleExtractor to add max_urls (default 5) and skip duplicates..Langflow Assistant generates an updated URLTitleExtractor component (again, the exact code may differ from a previous run).
-
Replace the old component with the new component. Set max_urls to
3. In the Playground, enter a list that includes a duplicate URL and the invalid URL from before:Check these links: https://langflow.orghttps://github.com/langflow-ai/langflowhttps://python.orghttps://langflow.orghttps://this-domain-should-not-resolve-12345.invalid -
Run the flow. The output will be similar to the following, with the duplicate
https://langflow.orgremoved and only 3 valid URLs displayed.url title status https://langflow.org Langflow | Low-code AI builder for agentic and RAG applications 200 https://github.com/langflow-ai/langflow GitHub - langflow-ai/langflow: Langflow is a powerful tool for building and deploying AI-powered agents and workflows. - GitHub 200 https://python.org Welcome to Python.org 200
Build an agent flow with Langflow Assistant
Building a flow reads and writes the entire Langflow graph on every turn, which can use significantly more tokens than single-component generation.
In addition to generating individual components, Langflow Assistant can create a flow from a single prompt.
Continuing from the Create a custom component with Langflow Assistant example, ask Langflow Assistant to build a simple agent flow that uses the URLTitleExtractor custom component as a tool.
-
With the URLTitleExtractor component still on the canvas, open Langflow Assistant and prompt it to build the agent flow:
Build a simple agent flow using the URLTitleExtractor custom component as a tool. -
Langflow Assistant presents a diagram of the flow it is proposing. To approve, click Add to Canvas.
Langflow Assistant adds an Agent component, connects the URLTitleExtractor to its Tools input, and connects Chat Input and Chat Output to complete the flow. Flow generation is model-driven, so the exact wiring may differ from this example.
-
To iterate, describe changes to Langflow Assistant, and then click Replace canvas to replace the entire flow currently on the canvas. For example:
Connect the URLTitleExtractor component's Toolset port to the Agent's Tools port. -
Open the Playground and ask the agent to check a URL:
What is the title of the page at https://langflow.org?The agent uses the URLTitleExtractor tool to fetch the page and return the title.
-
Langflow Assistant can further iterate on the flow, or answer questions about Langflow. For example, ask Langflow Assistant
How do I send an API request to chat with this flow in Python?The response includes a request sourced from the Langflow documentation that you can copy and paste into your application.
Reference canvas components in your prompts
Reference components and their fields directly in a Langflow Assistant prompt using the @ and . selectors.
In the Langflow Assistant prompt input, enter @ to list all available components, and then select a component to insert its reference.
To select a specific field within a component, enter . after the component.
For example, to prompt Langflow Assistant to update the system prompt field on an Agent component, enter the following:
Update @Agent.System Prompt to always respond in bullet points.
Use slash commands
Slash commands change how Langflow Assistant behaves in your browser session. Commands run locally and are never sent to the model.
In the Langflow Assistant prompt input, enter / to list the available commands.
Use the arrow keys to highlight a command, and then press Enter or Tab, or click the command, to insert it into the input.
Add an argument if the command takes one, and then press Enter to run it.
To close the list without inserting a command, press Esc.
| Command | Description |
|---|---|
/skip-all | Turns automatic approval on or off for plans, flow proposals, and validated components. The setting persists across sessions. |
/history [0–100 | off] | Sets how many past messages the Assistant remembers. The minimum is 0 and the maximum is 100. /history off restores the default. Without an argument, the command reports the current value. |
/iterations [1–200 | off] | Sets the maximum number of steps the Assistant can take for each request. The default is 100, the minimum is 1, and the maximum is 200. /iterations off restores the default. Without an argument, the command reports the current value. |
If Langflow Assistant stops with The agent ran out of steps before finishing, the request needed more steps than the /iterations limit allows.
For more information, see The agent ran out of steps before finishing.
Use a local or OpenAI-compatible model
Langflow Assistant can run on a model served from your own machine or from any OpenAI-compatible endpoint, so your prompts never leave your environment.
To use a local model served by Ollama, set the OLLAMA_BASE_URL global variable to your Ollama server, such as http://localhost:11434.
Ollama requires no API key.
To use an OpenAI-compatible server instead of OpenAI itself, set the OPENAI_BASE_URL global variable to your server's URL, and set OPENAI_API_KEY to the key your server expects.
You can set both values as global variables or as environment variables of the same name. Global variables take precedence, and Langflow falls back to the environment variable when no global variable is set.
Langflow Assistant builds flows by calling tools, so it requires a model that supports tool calling. Small local models often can't call tools reliably, which appears as an Assistant that only chats and never changes your canvas. If the Assistant doesn't act on your prompts, try a larger model.
Connect an external client with MCP
Langflow Assistant and Langflow's flow-authoring tools are available to external MCP clients, such as Cursor, Claude Code, and Codex.
A client can build, inspect, patch, and run your flows without opening the visual editor.
The run_assistant tool sends one instruction to Langflow Assistant, and the Assistant builds a complete flow by choosing and connecting components.
Every tool call is authorized as the user who owns the Langflow API key, so a client can only reach the flows that key can reach.
run_assistant requires Langflow Assistant to be enabled with LANGFLOW_AGENTIC_EXPERIENCE set to true (the default) and a language model that supports tool calling.
Flow-authoring tools other than run_assistant are available when Langflow Assistant is turned off.
- Call Langflow Assistant with `lfx-mcp`
- Call Langflow Assistant with Cursor
lfx-mcp is a local MCP server a coding agent starts on your machine.
It connects to your Langflow instance with LANGFLOW_SERVER_URL and LANGFLOW_API_KEY, and it includes run_assistant.
-
Add
lfx-mcpto your MCP client. For example, to addlfx-mcpin Claude Code, run:claude mcp add langflow \-e LANGFLOW_SERVER_URL=http://localhost:7860 \-e LANGFLOW_API_KEY=<YOUR_LANGFLOW_API_KEY> \-- uvx --from lfx lfx-mcpReplace
LANGFLOW_SERVER_URLwith your Langflow server URL, and replaceLANGFLOW_API_KEYwith your Langflow API key.For more information, see Build flows with the LFX MCP server.
-
To confirm that the server is registered, run:
claude mcp listThe output includes an entry similar to the following:
langflow: uvx --from lfx lfx-mcp -
Start Claude Code, and then prompt it to use Langflow Assistant.
claudeEnter a prompt, such as the following:
Use the Langflow assistant to build a chatbot flow with a Chat Input, an OpenAI model, and a Chat Output.Claude Code calls
run_assistant. Langflow Assistant chooses the components, connects them into a flow, and saves it. -
Open Langflow. The new flow is available in your project.
Cursor can call the same tools as Claude without a local lfx-mcp process.
Langflow serves them over streamable HTTP at /api/v1/agentic/mcp.
-
In Cursor, open Cursor Settings, select MCP, and then click Add New Global MCP Server.
-
Add the server to
mcp.json:{"mcpServers": {"langflow-assistant": {"url": "http://localhost:7860/api/v1/agentic/mcp","headers": {"x-api-key": "YOUR_LANGFLOW_API_KEY"}}}}Replace
LANGFLOW_SERVER_URLwith your Langflow server URL, and replaceLANGFLOW_API_KEYwith your Langflow API key. -
Save the file. Cursor lists langflow-assistant and its tools, including
run_assistant. -
Ask Cursor to use the Assistant with the same kind of prompt as in Call Langflow Assistant with
lfx-mcp.
In the Langflow Assistant pane, a new flow is displayed as a diagram until you click Add to canvas, but a run_assistant call saves the flow as soon as Langflow Assistant completes its run.
The client can pass these arguments:
- flow_id: Edits this
flow_id. Ifflow_idis omitted, Langflow Assistant creates a new flow by default. - session_id: Continues an earlier Assistant conversation by
session_id. - provider and model_name: Selects the Assistant's model, such as
OpenAIandgpt-4o. If omitted, Langflow uses the first configured provider by default.
The agent ran out of steps before finishing
Langflow Assistant stops a request and shows the following error:
The agent ran out of steps before finishing. Try again, or break the request into smaller parts.
When you expand Error details, the Component is Agent, and the Step shows what the Assistant was doing when it stopped, such as generating_flow.
This error means the request needed more steps than the step limit allows. Each step is one model call, and each tool the Assistant uses, such as searching for components, generating a custom component, or building and running the flow, takes a step. Requests that create several custom components and a flow with many components in a single prompt use the most steps. Because the model chooses a different path each time, the same prompt can finish on one attempt and run out of steps on another.
To resolve this error, do any of the following:
- Raise the step limit for your browser session, and then send the request again.
For example, enter
/iterations 150in the Langflow Assistant prompt input, and then press Enter. The default limit is100, and the maximum is200. To check the current limit, enter/iterationswithout an argument. - To raise the default limit for every user of your Langflow server, set the
LANGFLOW_ASSISTANT_ITERATIONSenvironment variable, and then restart Langflow. A value set with/iterationsstill overrides the server default for that browser session. - Split the request into smaller prompts. For example, ask Langflow Assistant to create the custom components first, and then ask it to build the flow that uses them.
A higher step limit doesn't make simple requests more expensive, because the Assistant stops as soon as the request is done. It only lets long requests use more model calls and tokens before they stop.
See also
Was this page helpful?