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
| Method | Command |
|---|
| uv (recommended) | uv pip install langflow |
| pip | pip install langflow |
| Run after install | langflow run (or python -m langflow run) |
| uvx (no install) | uvx langflow run |
| Docker | docker run -it --rm -p 7860:7860 langflowai/langflow:latest |
| Desktop app | Download from the official site (macOS/Windows) |
Requires Python 3.10–3.13. After langflow run, open http://localhost:7860.
Running the Server
| Command | Description |
|---|
langflow run | Start the UI + API on 127.0.0.1:7860 |
langflow run --host 0.0.0.0 --port 7860 | Bind to all interfaces / custom port |
langflow run --env-file .env | Load environment variables from a file |
langflow run --dev | Developer/hot-reload mode |
langflow --help | Full CLI reference |
langflow api-key | Create an API key for programmatic access |
langflow migration | Run database migrations |
Core Concepts
| Term | Meaning |
|---|
| Flow | A graph of connected components = one app/pipeline |
| Component | A node (model, prompt, retriever, tool, agent, I/O) |
| Port / Edge | Typed input/output connection between components |
| Playground | Built-in chat/run panel to test a flow interactively |
| Project | A workspace grouping multiple flows |
| Global Variables | Stored secrets (API keys) reusable across flows |
Building Blocks
| Category | Examples |
|---|
| Inputs/Outputs | Chat Input, Chat Output, Text Input |
| Models | OpenAI, Anthropic, Google, Ollama, Groq, HuggingFace |
| Prompts | Prompt template, system message |
| Data / RAG | File loader, URL, Split Text, Vector Store (Chroma, Qdrant, Astra, pgvector), Embeddings |
| Agents | Agent component with tool calling |
| Tools | Web search, Python REPL, API request, MCP tools |
| Logic | Conditional 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
| Capability | How |
|---|
| Expose flows as MCP tools | Each Project ships an MCP server; point an MCP client (Claude Desktop, Cursor) at it |
| Consume external MCP tools | Add the MCP Tools component and connect a server URL/command |
Environment & Config
| Variable | Purpose |
|---|
LANGFLOW_HOST / LANGFLOW_PORT | Bind address and port |
LANGFLOW_DATABASE_URL | Use Postgres instead of the default SQLite |
LANGFLOW_AUTO_LOGIN=false | Require login (multi-user) |
LANGFLOW_SUPERUSER / LANGFLOW_SUPERUSER_PASSWORD | Seed an admin account |
LANGFLOW_SECRET_KEY | Encryption key for stored credentials |
OPENAI_API_KEY, ANTHROPIC_API_KEY, … | Provider keys (or set as Global Variables) |
Import / Export
| Action | How |
|---|
| Export a flow | Flow menu → Export → .json |
| Import a flow | New → Import the .json |
| Version control | Commit 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
| Aspect | Langflow | Dify | n8n |
|---|
| Focus | LangChain-style flows & agents | LLMOps app platform (RAG, prompts) | General automation + AI nodes |
| Style | Visual canvas | App + workflow studio | Workflow automation |
| Endpoints | API + MCP | API + chat apps | Webhooks/automation |
| Best for | Prototyping agent/RAG graphs | Shipping LLM apps with ops | Glue across 500+ services |
Resources