Skip to content

Langflow - Visual AI Agent & RAG Builder Cheatsheet

Langflow - Visual AI Agent & RAG Builder Cheatsheet

Langflow is an open-source, Python-based visual builder for LLM applications. You assemble agents, chains, and RAG pipelines by dragging and wiring components on a canvas, test them in a live playground, and then expose any flow as an API or MCP endpoint. It is model-agnostic (OpenAI, Anthropic, local models via Ollama, etc.) and builds on the LangChain ecosystem.

Installation

MethodCommand
uv (recommended)uv pip install langflow
pippip install langflow
Run after installlangflow run (or python -m langflow run)
uvx (no install)uvx langflow run
Dockerdocker run -it --rm -p 7860:7860 langflowai/langflow:latest
Desktop appDownload from the official site (macOS/Windows)

Requires Python 3.10–3.13. After langflow run, open http://localhost:7860.

Running the Server

CommandDescription
langflow runStart the UI + API on 127.0.0.1:7860
langflow run --host 0.0.0.0 --port 7860Bind to all interfaces / custom port
langflow run --env-file .envLoad environment variables from a file
langflow run --devDeveloper/hot-reload mode
langflow --helpFull CLI reference
langflow api-keyCreate an API key for programmatic access
langflow migrationRun database migrations

Core Concepts

TermMeaning
FlowA graph of connected components = one app/pipeline
ComponentA node (model, prompt, retriever, tool, agent, I/O)
Port / EdgeTyped input/output connection between components
PlaygroundBuilt-in chat/run panel to test a flow interactively
ProjectA workspace grouping multiple flows
Global VariablesStored secrets (API keys) reusable across flows

Building Blocks

CategoryExamples
Inputs/OutputsChat Input, Chat Output, Text Input
ModelsOpenAI, Anthropic, Google, Ollama, Groq, HuggingFace
PromptsPrompt template, system message
Data / RAGFile loader, URL, Split Text, Vector Store (Chroma, Qdrant, Astra, pgvector), Embeddings
AgentsAgent component with tool calling
ToolsWeb search, Python REPL, API request, MCP tools
LogicConditional router, loop, pass-through

Typical RAG Flow

File / URL  →  Split Text  →  Embeddings  →  Vector Store (ingest)
Chat Input  →  Vector Store (search)  →  Prompt  →  Model  →  Chat Output

Build it on the canvas, open the Playground, ask a question, and Langflow runs the graph end to end.

Using Flows from Code

Every flow gets an auto-generated API. From the UI, click API (or Share → API access) to copy a snippet:

import requests

url = "http://localhost:7860/api/v1/run/<FLOW_ID>"
payload = {"input_value": "What is in my docs?", "output_type": "chat", "input_type": "chat"}
headers = {"x-api-key": "<YOUR_API_KEY>", "Content-Type": "application/json"}

resp = requests.post(url, json=payload, headers=headers)
print(resp.json())
# Same call with curl
curl -X POST "http://localhost:7860/api/v1/run/<FLOW_ID>" \
  -H "x-api-key: <YOUR_API_KEY>" -H "Content-Type: application/json" \
  -d '{"input_value":"hello","output_type":"chat","input_type":"chat"}'

MCP Integration

CapabilityHow
Expose flows as MCP toolsEach Project ships an MCP server; point an MCP client (Claude Desktop, Cursor) at it
Consume external MCP toolsAdd the MCP Tools component and connect a server URL/command

Environment & Config

VariablePurpose
LANGFLOW_HOST / LANGFLOW_PORTBind address and port
LANGFLOW_DATABASE_URLUse Postgres instead of the default SQLite
LANGFLOW_AUTO_LOGIN=falseRequire login (multi-user)
LANGFLOW_SUPERUSER / LANGFLOW_SUPERUSER_PASSWORDSeed an admin account
LANGFLOW_SECRET_KEYEncryption key for stored credentials
OPENAI_API_KEY, ANTHROPIC_API_KEY, …Provider keys (or set as Global Variables)

Import / Export

ActionHow
Export a flowFlow menu → Export.json
Import a flowNew → Import the .json
Version controlCommit exported flow JSON to your repo

Common Workflows

# Spin up for a team on a server with Postgres + auth
LANGFLOW_DATABASE_URL=postgresql://user:pass@db:5432/langflow \
LANGFLOW_AUTO_LOGIN=false \
langflow run --host 0.0.0.0 --port 7860

# Ephemeral local trial, no install
uvx langflow run

Langflow vs Dify vs n8n

AspectLangflowDifyn8n
FocusLangChain-style flows & agentsLLMOps app platform (RAG, prompts)General automation + AI nodes
StyleVisual canvasApp + workflow studioWorkflow automation
EndpointsAPI + MCPAPI + chat appsWebhooks/automation
Best forPrototyping agent/RAG graphsShipping LLM apps with opsGlue across 500+ services

Resources