n8n Basic LLM Chain Node: Add Language Model Text Generation to Any Workflow [Free Workflow JSON]
tags: n8n, automation, ai, javascript
The n8n Basic LLM Chain node is the simplest way to add language model text generation to an n8n workflow. You wire it to any Chat Model node (OpenAI, Anthropic, Google, Ollama, etc.), pass it a prompt, and get a text response back — no agent loop, no tool calls, no memory overhead.
This guide covers every configuration option, the gotchas that catch people out, three production-ready patterns, and a free workflow JSON you can import today.
What the Basic LLM Chain node does
The Basic LLM Chain is a LangChain wrapper that executes a single prompt → response cycle:
- Takes one or more input items (text, data fields, whatever your workflow has produced)
- Builds a prompt from a template you define (with access to all input fields via
{{ $json.fieldName }}) - Sends it to a connected Chat Model sub-node
- Returns the model's text response as
{ "text": "..." }on each output item
It does not loop, call tools, use memory, or reason across steps. For those, use the AI Agent node. The Basic LLM Chain is for single-shot generation: summarise, classify, extract, rewrite, translate, score.
Node anatomy
Required sub-node: Chat Model
The Basic LLM Chain has no built-in model. You must attach a Chat Model node as a child:
- OpenAI Chat Model — GPT-4o, GPT-4o-mini, etc.
- Anthropic Chat Model — claude-opus-4, claude-sonnet-4-6, claude-haiku-4-5
- Google Gemini Chat Model — gemini-2.5-flash, gemini-2.5-pro
- Ollama Chat Model — local models (llama3, mistral, etc.)
- Azure OpenAI Chat Model — enterprise Azure deployments
- Mistral Cloud Chat Model, Cohere, Groq, and others
Drag the Chat Model node onto the canvas, then connect it to the Basic LLM Chain's AI Language Model input (the purple connector).
Optional sub-node: Output Parser
By default, the chain returns raw text in { "text": "..." }. If you need structured output (JSON, a list, a specific schema), attach an Output Parser:
- Structured Output Parser — define a Zod/JSON schema; the model is instructed to return JSON matching it
- Auto-fixing Output Parser — wraps another parser; if the model returns malformed JSON it sends a correction prompt automatically
- List Output Parser — returns a simple array of strings
- Item List Output Parser — splits a comma/newline-separated list into individual items
- Bytes Output Parser — returns raw bytes (rare)
Prompt template
The main configuration field is the Prompt (or User Message if using a chat-style template). This is a Mustache/Handlebars-style template with access to the current item's fields:
Summarise the following support ticket in one sentence. Be concise.
Ticket subject: {{ $json.subject }}
Ticket body: {{ $json.body }}
n8n evaluates {{ $json.fieldName }} at runtime for each item, so one chain node handles batches automatically.
System message
An optional System Message field sets the model's persona/instructions. Keep it short and direct:
You are a helpful assistant. Respond only in plain text with no markdown formatting.
Temperature and other model params
Temperature, max tokens, top-p, and stop sequences are configured on the Chat Model sub-node, not on the Basic LLM Chain itself. Adjust them there.
Gotchas
1. You must wire a Chat Model — the node won't run without one
The Basic LLM Chain has no fallback model. If the AI Language Model input is unwired, execution fails immediately. Always connect a Chat Model sub-node first.
2. {{ $json }} in prompts — not {{ $item.json }}
Inside the Prompt field, n8n uses Mustache syntax. The correct reference is {{ $json.fieldName }}, not the expression syntax {{ $item.json.fieldName }} used in other node fields. Using expression syntax here produces literal text, not the value.
3. Output is always { "text": "..." } unless you attach an Output Parser
Downstream nodes expecting a field like summary or category won't find it. Either attach an Output Parser, or add a Set node after the chain to rename text to your preferred field name.
4. One LLM call per input item
The Basic LLM Chain runs once per input item. If your upstream node produces 500 items, you'll make 500 model calls. For large batches, add a Split In Batches node upstream and respect rate limits on the model sub-node.
5. Context window limits
If you're passing long documents into the prompt, watch token counts. The chain doesn't chunk automatically. For long-document summarisation, use the Summarization Chain node instead — it handles chunking and map-reduce strategies.
6. The chain returns a new item, not a merged item
The output item contains only { "text": "..." } (or your parsed output). Input fields are not automatically carried forward. Use a Merge node to join the chain's output back to the original item if you need both.
Three production-ready patterns
Pattern 1: Support ticket classifier
Classify incoming support tickets by category and urgency so they can be routed without human triage.
Workflow:
Webhook Trigger → Basic LLM Chain (+ OpenAI Chat Model + Structured Output Parser) → Switch node → Slack/email routing
Prompt:
Classify this support ticket.
Subject: {{ $json.subject }}
Body: {{ $json.body }}
Return JSON with:
- category: one of ["billing", "technical", "account", "general"]
- urgency: one of ["low", "medium", "high"]
- one_line_summary: string (max 15 words)
Structured Output Parser schema:
{
"category": "string",
"urgency": "string",
"one_line_summary": "string"
}
Downstream: Switch node routes on urgency → Slack alert for "high", Zendesk ticket for "medium"/"low".
Pattern 2: Blog post meta generator
Given a draft blog post body, generate SEO title, meta description, and 5 tags automatically before publishing.
Workflow:
Google Drive Trigger (new file) → Google Drive node (read content) → Basic LLM Chain (+ Anthropic Chat Model + Structured Output Parser) → Google Sheets node (write metadata row) → Notify
Prompt:
You are an SEO copywriter. Given the blog post below, generate:
- An SEO title (max 60 characters, front-load the main keyword)
- A meta description (max 155 characters, include a call to action)
- Five relevant tags (lowercase, hyphenated)
Blog post:
{{ $json.content }}
Structured Output Parser schema:
{
"seo_title": "string",
"meta_description": "string",
"tags": ["string"]
}
This pattern runs zero-cost on haiku/flash for short posts; reserve Sonnet/GPT-4o for posts where quality matters most.
Pattern 3: Customer review sentiment + response draft
Process incoming product reviews: extract sentiment, key themes, and draft a personalised response — ready for a human to approve before sending.
Workflow:
Schedule Trigger → HTTP Request (fetch reviews from API) → Split Out (one item per review) → Basic LLM Chain (+ Claude Haiku + Structured Output Parser) → Google Sheets append → Slack digest
Prompt:
Analyse this product review and draft a response.
Review ({{ $json.rating }} stars):
{{ $json.review_text }}
Product: {{ $json.product_name }}
Return:
- sentiment: "positive" | "neutral" | "negative"
- themes: array of up to 3 key themes mentioned
- response_draft: a polite, personalised 2-3 sentence response from the brand
The response draft goes into Sheets; a Slack digest shows the day's reviews with one-click links to approve/edit responses. The human touches only the outliers.
Free workflow JSON
Import this into n8n (Workflows → Import from clipboard) to get a working Basic LLM Chain skeleton with a Webhook trigger, chain, and Structured Output Parser wired up:
{
"name": "Basic LLM Chain — Starter",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "llm-chain",
"responseMode": "responseNode"
},
"id": "webhook-1",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [240, 300]
},
{
"parameters": {
"prompt": "={{ $json.prompt }}",
"options": {}
},
"id": "llm-chain-1",
"name": "Basic LLM Chain",
"type": "@n8n/n8n-nodes-langchain.chainLlm",
"typeVersion": 1.4,
"position": [460, 300]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ { \"result\": $json.text } }}"
},
"id": "respond-1",
"name": "Respond to Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [680, 300]
}
],
"connections": {
"Webhook": {
"main": [[{"node": "Basic LLM Chain", "type": "main", "index": 0}]]
},
"Basic LLM Chain": {
"main": [[{"node": "Respond to Webhook", "type": "main", "index": 0}]]
}
}
}
Note: After importing, add your Chat Model sub-node (e.g. OpenAI Chat Model) connected to the Basic LLM Chain's AI Language Model input. The workflow won't run without it.
When to use Basic LLM Chain vs AI Agent
| Use case | Basic LLM Chain | AI Agent |
|---|---|---|
| Single prompt → text response | ✅ | overkill |
| Classify / summarise / extract | ✅ | overkill |
| Structured JSON output | ✅ (+ Output Parser) | ✅ |
| Multi-step reasoning | ❌ | ✅ |
| Tool calls (web search, APIs) | ❌ | ✅ |
| Conversation memory | ❌ | ✅ |
| Cheaper / faster | ✅ | ❌ |
Rule of thumb: if you can write the task as a single prompt, use the Basic LLM Chain. If the task requires the model to decide what to do next, use an AI Agent.
Quick-start checklist
- [ ] Add a Chat Model sub-node and connect it to the Basic LLM Chain's purple input
- [ ] Write your prompt using
{{ $json.fieldName }}for dynamic values - Add an Output Parser sub-node for structured output
- [ ] Add a Set node downstream if you need to rename
textto a specific field - [ ] Test with a single item before running on large batches
- [ ] Set temperature and max tokens on the Chat Model sub-node
The Basic LLM Chain is n8n's workhorse for single-shot AI tasks. Wire it once, feed it your data, and every item in your workflow gets an LLM pass — classification, summarisation, extraction, drafting — without touching the agent complexity. Start here, move to the AI Agent only when you genuinely need it.
Top comments (0)