Build AI Agents Locally and Access Them Anywhere with Langflow
Source: Dev.to
Building AI Agents with Langflow – From Local Install to Public Access
There was a time when building AI agents meant stitching together multiple libraries, writing glue code, and debugging small mismatches between APIs. That approach still exists, but tools like Langflow have made the process far more approachable. Instead of writing everything from scratch, you now work on a visual canvas where components connect like building blocks.
What makes this even more interesting is that you can run the entire system on your own machine. Your workflows, data, and experiments stay local. The trade‑off is that, by default, the service is only reachable on your local network. If you want to test your agent on your phone, share it with someone else, or integrate it with an external service, you need a way to expose it.
This guide walks through that journey in a practical, grounded way. You will:
- Install Langflow and run it locally.
- Make it accessible from anywhere using a simple tunneling approach.
Understanding Langflow in Practice
Langflow is a visual environment for building AI pipelines. Instead of writing long scripts, you connect components—language models, vector databases, APIs, logic blocks—on a canvas.
- Each workflow becomes a working API endpoint.
- The flow is interactive in the UI and usable in real applications.
- Flexibility: Switch between providers, run local inference, or hook up external tools as needed.
Why Running It Locally Makes Sense
| Benefit | Why it matters |
|---|---|
| Privacy | Sensitive documents or internal datasets never leave your machine. |
| Cost | Pair with local models to avoid usage‑based billing. |
| Customization | Choose your environment, services, and storage configuration. |
Getting Started with Installation
You can install Langflow in several ways, depending on your comfort with Python environments.
Option 1 – Using uv (recommended for isolated environments)
pip install uv
uv pip install langflow
uv run langflow runOption 2 – Using pip (if you already manage Python manually)
pip install langflow
langflow runOption 3 – Using Docker (no local dependency management)
docker run -p 7860:7860 langflowai/langflow:latestAfter the command starts, open your browser at:
http://localhost:7860You should see the Langflow interface ready to use.
Running Langflow on a Different Port
If port 7860 is already occupied, change it:
langflow run --port 8080Or set an environment variable:
export LANGFLOW_PORT=8080
langflow runA More Stable Setup with Docker Compose
For longer‑term usage (persistence, database, easy restarts), Docker Compose is a better choice.
docker-compose.yml
services:
langflow:
image: langflowai/langflow:latest
pull_policy: always
ports:
- "7860:7860"
depends_on:
- postgres
env_file:
- .env
environment:
- LANGFLOW_DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
- LANGFLOW_CONFIG_DIR=/app/langflow
volumes:
- langflow-data:/app/langflow
postgres:
image: postgres:16
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- langflow-postgres:/var/lib/postgresql/data
volumes:
langflow-postgres:
langflow-data:.env
POSTGRES_USER=langflow
POSTGRES_PASSWORD=changeme
POSTGRES_DB=langflow
LANGFLOW_SUPERUSER=admin
LANGFLOW_SUPERUSER_PASSWORD=changeme
LANGFLOW_AUTO_LOGIN=FalseStart everything:
docker compose up -dThis setup ensures your flows and configurations persist across restarts.
Making Your Local Setup Accessible
Running Langflow locally limits access to your machine. To expose it publicly, create a tunnel. One simple, free option is Pinggy.
Create a Public URL
ssh -p 443 -R0:localhost:7860 free.pinggy.ioAfter the command runs, Pinggy returns a public URL that forwards traffic to your local Langflow instance. Open that link from any device to access Langflow remotely.
Adding Basic Protection
If you share the URL, protect it with basic authentication:
ssh -p 443 -R0:localhost:7860 -t free.pinggy.io b:username:passwordOnly users who know the username and password can reach your setup.
Building Your First Flow
Now that Langflow is up and reachable, you can start creating workflows. A simple starter is a question‑answering flow:
- Drag a LLM component (e.g., OpenAI, Llama‑cpp).
- Add a Prompt node that formats the user’s question.
- Connect the Prompt to the LLM and expose the output as an API endpoint.
- Test the endpoint via the UI or with
curl:
curl -X POST http:///api/v1/flow//run \
-H "Content-Type: application/json" \
-d '{"input": "What is Langflow?"}'You now have a fully functional AI agent that you can call from any client, on any device.
Recap
| Step | What you did |
|---|---|
| Install | Chose uv / pip / Docker (or Docker Compose) and started Langflow locally. |
| Expose | Used Pinggy to create a public URL, optionally adding basic auth. |
| Build | Designed a visual workflow that becomes a callable API. |
With Langflow running locally and reachable from anywhere, you have a powerful, private, and cost‑effective platform for prototyping and deploying AI agents. Happy building!
Agent that fetches information from the web
Basic components include
- Chat Input – user queries
- Search tool – fetches information
- Parser – converts structured data into text
- Prompt Template – combines inputs
- Language model – generates responses
- Chat Output – displays results
You connect these components visually; each connection shows how data flows from one step to the next.
Exploring a RAG Workflow
One of the most practical use cases is Retrieval‑Augmented Generation (RAG).
In simple terms, you allow your agent to answer questions based on your own documents.
Typical flow
- Upload a document
- Split it into smaller chunks
- Convert those chunks into embeddings
- Store them in a vector database
- Retrieve relevant pieces during a query
- Combine them with the question
- Generate a final answer
This approach makes your agent far more useful for domain‑specific tasks.
Running Everything Locally with Ollama
If you want complete control, you can avoid external APIs entirely.
Start a local model
ollama pull llama3.2
ollama serveConnect Langflow
http://localhost:11434Now the entire pipeline runs on your own machine, from document processing to response generation.
Using Your Flow as an API
Every workflow you build can be called programmatically.
Example request
curl -X POST \
"http://localhost:7860/api/v1/run/" \
-H "Content-Type: application/json" \
-d '{"input_value": "What does the document say about pricing?"}'Replace localhost with your public tunnel URL to call your agent from anywhere.
Flexibility Across Tools and Models
Langflow supports a wide range of integrations. You can experiment with different models, connect various databases, and integrate external services without changing your entire setup.
This flexibility makes it useful not only for experimentation but also for building real applications.
Conclusion
Self‑hosting Langflow changes how you approach building AI systems. Instead of relying entirely on external platforms, you gain ownership over your workflows and data.
Adding remote access completes the picture: it lets your local setup behave like a deployable service without the overhead of managing servers.
The combination of a visual builder, local control, and simple remote access creates a workflow that feels both powerful and practical. It lowers the barrier to experimentation while still providing the tools needed for more serious projects.