6.2 KiB
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
-
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 | latest |
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 API Keys
You can add API keys for LLM providers in two ways:
Option 1: Global Variables (Recommended)
- Click your profile icon → Settings
- Go to "Global Variables"
- Add your API keys (e.g.,
OPENAI_API_KEY) - Reference them in components using
{OPENAI_API_KEY}
Option 2: Environment Variables
Add to your .env file:
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_API_KEY=...
Langflow will automatically create global variables from these.
Using the API
Get your API token from the UI:
- Click your profile icon → Settings
- Go to "API Keys"
- Create a new API key
Example: Run a flow
curl -X POST http://localhost:7860/api/v1/run/YOUR_FLOW_ID \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"input_value": "Hello"}'
Custom Components
- Create a directory for your components
- Set
LANGFLOW_COMPONENTS_PATHin.env - Create Python files with your component classes
- Restart Langflow to load them
Example component structure:
from langflow import CustomComponent
class MyComponent(CustomComponent):
display_name = "My Component"
description = "Does something cool"
def build(self):
# Your component logic
return result
Security Considerations
-
Secret Key: Generate a strong
LANGFLOW_SECRET_KEYfor production:python -c "from secrets import token_urlsafe; print(token_urlsafe(32))" -
Authentication: Set
LANGFLOW_AUTO_LOGIN=falseto require login -
Database Password: Use a strong PostgreSQL password
-
API Keys: Store sensitive keys as global variables, not in flows
-
SSL/TLS: Use reverse proxy with HTTPS in production
-
Network Access: Restrict access with firewall rules
Upgrading
To upgrade Langflow:
-
Update
LANGFLOW_VERSIONin.env(or uselatest) -
Pull and restart:
docker compose pull docker compose up -d -
Check logs:
docker compose logs -f langflow
Troubleshooting
Service won't start:
- Check logs:
docker compose logs langflow - Verify database:
docker compose ps postgres - Ensure sufficient resources allocated
Cannot access UI:
- Check port 7860 is not in use:
netstat -an | findstr 7860 - Verify firewall settings
- Check container health:
docker compose ps
API key not working:
- Verify the key is set in Global Variables
- Check the variable name matches in your components
- Ensure
LANGFLOW_STORE_ENVIRONMENT_VARIABLES=true
Flow execution errors:
- Check component configurations
- Review logs in the UI under each component
- Verify API keys have sufficient credits/permissions
References
- Official Website: https://langflow.org
- Documentation: https://docs.langflow.org
- GitHub: https://github.com/langflow-ai/langflow
- Discord Community: https://discord.gg/EqksyE2EX9
- Docker Hub: https://hub.docker.com/r/langflowai/langflow
License
Langflow is licensed under MIT. See LICENSE for more information.