Loader

n8n AI Agent Workflow: Using OpenAI or Ollama on Your Own Server

n8n can run AI agents that read data, call tools and take action. Learn how the pieces fit and what server each option needs.

  • OpenAI or local Ollama
  • Agent, memory and tools
  • Server and GPU sizing
n8n AI Agent Workflow: Using OpenAI or Ollama on Your Own Server
  • 26 October 2026
  • by Admin

n8n AI Agent Workflow: Using OpenAI or Ollama on Your Own Server

n8n has AI nodes that let a workflow use a language model to decide what to do. An agent can read an email, search your data, call other nodes as tools and return an answer or take an action. You can use a hosted model such as OpenAI, or run an open model locally with a tool like Ollama.

The main building blocks

  • AI Agent node. The brain that plans and calls tools.
  • Chat model. Connect an OpenAI, other hosted model, or an Ollama model node.
  • Memory. Keeps the recent conversation so the agent has context.
  • Tools. Other n8n nodes the agent may call, such as HTTP Request, a database, Google Sheets or a workflow.

Option 1: hosted model (OpenAI and others)

You add an API key as a credential, and n8n sends prompts to the provider. The model runs on their hardware, so your n8n server can stay small. You pay per use to the provider, and your prompts leave your server. Good for getting started quickly.

Option 2: local model with Ollama

Ollama runs open models on your own machine, and n8n connects to it through the Ollama node. Your prompts stay on your infrastructure and you pay no per-token fee. The cost is hardware: models need RAM, and larger models need a GPU with enough memory to run well.

Model sizeWhat you need (rough guide)Notes
Small (about 3B to 8B parameters)16 GB+ RAM, or a GPU with 6 to 8 GB VRAMFine for classification and short answers. Slower on CPU only.
Medium (about 13B to 14B)GPU with about 16 GB VRAMBetter reasoning for tools and summaries.
Large (30B and above)GPU with 24 GB+ VRAM or moreNeeds a powerful GPU server.

These sizes are rough. Check the model's own requirements. See our GPU dedicated servers and GPU RDP plans for graphics-card options, and ask support before buying if you plan to run a large model.

A simple agent workflow

  • Trigger: a chat message, an email or a webhook.
  • AI Agent node with a clear system prompt that explains its job and limits.
  • Attach a chat model and short memory.
  • Add two or three tools, for example search your knowledge base and create a ticket.
  • Return the answer or send it to Slack or email.

Keep agents safe

  • Give the agent only the tools it needs.
  • Do not let it delete data or send money without a human approval step.
  • Treat incoming text as untrusted. Prompt injection is real, so validate the actions the agent proposes.
  • Log executions and review them.
  • Follow our n8n security checklist for the server itself.

Where to run it

n8n itself runs well on a small Linux VPS. If you add a local model, plan a separate machine with enough RAM or a GPU. See which VPS plan fits your n8n workload, and 10 workflows to start with.

Host n8n on a managed server, and connect it to OpenAI or your own GPU server.

See Managed n8n Plans

Frequently asked questions

  • Can n8n run AI agents?
    Yes. n8n has an AI Agent node that works with chat models, memory and tools.
  • Do I need a GPU to use Ollama with n8n?
    Small models can run on CPU but slowly. A GPU with enough memory makes local models much faster.
  • Is OpenAI or Ollama better?
    OpenAI is quick to start and needs no GPU. Ollama keeps data on your server and avoids per-token fees but needs stronger hardware.