Build a Local AI Agent with Langflow and Ollama
What you will build
Langflow is an open-source visual builder for AI agents and workflows: drag components onto a canvas, connect them with arrows, and press run. Pair it with Ollama, which serves open models on your own machine, and you get a tool-using AI agent with no API keys, no per-token billing, and no data leaving your hardware.
By the end of this guide you will have Langflow running at http://localhost:7860, a local model answering through an Agent component, at least one tool wired in, and the flow published as a REST API. The whole setup takes about 30 minutes.
Prerequisites
- Python 3.10 to 3.14 and
uv, the package manager Langflow recommends. - Ollama installed from ollama.com/download, or via
curl -fsSL https://ollama.com/install.sh | shon Linux. - At least 8 GB of RAM for a 7B model; 16 GB is more comfortable for larger models.
Step 1: Pull a tool-calling model with Ollama
An agent is only as good as its model, and not every local model can call tools. Qwen 2.5 7B supports tool calling in Ollama, fits in about 4.7 GB, and runs well on a laptop CPU or a modest GPU. Pull it and confirm it answers:
ollama pull qwen2.5:7b
ollama run qwen2.5:7b "What is 17 + 25?"
With a GPU of 12 GB or more, qwen3:8b is a stronger alternative. Keep the exact tag — you will type it into Langflow in Step 3.
Step 2: Install and start Langflow
Langflow 1.13 installs with uv. Create a fresh directory, install the package, and start the server:
uv venv
uv pip install langflow
uv run langflow run
Langflow starts at http://127.0.0.1:7860. One change in recent releases catches people out: official packages disable automatic login. Set a superuser password first, then sign in with the username langflow:
export LANGFLOW_SUPERUSER_PASSWORD="a-strong-password"
uv run langflow run
Prefer Docker? The equivalent is docker run -p 7860:7860 -e LANGFLOW_SUPERUSER_PASSWORD="a-strong-password" langflowai/langflow:latest. Inside Docker, Ollama is not on localhost — point Langflow at http://host.docker.internal:11434 instead.
Step 3: Connect Langflow to Ollama
Click New Flow, then Blank Flow. From the components panel, search for Ollama and drag it onto the canvas. Configure it:
- Base URL:
http://localhost:11434(orhttp://host.docker.internal:11434in Docker) - Model Name:
qwen2.5:7b - Tool Model Enabled: on — this tells Langflow the model can call tools
Leave the system message empty for now; the agent gets its instructions in the Agent component.
Step 4: Build your first agent flow
Drag these components onto the canvas and connect them:
- Chat Input — captures what you type in the Playground.
- Agent — connect the Ollama component to its Language Model input, and Chat Input to its Input.
- Chat Output — connects to the Agent's Response output.
- Calculator and URL tools — connect both to the Agent's Tools input so it can do arithmetic and fetch web pages.
A Langflow travel-planning flow with Ollama and a search tool. Source: NVIDIA Blog
In the Agent component, write instructions that state the role and the limits. Something like: "You are a research assistant. Use the calculator for any arithmetic instead of guessing, and use the URL tool to check facts before answering. Say when you do not know something."
Click Playground and try a question that forces tool use: "What is 1847 times 39, and what does the Langflow homepage say the tool is for?" The agent should call the calculator for the math and fetch the page for the second half. If it answers from memory instead, your model may not support tool calling — switch to qwen2.5:7b and check that Tool Model Enabled is on.
Step 5: Publish the flow as a REST API
Every flow in Langflow is also an API. Open the API tab, create an API key, and copy the flow ID from the URL. Then call it from any script:
curl -X POST "http://localhost:7860/api/v1/run/YOUR_FLOW_ID" \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"input_value": "What is 1847 times 39?", "output_type": "chat", "input_type": "chat"}'
The response JSON contains the agent's reply under the text field. That is the point where a visual prototype becomes infrastructure: a shell script, a cron job, or another app can call your local agent without opening the canvas again.
Troubleshooting
- Langflow asks for a password you never set: versions 1.13 and later disable auto-login. Set
LANGFLOW_SUPERUSER_PASSWORDbefore starting. Do not delete the install to regain access — that can permanently remove your flows. - "Connection refused" from the Ollama component: Ollama is not running, or Langflow runs in Docker and
localhostpoints at the container. Start Ollama withollama serve, and usehttp://host.docker.internal:11434from Docker. - The agent never calls tools: the model does not support tool calling, or Tool Model Enabled is off. Use
qwen2.5:7borqwen3:8b, both of which support tools in Ollama. - Port 7860 is taken: start with
langflow run --port 8080, or setLANGFLOW_PORT=8080.
When a visual builder beats writing code
Langflow is not a replacement for LangGraph, CrewAI, or AutoGen — those frameworks give you control a canvas cannot. The visual route wins in three cases: prototyping an agent idea in an afternoon, handing the flow to someone who does not write Python, or needing a working API endpoint before writing any code. Flows export as JSON, and Langflow can generate the equivalent Python, so a prototype can graduate into code when it earns it. For a no-code automation tool with wider app integrations, see our n8n and Ollama guide; for a coding agent in the terminal, see OpenCode with Ollama.
Closing
Thirty minutes from now you can have a local agent that does arithmetic, fetches pages, and answers through an API — with no account, no API key, and no data sent to a cloud provider. Start with the flow above, then add one tool at a time: a search API for live information, a file loader for your own documents, or a vector store to turn the agent into a RAG chatbot over your notes.


Comments
Post a Comment