DEV Community

Pirate Prentice
Pirate Prentice

Posted on

n8n Anthropic Chat Model Node: Connect Claude to Your AI Agent Workflows [Free Workflow JSON]

What the Anthropic Chat Model node does

The Anthropic Chat Model node is a sub-node — it doesn't run on its own. Attach it to the Model input of an:

  • AI Agent node — gives the Agent Claude as its reasoning engine
  • Basic LLM Chain node — single prompt → response
  • Summarization Chain node — long-document summarisation
  • Question and Answer Chain node — RAG-style Q&A

The node handles the Anthropic API call, streaming, and token counting. You configure it once; the parent node calls it in a loop.


Configuration parameters

Parameter What it does
Credential Your Anthropic API key. Create a credential of type Anthropic API in n8n credentials manager.
Model Model ID: claude-opus-4-20250514, claude-sonnet-4-6, claude-haiku-4-5-20251001, or enter a custom ID for preview models.
Maximum Tokens Hard cap on response length. Default 1024. Set higher (4096–8192) for long outputs; lower for cost control.
Temperature 0 = deterministic, 1 = creative. Use 0–0.3 for structured/factual tasks; 0.7–1.0 for creative writing.
Top P Nucleus sampling. Leave at default (1) unless you have a specific reason to tune it alongside temperature.
Top K Limits vocabulary to the K most likely tokens. Claude default is fine for most cases.
Timeout Request timeout in milliseconds. Increase for long outputs or slow network.

Model selection guide

Use case Recommended model
Complex reasoning, multi-step agent tasks claude-opus-4-20250514
Balanced quality + cost, most production workflows claude-sonnet-4-6
Fast, high-volume, simple tasks (classification, extraction) claude-haiku-4-5-20251001
Latest preview features Enter the model ID from Anthropic's changelog

Cost tip: Haiku is ~15–20× cheaper than Opus per token. For high-volume workflows that classify or extract, default to Haiku and only step up when output quality requires it.


Gotchas & common errors

1. "Credential not found" after saving

Anthropic credentials are stored per n8n instance. If you import a workflow from another instance, the credential reference will be broken. Re-select the credential in the node settings after import.

2. Max Tokens too low = truncated responses

Default is 1024 tokens. Claude's responses for structured tasks (JSON, long summaries, code) often exceed this. Set Maximum Tokens to at least 2048–4096 for agent workflows; truncated JSON breaks downstream nodes.

3. Tool use requires a capable model

Claude's native tool calling (used by n8n's AI Agent node) requires claude-3+ models. Haiku 3 and above support tools; older model IDs do not. If the Agent stops after one step with a parsing error, check the model version.

4. Temperature 0 is not perfectly deterministic

Claude's sampling has a small inherent randomness floor even at temperature 0. For truly reproducible outputs, add explicit formatting instructions in the system prompt rather than relying on temperature alone.

5. Streaming vs. batch in n8n

n8n's Anthropic node uses the Anthropic streaming API internally but buffers the full response before handing it to the parent node. You won't see token-by-token output in the execution log — only the completed response. This is fine for automation workflows; streaming is only relevant if you're building real-time chat UIs.

6. Context window limits

Claude Sonnet 4.6 and Opus 4 have 200K token context windows. For most automation tasks this is far more than enough. The limit that matters in practice is Maximum Tokens on the output side, not the input window.


3 workflow patterns

Pattern 1: Document summarisation pipeline

Google Drive Trigger (new file uploaded)
→ HTTP Request (download file content)
→ Basic LLM Chain
  ├─ Anthropic Chat Model (claude-haiku-4-5, temp 0, max_tokens 512)
  └─ System: "Summarise the following document in 3 bullet points. Be concise."
→ Gmail / Slack (send summary to stakeholder)
Enter fullscreen mode Exit fullscreen mode

Use case: Auto-summarise every new document dropped into a shared Drive folder.

Pattern 2: Structured data extraction agent

Webhook (POST with raw text payload)
→ AI Agent (Tools Agent)
  ├─ Anthropic Chat Model (claude-sonnet-4-6, temp 0, max_tokens 2048)
  ├─ Output Parser (Structured Output Parser — define schema)
  └─ System: "Extract the following fields from the text: name, company, email, phone, request_type. Return valid JSON only."
→ Airtable / HubSpot (create/update record)
→ Webhook Response (200 OK + extracted JSON)
Enter fullscreen mode Exit fullscreen mode

Use case: Parse unstructured contact form submissions into CRM records without manual data entry.

Pattern 3: Code review assistant

Webhook Trigger (GitHub PR webhook)
→ HTTP Request (fetch PR diff from GitHub API)
→ Basic LLM Chain
  ├─ Anthropic Chat Model (claude-opus-4, temp 0.2, max_tokens 4096)
  └─ System: "You are a senior software engineer reviewing a pull request. Review the diff for: (1) correctness bugs, (2) security issues, (3) performance problems. Be specific — cite line numbers. Output Markdown."
→ HTTP Request (POST comment to GitHub PR via API)
Enter fullscreen mode Exit fullscreen mode

Use case: Automated first-pass code review on every PR, before a human reviewer.


Free workflow JSON

Document summarisation pipeline:

{
  "name": "Anthropic Doc Summariser",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "summarise",
        "responseMode": "responseNode",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [240, 300]
    },
    {
      "parameters": {
        "prompt": "={{ $json.body.text }}",
        "options": {}
      },
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [460, 300]
    },
    {
      "parameters": {
        "model": "claude-haiku-4-5-20251001",
        "options": {
          "maxTokensToSample": 512,
          "temperature": 0
        }
      },
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [460, 480]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { summary: $json.response } }}",
        "options": {}
      },
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "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 }]]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [[{ "node": "Basic LLM Chain", "type": "ai_languageModel", "index": 0 }]]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Import via Settings → Import from URL/Clipboard. Add your Anthropic credential to the Chat Model node before activating. Send a POST request to the webhook URL with { "text": "your document here" }.


Next steps

Which Claude model are you using in your n8n workflows — and for what task? Drop your setup in the comments.

Top comments (1)

Collapse
 
pirateprentice profile image
Pirate Prentice

Which Claude model are you using in n8n — Haiku for high-volume extraction, Sonnet for balanced agent tasks, or Opus for complex reasoning? Drop your workflow pattern in the comments.