As more businesses and creators look to integrate advanced AI models into their workflows, connecting tools like n8n with Ollama becomes increasingly valuable. n8n is a powerful open-source workflow automation tool, and Ollama makes it easy to run Large Language Models (LLMs) like Llama 2 or Mistral locally. Combining the two enables you to build private, fast, and customizable AI-powered flows without relying on external APIs. If you’ve been wondering how to connect n8n to Ollama to unlock the full power of local AI automation, this guide will walk you through the process from start to finish.
Why Connect n8n to Ollama?
Before diving into the steps, let’s discuss why this integration is worth your time.
- Data Privacy: With Ollama running locally, your data never leaves your machine.
- Faster Performance: No API latency or external call limits.
- Cost-Free LLM Access: No OpenAI API key required for basic usage.
- Custom AGI Agents: You can build AI workflows that call local models to summarize, analyze, or generate content.
Use cases include automated content summarization, chatbots, voice agents, and internal data analysis tools.
Prerequisites
Make sure you have the following before starting:
- A working installation of n8n (self-hosted or local). Here’s how to run n8n locally.
- The Ollama CLI installed and up and running on your machine. You can download it from ollama.com.
- At least one model pulled via Ollama (e.g.,
ollama run mistral). - Basic familiarity with HTTP nodes in n8n.
Step-by-Step Guide: How To Connect n8n to Ollama
Let’s walk through the full setup of this integration using n8n’s HTTP Request node to interact with Ollama’s local API.
Step 1: Run Ollama and Load Your Model
Open your terminal and make sure Ollama is installed and running. You’ll also want to load a model if you haven’t yet:
ollama run llama2
This ensures Ollama downloads the model and runs a local server on http://localhost:11434.
You can test this by running a simple curl command:
curl http://localhost:11434/api/generate -d '{ "model": "llama2", "prompt":"Hello, who are you?" }'
Step 2: Open n8n and Create a New Workflow
- Launch your n8n instance.
- Create a New Workflow and name it something like
Ask Ollama.
Step 3: Add a Trigger Node
- Add a Webhook Trigger if you want to use an external service to initiate the prompt.
- Alternatively, use the Manual Trigger for testing.
Step 4: Add an HTTP Request Node for Ollama
- Drag in an HTTP Request node.
- Configure it with the following settings:
- HTTP Method: POST
- URL:
http://localhost:11434/api/generate - Authentication: None
- Content-Type: JSON
- Body Parameters (RAW JSON):
{
"model": "llama2",
"prompt": "Write a product description for a new coffee maker.",
"stream": false
}
✅ Tip: Use expressions to dynamically pass prompts from other nodes.
- Save the node and click Execute Node.
You should receive a response from the local LLM model with your generated text.
Step 5: Parse and Use the Output
The response from Ollama will look like this:
{
"response": "Introducing the EspressoMaster 3000..."
}
From here, you can:
- Send it to email using an Email Node
- Forward to Slack using a Slack Node
- Store in Google Sheets or Notion
Here’s a simple use case: Build a workflow triggered by a Google Form submission that generates LLM responses and emails them. Check our guide on sending emails with n8n.
Example: Automated Summary Tool
Let’s say you want to build a tool that summarizes news articles using Ollama and n8n.
Workflow Structure:
- Webhook Trigger – Submit article URLs
- HTTP Request Node – Use HTTP to fetch the page content (or use a scraper API)
- Ollama Node (HTTP Request) – Send the content with a prompt like “Summarize this article”
- Return Response – Output summary via email or UI
This makes content summarization fast and API-free.
Common Issues and Fixes
If your connection doesn’t work as expected, a few things to check:
- Make sure Ollama is running in the terminal and that the model is loaded
- Confirm your n8n instance can access
localhost:11434— Docker users may need to point tohost.docker.internal - If you get a model fetch error, see this article on how to fix the Ollama fetch error in n8n
Performance Tip: Use Lightweight Models
While LLaMA 2 is powerful, some users may benefit from smaller models like Mistral or LLaMA 3 8B for performance reasons, especially on local hardware.
Model Comparison Table
Here’s a simple outline showing models you can run with Ollama:
| Model | RAM Requirement | Use Case |
|---|---|---|
| LLaMA 2 | High (16GB+) | General-purpose language tasks |
| Mistral | Medium (8-12GB) | Fast content generation |
| LLaMA 3 8B | High | Sustained reasoning and chatbots |
These models are freely hosted by Ollama with daily updates, and you can switch between them just by changing the "model" key in your n8n node.
Enhancing With Agent Workflows
By integrating Ollama into agent-based workflows, you can build intelligent tools that plan, execute, and react to real-time data. For example, see how to build a plan and execute AI agent in n8n.
Final Thoughts
Knowing how to connect n8n to Ollama unlocks a powerful and flexible way to integrate local AI models into your automations. Whether you’re building chatbots, voice agents, summarizers, or coding assistants, Ollama offers serious potential — especially with n8n’s no-code/low-code approach.
As the AI landscape evolves, running models locally with tools like Ollama offers privacy, performance, and freedom from API providers — all while enabling advanced agentic workflows and automation.
FAQ
How do I change the model used by Ollama in n8n?
Simply update the "model": "modelname" field in your HTTP Request node’s JSON body. Make sure the model is downloaded with ollama pull modelname.
Can I stream response data instead of retrieving it all at once?
Yes. Set "stream": true in the body. However, n8n currently doesn’t handle streaming responses very well. It’s better to keep "stream": false for now.
How do I use n8n and Ollama with Docker?
If n8n is running inside Docker, replace localhost in the URL with host.docker.internal to access your host’s Ollama server.
What if Ollama isn’t responding to the HTTP Request?
Check that the CLI is running and the model is loading properly. Restart both Ollama and n8n if needed. Also make sure ports aren’t blocked by firewalls or proxies.
Can I use different LLMs like Mistral or Code LLaMA?
Absolutely. Ollama supports multiple open-source models. Just change the "model" field and pull the desired model with ollama pull.
Copy-paste templates.
Beginner friendly.