Langflow
Langflow is a low-code visual framework for building AI applications. It's Python-based and agnostic to any model, API, or database, making it easy to build RAG applications, multi-agent systems, and custom AI workflows.
Features
- Visual Flow Builder: Drag-and-drop interface for building AI applications
- Multi-Model Support: Works with OpenAI, Anthropic, Google, HuggingFace, and more
- RAG Components: Built-in support for vector databases and retrieval
- Custom Components: Create your own Python components
- Agent Support: Build multi-agent systems with memory and tools
- Real-Time Monitoring: Track executions and debug flows
- API Integration: REST API for programmatic access
Quick Start
-
Copy
.env.exampleto.env:cp .env.example .env -
(Optional) Edit
.envto customize settings:- Generate a secure
LANGFLOW_SECRET_KEYfor production - Set
LANGFLOW_AUTO_LOGIN=falseto require authentication - Configure superuser credentials
- Add API keys for LLM providers
- Generate a secure
-
Start Langflow:
docker compose up -d -
Wait for services to be ready (usually takes 1-2 minutes)
-
Access Langflow UI at
http://localhost:7860 -
Start building your AI application!
Default Configuration
| Service | Port | Description |
|---|---|---|
| Langflow | 7860 | Web UI and API |
| PostgreSQL | 5432 | Database (internal) |
Default Credentials (if authentication enabled):
- Username:
langflow - Password:
langflow
Environment Variables
Key environment variables (see .env.example for full list):
| Variable | Description | Default |
|---|---|---|
LANGFLOW_VERSION |
Langflow image version | 1.1.1 |
LANGFLOW_PORT_OVERRIDE |
Host port for UI | 7860 |
POSTGRES_PASSWORD |
Database password | langflow |
LANGFLOW_AUTO_LOGIN |
Auto-login (disable for auth) | true |
LANGFLOW_SUPERUSER |
Superuser username | langflow |
LANGFLOW_SUPERUSER_PASSWORD |
Superuser password | langflow |
LANGFLOW_SECRET_KEY |
Secret key for sessions | (empty) |
LANGFLOW_COMPONENTS_PATH |
Custom components directory | (empty) |
LANGFLOW_LOAD_FLOWS_PATH |
Auto-load flows directory | (empty) |
TZ |
Timezone | UTC |
Resource Requirements
Minimum:
- CPU: 1 core
- RAM: 1GB
- Disk: 5GB
Recommended:
- CPU: 2+ cores
- RAM: 2GB+
- Disk: 20GB+
Volumes
postgres_data: PostgreSQL database datalangflow_data: Langflow configuration, flows, and logs
Using Langflow
Building Your First Flow
- Access the UI at
http://localhost:7860 - Click "New Flow" or use a template
- Drag components from the sidebar to the canvas
- Connect components by dragging between ports
- Configure component parameters
- Click "Run" to test your flow
- Use the API or integrate with your application
Adding LLM Providers
To use external LLM providers, configure their API keys:
- In Langflow UI, go to Settings > Global Variables
- Add your API keys (e.g.,
OPENAI_API_KEY,ANTHROPIC_API_KEY) - Reference these variables in your flow components
Alternatively, add them to your .env file and restart:
# Example LLM API Keys (add to .env)
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=...
Custom Components
To add custom components:
-
Create a directory for your components (e.g.,
./custom_components) -
Update
.env:LANGFLOW_COMPONENTS_PATH=/app/langflow/custom_components -
Mount the directory in
docker-compose.yaml:volumes: - ./custom_components:/app/langflow/custom_components -
Restart Langflow
Auto-Loading Flows
To automatically load flows on startup:
-
Export your flows as JSON files
-
Create a directory (e.g.,
./flows) -
Update
.env:LANGFLOW_LOAD_FLOWS_PATH=/app/langflow/flows -
Mount the directory in
docker-compose.yaml:volumes: - ./flows:/app/langflow/flows -
Restart Langflow
API Usage
Langflow provides a REST API for running flows programmatically.
Get Flow ID
- Open your flow in the UI
- The flow ID is in the URL:
http://localhost:7860/flow/{flow_id}
Run Flow via API
curl -X POST http://localhost:7860/api/v1/run/{flow_id} \
-H "Content-Type: application/json" \
-d '{
"inputs": {
"input_field": "your input value"
}
}'
With Authentication
If authentication is enabled, first get a token:
# Login
curl -X POST http://localhost:7860/api/v1/login \
-H "Content-Type: application/json" \
-d '{
"username": "langflow",
"password": "langflow"
}'
# Use token in subsequent requests
curl -X POST http://localhost:7860/api/v1/run/{flow_id} \
-H "Authorization: Bearer {token}" \
-H "Content-Type: application/json" \
-d '{
"inputs": {
"input_field": "your input value"
}
}'
Production Deployment
For production deployments:
-
Enable Authentication:
LANGFLOW_AUTO_LOGIN=false LANGFLOW_SUPERUSER=admin LANGFLOW_SUPERUSER_PASSWORD=<strong-password> -
Set Secret Key:
# Generate a secure key python -c "from secrets import token_urlsafe; print(token_urlsafe(32))" # Add to .env LANGFLOW_SECRET_KEY=<generated-key> -
Use Strong Database Password:
POSTGRES_PASSWORD=<strong-password> -
Enable SSL/TLS: Use a reverse proxy (nginx, traefik) with SSL certificates
-
Configure Resource Limits: Adjust CPU and memory limits based on your workload
-
Backup Database: Regularly backup the PostgreSQL data volume
Troubleshooting
Langflow Won't Start
- Check logs:
docker compose logs langflow - Ensure PostgreSQL is healthy:
docker compose ps postgres - Verify port 7860 is not in use
Components Not Loading
- Check custom components path is correct
- Ensure Python dependencies are installed in custom components
- Check logs for component errors
Slow Performance
- Increase resource limits in
.env - Reduce
LANGFLOW_WORKERSif low on memory - Optimize your flows (reduce unnecessary components)
Database Connection Errors
- Verify PostgreSQL is running:
docker compose ps postgres - Check database credentials in
.env - Ensure
LANGFLOW_DATABASE_URLis correct
Maintenance
Backup
Backup volumes:
docker compose down
docker run --rm -v compose-anything_postgres_data:/data -v $(pwd):/backup alpine tar czf /backup/postgres-backup.tar.gz -C /data .
docker run --rm -v compose-anything_langflow_data:/data -v $(pwd):/backup alpine tar czf /backup/langflow-backup.tar.gz -C /data .
docker compose up -d
Restore
Restore from backup:
docker compose down
docker run --rm -v compose-anything_postgres_data:/data -v $(pwd):/backup alpine sh -c "cd /data && tar xzf /backup/postgres-backup.tar.gz"
docker run --rm -v compose-anything_langflow_data:/data -v $(pwd):/backup alpine sh -c "cd /data && tar xzf /backup/langflow-backup.tar.gz"
docker compose up -d
Upgrade
To upgrade Langflow:
-
Update version in
.env:LANGFLOW_VERSION=1.2.0 -
Pull new image and restart:
docker compose pull docker compose up -d -
Check for breaking changes in release notes
Useful Commands
# View logs
docker compose logs -f langflow
# Restart Langflow
docker compose restart langflow
# Access PostgreSQL
docker compose exec postgres psql -U langflow -d langflow
# Check resource usage
docker stats
# Clean up
docker compose down -v # WARNING: Deletes all data
References
- Official Documentation
- GitHub Repository
- Component Documentation
- API Documentation
- Community Discord
License
MIT - See LICENSE