Claude + n8n: How to Build AI Workflows for VPS
Connect Claude to n8n for 3 VPS workflows: webhook summaries, scheduled feed-to-spreadsheet rows, and an AI Agent with HTTP API calls, plus costs and errors.
Wetin you dey build
Three working AI workflows for the n8n instance wey you already dey run: one webhook wey dey summarize anything wey you send give am, one scheduled feed-reader wey dey turn articles into structured spreadsheet rows, and one AI Agent wey dey call HTTP API by itself to answer questions. This na the no-code version of calling Claude API from Python for your VPS, same API, same tokens, same bill, but orchestration dey happen for n8n nodes instead of script.
I assume say n8n don already dey run behind HTTPS according to the self-hosted n8n on Docker guide. If e never dey run, do that one first. Webhooks need real TLS endpoint, and the credential store wey you wan put API key inside needs the encryption-key backup wey that guide dey remind you about.
The main problems for here no be drag-and-drop. Na model selection for each node, prompt fields wey dey silently interpolate undefined, and the fact say automation dey run without person watching am. Workflow wey costs half a cent per run cheap until retry loop runs am four thousand times overnight. Most of this guide dey focus on those issues.
Credential wey you encrypt with the key wey you back up
Get API key from Anthropic Console for platform.claude.com. Go Settings, then API Keys, then create key with name like n8n-vps. E go show only once. Fund the account or set up billing. API usage na pay-per-token, and e separate completely from any Claude.ai subscription.
For n8n: go Credentials, Create credential, choose Anthropic, paste the key inside API Key field, then save. Every Claude node for every workflow go use this one stored credential. You no need paste the key inside any node.
Operational note two dey important.
First, n8n dey use N8N_ENCRYPTION_KEY to encrypt credentials wey e store. If you set that env var by yourself for your compose file according to the n8n guide, your credential go survive container rebuilds. But if you allow n8n generate one and later lose the volume, every stored credential, including this key, go become ciphertext wey nobody fit recover. Back up the key now if you never do am.
Second, treat the n8n credential store as the blast radius. Anybody wey fit edit workflows for your instance fit use your Anthropic key make requests. Community edition no get per-user permissions for credentials. So, if other people dey log into this instance, read which access controls dey behind paid n8n licence before you give dem accounts. Set a spend limit for Console under Settings, so a breached or runaway instance get a maximum limit.
Model choice na per-node decision
The model dropdown for n8n Claude nodes dey come live from the API, so e dey show wetin your key fit access. As of July 2026, the available models and API price per million input/output tokens be: Claude Haiku 4.5 (claude-haiku-4-5) at $1/$5 with 200K context window, Claude Sonnet 5 (claude-sonnet-5) at $3/$15, introductory price na $2/$10 until August 31, 2026, and Claude Opus 4.8 (claude-opus-4-8) at $5/$25, with both of dem get 1M-token context windows. Claude Fable 5 (claude-fable-5) dey also available at $10/$50 for the hardest reasoning work; nothing for this guide need am. Use those exact IDs. A date-suffixed variant wey you remember from old tutorial go 404. Prices dey change, so check platform.claude.com before you trust any number wey you read anywhere, including here.
The habit wey you need build be this: choose the model per node, no be per platform. Classification, extraction, summarization, and routing — the main everyday work for automation — dey run well on Haiku at one-third of Sonnet list price and one-fifth of Opus price. Keep Sonnet for agents and multi-step reasoning. Use Opus for the rare workflow where wrong answer cost pass the token price. Workflow wey get five Claude nodes fit and suppose mix different models.
Claude node dem wey exist, and which one to use for where
n8n get two different Anthropic integrations, and choosing the wrong one na the commonest beginner mistake.
The Anthropic node na normal app node: one request enter, one response comot. E Text resource get Message a Model operation, plus operations for analyzing images and documents. Use am whenever workflow logic dey inside n8n: trigger, Claude call, next node. Workflows 1 and 2 below use am or the chain equivalent.
The Anthropic Chat Model node na sub-node, wey be small attachment wey supplies model to root node like AI Agent or Basic LLM Chain. E no get trigger and e no get output of im own; e exposes model picker plus sampling options like Maximum Number of Tokens and Sampling Temperature. One important caveat from n8n docs wey you suppose memorize: expressions inside sub-nodes always resolve against the first input item, no be each item. Put per-item expressions for the root node prompt fields, no be inside the sub-node.
Workflow 1: webhook go in, summary come out
The hello-world of AI automation be say anything wey POST to URL, e go get summary and land for Slack or your inbox.
- Webhook node, HTTP Method POST, path
summarize. n8n go give you test URL and production URL; the production one go only listen when workflow dey active. - Anthropic node, Message a Model, model
claude-haiku-4-5, Max Tokens around 300. - Slack node (or Send Email), post the response text to channel.
Na prompt be where n8n expressions meet Claude. POST body dey under $json.body, so user message field go look like:
Summarize the following feedback in three bullets, then one line:
verdict: praise | complaint | churn-risk. No preamble.
{{ $json.body.text }}Put role and format instructions for node system prompt field, no be user message. System prompt dey constant while payload dey change. This one keep behaviour stable and make prompt easy to understand six months from now. Test am from the VPS itself:
curl -X POST https://n8n.example.com/webhook/summarize \
-H 'Content-Type: application/json' \
-d '{"text": "Third support ticket this month about slow disk IO..."}'Cost for each run with Haiku: 1,200-token payload plus prompt na about $0.0012 in, while 300 tokens out na $0.0015, roughly one quarter of one cent. One thousand runs for one month go cost under $3. The same node wey point to Opus 4.8 na about five times this amount. This ratio, multiplied by every workflow wey you build, na why per-node model habit matter.
Workflow 2: scheduled RSS to structured rows
Now we go do something wey follow clock, with structured output: read RSS feed every hour, classify each item, then append rows to sheet.
- Schedule Trigger, every hour.
- RSS Read, the feed URL. E go output one item for each article.
- Basic LLM Chain, with an Anthropic Chat Model sub-node wey set to
claude-haiku-4-5, and a Structured Output Parser sub-node wey get JSON schema. - Google Sheets (or Postgres), append one row for each item.
Na the Structured Output Parser dey turn "Claude, please return JSON" from mere hope into contract: e validate the model reply against your schema, and e make the item fail clearly instead of writing bad rows. Schema fit look like this:
{
"type": "object",
"properties": {
"category": { "type": "string", "enum": ["release", "security", "tutorial", "other"] },
"relevance": { "type": "number" },
"one_line_summary": { "type": "string" }
},
"required": ["category", "relevance", "one_line_summary"]
}The chain prompt dey reference the feed item:
Classify this article for a VPS hosting audience.
Title: {{ $json.title }}
Content: {{ $json.contentSnippet }}Cost calculation dey different here: na each item dey incur cost, no be each run. Fifty articles every hour, twenty-four hours every day, na 36,000 Claude calls every month. For Haiku, e fit cost around $40–90 depending on article length. For Opus, e fit cost about five times that. Remove duplicates before the LLM node (use simple IF against links wey you don see before, or n8n's Remove Duplicates node). This go reduce the number because most hourly polls no get anything new. The cheapest token na the call wey you no make.
Workflow 3: AI Agent wey dey use tools
The first two workflows na pipelines; na you dey decide the steps. An AI Agent node turn this arrangement around: you give Claude one goal and some tools, then e decide which tools to call, the order to call dem, and when e don finish. n8n need one chat model sub-node and at least one tool sub-node wey you attach.
One practical build na ops assistant wey dey answer “wetin dey down and why” from your monitoring:
- Chat Trigger (or webhook), na here the question dey enter.
- AI Agent, with an Anthropic Chat Model sub-node set to
claude-sonnet-5. Agents dey plan and chain tool calls; Haiku fit drive simple single-tool agents, but Sonnet na the sensible minimum once tools plenty. - HTTP Request node wey you attach as a tool, and point am to your Uptime Kuma status API or Zabbix endpoint. Another HTTP tool fit call anything else wey get REST API.
Two settings dey do most of the work. The agent System Message dey define the job: “You be ops assistant. Use the status tool check the current monitor state before you answer. Report only monitors wey dey down, with duration.” The description of each tool no be documentation for humans; na how Claude dey decide when to call the tool. “Returns current up/down state for all monitored services as JSON” go make am call the tool at the correct time; “status API” fit make am ignore or misuse the tool. When you attach the HTTP Request node as a tool, enable Optimize Response and select the JSON fields wey matter. If you no do this, every verbose API response go enter the model context as input tokens wey you dey pay for.
Set Max Iterations for the agent (the default na 10) to the smallest number wey work. Na this setting dey separate “the agent give up after 4 tool calls” from a loop of about twelve model round-trips. Also understand how billing dey work: every iteration dey send the full conversation again, including the system message, question, every previous tool result, as input tokens. One six-iteration agent run fit easily reach 20,000 cumulative input tokens and 2,000 output tokens: for Sonnet 5 introductory pricing, na about $0.06; for the standard $3/$15 pricing, roughly $0.09. You fit count am as twenty times the cost of one simple summarization run. If you notice say you dey add many tools to one agent, na that point to run MCP servers for your VPS go become the cleaner architecture.
Cost guardrails, because nobody dey watch am
Workflow wey nobody dey supervise needs the controls wey human for keyboard dey provide without thinking. Four layers, start with the cheapest one.
Max Tokens for every Claude node. Na hard limit for output size. Summarizer need 300, classifier need 100. This one limit the expensive part of the bill ($5–$25 per million output tokens versus $1–$5 for input), and e also stop runaway output. If prompt bug make Claude talk too much, e go cost 300 tokens, no be 8,000.
Model for each node. We don cover this above; e fit change price by five to ten times across the current lineup, and e dey take ten seconds to set.
Put limit for the loops. Set Max Iterations for agents. Set workflow timeout inside the workflow settings so execution wey hang go stop instead of continuing forever. Also take care with per-node Retry On Fail: na correct tool for temporary errors, but retries dey multiply cost. Max Tries of 3 with Wait Between Tries of 5000 ms means persistent failure fit bill you up to three times for each item before e give up. Never put retry around node wey don already succeed after expensive work.
Use error workflow as final backup. Create workflow wey start with the Error Trigger node. Make e post the failed workflow name and error to Slack. Then set am as the Error Workflow for each AI workflow inside the workflow settings. The serious failure wey this catches na schedule-triggered workflow wey dey error for every run, every hour, for one week, with each run using tokens before e stop. Combine am with monthly spend limit for Anthropic Console. Check the Console usage page during the first few days after you activate any scheduled workflow. If you want understand exactly wetin you dey pay for, this guide for token usage explain am well.
Failure mode, wit di strings wey you go see
Di node fail immediately wit "Authorization failed - please check your credentials." Di API return 401. Di body wey dey underneath na:
{"type": "error", "error": {"type": "authentication_error", "message": "invalid x-api-key"}}You fit don paste key wrongly, key fit cut short, trailing whitespace fit dey, or you fit use placeholder from tutorial. Create the n8n credential again and paste am again. If e work yesterday, check whether dem revoke the key for Console, or whether volume restore take return credential wey dem encrypt wit different N8N_ENCRYPTION_KEY.
Executions fail in bursts wit 429 rate_limit_error, and message fit be like "Number of request tokens has exceeded your per-minute rate limit." Rate limits dey use per-minute buckets. n8n make am very easy to fire fifty webhook or RSS executions at the same time. Fix am from the structure: process items one after another with Loop Over Items instead of parallel processing. Set Retry On Fail with Max Tries 3 and Wait Between Tries for the maximum 5000 ms. n8n no allow that field pass 5000 ms. When you need longer backoff so retries go enter the next minute window, put Wait node for the error path or process items one at a time. The response get retry-after header wey tell you exactly how long to wait. n8n fixed wait no fit read am, so build the longer pause by yourself.
404 not_found_error when you name your model. The body repeat the typo:
{"type": "error", "error": {"type": "not_found_error", "message": "model: claude-haiku-4.5"}}You fit use dots instead of hyphens (4.5 for 4-5), date suffix from old blog post, or model wey dem retire. Correct the ID against the current list. This problem dey happen to people wey type inside the model field as expression instead of selecting from the dropdown.
Claude answer question wey you no ask. No error dey anywhere, and the run show green. n8n expression wey reference missing field, like {{ $json.body.text }} when the payload use message, go put the literal string undefined inside your prompt. Claude go still answer prompt wey no get real meaning. If the referenced node no execute at all, you go see "Referenced node is unavailable". But missing field dey fail silently. Before you activate am, always run once with real data and read the actual rendered prompt for the node input panel. The expression editor preview show the resolved value, and undefined dey there if you check well.
FAQ
How I fit connect Claude to n8n?
Create API key for Anthropic Console for platform.claude.com, then for n8n add credential wey get type Anthropic and paste am for API Key field. Every Claude node, the Anthropic app node and the Anthropic Chat Model sub-node, dey reference that stored credential. n8n dey encrypt am with N8N_ENCRYPTION_KEY, so back up that key, otherwise your credentials go lost with the volume.
How much AI workflow dey cost per run?
Estimate tokens per run, then multiply am by the model per-million prices. As of July 2026, Haiku 4.5 na $1/$5 per million input/output tokens, and Sonnet 5 na $3/$15 ($2/$10 introductory through August 2026). Webhook summarization for Haiku dey cost about quarter of a cent; agent run for Sonnet wey get several tool calls dey near $0.06–$0.10 because every iteration dey send the whole conversation again as input. Verify the run for the Console usage page instead of trusting estimates.
Which Claude model I suppose use for n8n automations?
Use Haiku 4.5 for classification, extraction, summarization, and routing, especially high-volume work wey speed and price matter pass. Use Sonnet 5 for AI Agent nodes and multi-step reasoning. Use Opus 4.8 only when wrong answer cost enough to justify the $5/$25 list price: five times Haiku and a little below twice Sonnet. Set the model per node, no be per workflow. One workflow fit mix all three.
How I fit stop n8n workflow from overspending for Claude API?
Put guardrails in layers: set low Max Tokens for every Claude node, set Max Iterations for agents, add workflow timeout, and use conservative Retry On Fail settings so failures no multiply token spending. Then add Error Trigger workflow wey go alert you for Slack whenever any AI workflow fail. Set monthly spend limit for Anthropic Console as the hard ceiling wey nothing for the VPS fit override.
AI Agent tool calls dey cost extra?
No separate tool fee dey, but tools no be free. Every tool result dey go back to the model as input tokens, and every agent iteration dey send the whole conversation so far again. Chatty API response wey you pass through without filtering fit become much bigger than your actual prompt. Enable Optimize Response for HTTP Request tools and return only the fields wey the agent need.