Langflow - Constructeur visuel d’agent IA et RAG
Langflow est un constructeur visuel open-source basé sur Python pour les applications LLM. Vous assemblez des agents, des chaînes et des pipelines RAG en faisant glisser et en reliant des composants sur un canevas, les testez dans un aire de jeu en direct, puis exposez tout flux en tant qu’endpoint API ou MCP. Il est agnostique du modèle (OpenAI, Anthropic, modèles locaux via Ollama, etc.) et s’appuie sur l’écosystème LangChain.
Installation
| Méthode | Commande |
|---|
| uv (recommandé) | uv pip install langflow |
| pip | pip install langflow |
| Exécuter après install | langflow run (ou python -m langflow run) |
| uvx (pas d’install) | uvx langflow run |
| Docker | docker run -it --rm -p 7860:7860 langflowai/langflow:latest |
| Application de bureau | Télécharger depuis le site officiel (macOS/Windows) |
Nécessite Python 3.10–3.13. Après langflow run, ouvrez http://localhost:7860.
Exécution du serveur
| Commande | Description |
|---|
langflow run | Démarrer l’interface utilisateur + API sur 127.0.0.1:7860 |
langflow run --host 0.0.0.0 --port 7860 | Se lier à toutes les interfaces / port personnalisé |
langflow run --env-file .env | Charger les variables d’environnement depuis un fichier |
langflow run --dev | Mode développeur/hot-reload |
langflow --help | Référence CLI complète |
langflow api-key | Créer une clé API pour l’accès programmatique |
langflow migration | Exécuter les migrations de base de données |
Concepts clés
| Terme | Signification |
|---|
| Flow | Un graphique de composants connectés = une application/pipeline |
| Component | Un nœud (modèle, invite, retrieveur, outil, agent, I/O) |
| Port / Edge | Connexion typée d’entrée/sortie entre composants |
| Playground | Panneau chat/run intégré pour tester un flux interactivement |
| Project | Un espace de travail regroupant plusieurs flux |
| Global Variables | Secrets stockés (clés API) réutilisables dans tous les flux |
Blocs de construction
| Catégorie | Exemples |
|---|
| Entrées/Sorties | Chat Input, Chat Output, Text Input |
| Modèles | OpenAI, Anthropic, Google, Ollama, Groq, HuggingFace |
| Invites | Modèle d’invite, message système |
| Données / RAG | Chargeur de fichier, URL, Split Text, Vector Store (Chroma, Qdrant, Astra, pgvector), Embeddings |
| Agents | Composant Agent avec appel d’outil |
| Outils | Recherche web, Python REPL, requête API, outils MCP |
| Logique | Routeur conditionnel, boucle, pass-through |
Flux RAG typique
File / URL → Split Text → Embeddings → Vector Store (ingestion)
Chat Input → Vector Store (recherche) → Prompt → Model → Chat Output
Construisez-le sur le canevas, ouvrez l’Playground, posez une question, et Langflow exécute le graphique de bout en bout.
Utiliser les flux depuis du code
Chaque flux obtient une API auto-générée. Depuis l’interface utilisateur, cliquez sur API (ou Share → API access) pour copier un extrait :
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())
# Même appel avec 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"}'
Intégration MCP
| Capacité | Comment |
|---|
| Exposer les flux en tant qu’outils MCP | Chaque Project livre un serveur MCP ; pointez un client MCP (Claude Desktop, Cursor) vers celui-ci |
| Consommer les outils MCP externes | Ajouter le composant MCP Tools et connecter une URL/commande de serveur |
Environnement et config
| Variable | Objectif |
|---|
LANGFLOW_HOST / LANGFLOW_PORT | Adresse de liaison et port |
LANGFLOW_DATABASE_URL | Utiliser Postgres au lieu du SQLite par défaut |
LANGFLOW_AUTO_LOGIN=false | Exiger la connexion (multi-utilisateur) |
LANGFLOW_SUPERUSER / LANGFLOW_SUPERUSER_PASSWORD | Seed un compte administrateur |
LANGFLOW_SECRET_KEY | Clé de chiffrement pour les identifiants stockés |
OPENAI_API_KEY, ANTHROPIC_API_KEY, … | Clés du fournisseur (ou définir comme Global Variables) |
Import / Export
| Action | Comment |
|---|
| Exporter un flux | Menu Flow → Export → .json |
| Importer un flux | New → Import le .json |
| Contrôle de version | Engager le JSON de flux exporté dans votre repo |
Flux de travail courants
# Faire fonctionner pour une équipe sur un serveur avec Postgres + auth
LANGFLOW_DATABASE_URL=postgresql://user:pass@db:5432/langflow \
LANGFLOW_AUTO_LOGIN=false \
langflow run --host 0.0.0.0 --port 7860
# Essai éphémère local, pas d'install
uvx langflow run
Langflow vs Dify vs n8n
| Aspect | Langflow | Dify | n8n |
|---|
| Focus | Flux et agents de style LangChain | Plateforme d’app LLMOps (RAG, invites) | Automation générale + noeuds IA |
| Style | Canevas visuel | Studio d’app + workflow | Automation de workflow |
| Endpoints | API + MCP | API + applications chat | Webhooks/automation |
| Meilleur pour | Prototyper des graphiques d’agent/RAG | Livrer les applications LLM avec ops | Coller à travers 500+ services |
Ressources