How to Connect n8n to a Local LLM: Building Private AI Automation with Ollama
Описание и применение
n8n подключается к локальному LLM Ollama через внутреннюю сеть Docker, обеспечивая автоматизацию без передачи данных внешним сервисам.
Задача
Running AI-powered workflows on private infrastructure while ensuring sensitive data never leaves the internal network.
Результат
n8n workflows can now invoke a locally hosted LLM without external API calls, keeping data within the internal network and reducing privacy risks.
Рабочий процесс
- Deploy n8n and Ollama containers with Docker Compose, ensuring Ollama is on a private network.
- Download required model (e.g., qwen2.5:1.5b) into Ollama before isolating the network.
- Configure n8n HTTP Request node to POST to http://ollama:11434/api/chat with JSON payload.
- Disable streaming in Ollama to receive full response in one JSON.
- Parse response message.content to extract summary and category.
- Store structured output in desired destination (e.g., database, email).
- Verify connectivity with GET http://ollama:11434/api/tags and POST /api/chat tests.
- Implement network isolation: Ollama only on internal network, n8n on frontend and inference networks.
- Add authentication gateway if needed, otherwise rely on network isolation.
- Monitor logs, execution history, and backups to ensure no sensitive data leaks.
Доказательства
Deploy Ollama alongside n8n, configure an HTTP request, and within minutes, your workflow can summarize support tickets, classify requests, or process internal documents without sending their contents to an external AI provider.
The Ollama container is connected only to the internal inference network. Its API port is not published to the host or public Internet.
Authentication requirements depend on how Ollama is deployed. By default, Ollama's local API does not require an API key.
- Дата записи: 2026-10-21T13:41:38.632Z