Lorena Dávila ErmusIf you want AI agents running on your own machine, with your own models, and no data leaving your...
If you want AI agents running on your own machine, with your own models, and no data leaving your computer, this is the article :).
This is part three of the series. In part one we set up PostgreSQL, and in part two we covered the LLM concepts (models, parameter, quantization, context, capabilities, VRAM). Today we put them to work: n8n for the workflows and Ollama for the models.
One prerequisite: Docker. If you do not have it yet, install Docker Desktop for Mac following the official guide [Docker docs].
The fastest path is n8n's official Self-hosted AI Starter Kit, a Docker Compose template that ships n8n, Ollama, Qdrant (a vector store) and PostgreSQL preconfigured to talk to each other [n8n docs].
git clone https://github.com/n8n-io/self-hosted-ai-starter-kit.git
cd self-hosted-ai-starter-kit
cp .env.example .env # file where your passwords are stored
The .env file is hidden by default. In Finder, press Command + Shift + Period to show hidden files, or just edit it from the terminal. Update the credentials, for example:
POSTGRES_USER=admin
POSTGRES_PASSWORD=root
POSTGRES_DB=n8n
Also replace the N8N_ENCRYPTION_KEY and N8N_USER_MANAGEMENT_JWT_SECRET values with your own random strings.
Now one Mac-specific detail. Docker on Apple Silicon cannot use the Mac's GPU, so the kit's README recommends running Ollama natively on your Mac for speed and letting the containers connect to it [starter kit README]. That is what we'll do. Set this in your .env:
OLLAMA_HOST=host.docker.internal:11434
Then start everything:
docker compose up
Open http://localhost:5678 to create your n8n account (once), and http://localhost:5678/home/workflows is where your workflows and agents live.
If you only want n8n without the rest of the kit, this single command works too [n8n docs]:
docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n
On the Mac side (from part two, condensed):
brew install ollama
ollama pull gemma4 # download a model
ollama run gemma4 # chat with it in the terminal
ollama list # see all downloaded models
Ollama serves an API at http://localhost:11434, and that address is what n8n will call. Not sure this model fits your machine or your task? Part two covers how to check with the VRAM calculator and when a task belongs on a local model versus a cloud one.
Now the fun part. In n8n, Ollama appears as a model node you can plug into chats and agents.
Step 1: create the credential. In n8n go to Credentials, create an "Ollama" credential, and set the base URL. Because n8n runs inside Docker and Ollama runs on your Mac, localhost will not work from inside the container. Use this instead [n8n docs]:
http://host.docker.internal:11434
The starter kit already includes a "Local Ollama service" credential. Edit it and set the same base URL [starter kit README]. No API key is needed, your local Ollama has no authentication.
Step 2: use it in a chat. Create a workflow, add a Chat Trigger node, then an AI Agent (or Basic LLM Chain) node. In its model slot pick "Ollama Chat Model", select your credential, and choose gemma4 from the model dropdown. Hit the Chat button at the bottom of the canvas and you are talking to your local model inside n8n [Ollama docs].
Step 3: give the agent tools. The AI Agent node accepts tool sub-nodes (HTTP Request, Gmail, a Qdrant vector store, another workflow). The model decides when to call them. This only works well if the model supports tool use, which llama3.1 does. Check the model's page on ollama.com for the "tools" tag before relying on it.
If the connection refuses, the base URL is almost always the culprit. The rule: n8n in Docker and Ollama on the host means host.docker.internal, both in the same compose network means the service name (http://ollama:11434), n8n installed natively means plain localhost [n8n docs].
You may have seen https://ollama.com/settings/keys and wondered if you missed a step. You did not. Those keys are for Ollama's cloud, where ollama.com hosts large models and acts as a remote Ollama server [Ollama docs]. If you ever want to call a cloud model (for example when a task needs more power than your Mac has), you create a key there and add it to the n8n Ollama credential with the base URL https://ollama.com. For everything local, no key, no account.
That is a complete private AI stack: n8n orchestrating, Ollama serving the model, and your data staying on your machine. Next I want to build a real workflow on top of this, a document assistant using the Qdrant vector store that came with the kit. See you there :).
Sources: Docker: get Docker, n8n Self-hosted AI Starter Kit docs, starter kit README, n8n Docker install, n8n Ollama credentials, n8n Ollama common issues, Ollama n8n integration, Ollama cloud, LLM VRAM Calculator.