n8n offers native AI nodes that enable direct integration with large language models — without writing a single line of code. In this lesson, you'll learn how to integrate OpenAI, Anthropic, and Ollama into your workflows.
| Node | Function | Provider |
|---|---|---|
| AI Agent | Autonomous agent with tool use | OpenAI, Anthropic |
| Basic LLM Chain | Simple LLM call with prompt | All providers |
| Summarization Chain | Automatic text summarization | All providers |
| Information Extractor | Extract structured data from text | All providers |
| Text Classifier | Categorize text | All providers |
| Sentiment Analysis | Detect sentiment | All providers |
| Embeddings | Generate vector representations | OpenAI, Ollama |
For maximum data control: Ollama runs locally without API costs.
# Install Ollama and pull model
ollama pull llama3.1
ollama pull nomic-embed-text
In n8n: Set base URL to http://ollama:11434 (Docker network) or http://host.docker.internal:11434 (local installation).
Practical tip: Never store API keys in workflow data. Use n8n's credential management exclusively — keys are stored encrypted with the
N8N_ENCRYPTION_KEY.
AI nodes support dynamic prompts with expressions:
You are an experienced analyst. Analyze the following customer message:
Message: {{ $json.message }}
Customer: {{ $json.customer_name }}
Product: {{ $json.product }}
Respond in JSON format with these fields:
- sentiment: "positive", "neutral", or "negative"
- category: Main category of the inquiry
- priority: "high", "medium", or "low"
- summary: Summary in one sentence
Use the Output Parser (sub-node) to get the LLM result as structured JSON:
{
"sentiment": "positive",
"category": "Product question",
"priority": "medium",
"summary": "Customer asks about availability of the premium plan."
}
Define a JSON schema so n8n automatically validates the response. Malformed responses are caught and can be re-requested.
Practical tip: Test prompts in the provider's playground first before building them into n8n. This way you iterate faster and save API costs during development.