Intermediate

AI Nodes & Agents in n8n

n8n's AI layer is built on LangChain under the hood, but exposed through its visual node editor. You connect an AI Agent node to LLM nodes, memory nodes, and tool nodes — and get a full reasoning agent without writing code.

The Four Components

1
AI Agent Node

The orchestrator. Receives the user prompt, plans steps, decides which tools to call, and produces the final output. Uses ReAct or OpenAI Functions reasoning loop.

2
LLM Sub-node

The brain. Connects the agent to a language model — OpenAI, Anthropic, Google Gemini, Mistral, Ollama (local), or any OpenAI-compatible endpoint.

3
Memory Sub-node

Keeps conversation history or context between runs. Options: Window Buffer Memory (last N messages), Redis Memory (persistent), Postgres Memory.

4
Tool Sub-nodes

What the agent can do. Any n8n integration becomes a tool: HTTP request, database query, email send, Slack message, calculator, code executor, web scraper.

LLM Sub-nodes — Supported Providers

ProviderModelsNotes
OpenAIGPT-4o, GPT-4.1, o3, o4-miniNative node — most feature-complete
AnthropicClaude Sonnet 4.5, Haiku 4.5, Opus 4Native node — good for long documents
GoogleGemini 2.5 Pro, FlashNative node — multimodal support
Mistral AILarge 3, Small 4, CodestralVia Mistral node or HTTP request
OllamaAny local model (Llama 4, DeepSeek-R1, etc.)Local — data stays on your machine. See /ollama section for setup.
Hugging FaceAny inference endpointVia HF Inference API node
OpenAI-compatAny provider with /v1/ endpointGeneric via OpenAI node + custom base URL

Tool Nodes — What Agents Can Do

Tools are what make an AI agent useful beyond text generation. In n8n, most nodes can be converted into tools for an agent. Some come pre-built as dedicated tool nodes:

HTTP Request Tool
Call any REST API as a tool. The agent describes what it needs, the node makes the HTTP call, and returns the result.
Code Tool
Execute JavaScript or Python code. The agent writes code to solve a problem, n8n runs it, and returns the output.
Think Tool
Lets the agent write intermediate reasoning steps before acting — improves accuracy on complex tasks.
Wikipedia Tool
Fetch Wikipedia summaries on demand — useful for agents that need factual grounding.
Calculator Tool
Arithmetic the agent can't reliably do in its head — delegates computation to a reliable function.
Custom n8n Workflow
Call any other n8n workflow as a tool — composable agents. A research sub-agent called by a main agent.

Memory Nodes

Window Buffer
Keeps the last N messages in memory. Simple, no external dependency. Resets when the workflow stops. Good for single-session chatbots.
Redis Memory
Stores conversation history in Redis by session ID. Persists across workflow runs. Good for multi-turn chat apps where users return.
Postgres Memory
Stores history in a PostgreSQL table. Best for production deployments where you want full control over the data and query history.

Example: Customer Support Agent

A realistic n8n AI agent for customer support:

  1. Trigger: Webhook receives incoming customer email
  2. AI Agent node with GPT-4o, Window Buffer Memory, and three tools:
    • HTTP Request Tool → query your order management API
    • HTTP Request Tool → search your knowledge base
    • Code Tool → calculate refund amounts from order data
  3. If node: Route based on agent's output (refund / escalate / auto-reply)
  4. Gmail node: Send the response
  5. Slack node: Notify the support team if escalated

This whole agent takes about 20 minutes to build in n8n's visual editor, no code required. The equivalent in Python with LangChain would be 200+ lines.

Checklist: Do You Understand This?

  • Can you name the four components every n8n AI agent needs?
  • Do you know how to connect Ollama as the LLM for a local, private n8n agent?
  • Can you explain the difference between Window Buffer and Redis Memory?
  • Do you understand how a custom n8n workflow becomes a tool for another agent?

Page built: 01 Jun 2026