
Natasha Anello
Head of Marketing at Coderhouse
Artificial Intelligence
How to Integrate n8n with AI Models Like ChatGPT or Claude
Publicado el
Integrating n8n with artificial intelligence models like ChatGPT (OpenAI) or Claude (Anthropic) lets you go from “mechanical” automations to smart flows that understand context, write texts, classify information and respond on your behalf. In this guide, you'll see how to connect them step by step, with examples ready to adapt.
Why add AI to your flows in n8n?
Text interpretation: turning emails or reviews into actionable summaries.
Content generation: responses, descriptions, copy or FAQs on demand.
Classification and extraction: tags, intent, sentiment, key entities.
End-to-end automation: receive, understand, decide and act in the same workflow.
Before you start
Create an account at n8n.io (cloud) or install it locally.
Have a data source handy: Gmail, Google Sheets, Notion, Webhook, etc.
Integrate ChatGPT (OpenAI) with n8n — step by step
In n8n, create a New Workflow and add a Trigger (e.g., Webhook or Gmail Trigger).
Add an HTTP Request node:
Method: POST
URL:
https://api.openai.com/v1/chat/completionsHeaders:
Authorization: Bearer {{ $env.OPENAI_API_KEY }}Content-Type: application/json
Body (JSON):
{ "model": "gpt-4-turbo", "messages": [ { "role": "system", "content": "You are a brief and clear assistant." }, { "role": "user", "content": "Summarize this text in 3 bullets: {{ $json.text }}" } ], "temperature": 0.4, "max_tokens": 300 }
Test with Execute Node. The text to summarize can come from the trigger (
{{ $json.text }}).Chain an output node (Notion, Slack, Gmail, Google Sheets) to save or send the result.
Integrate Claude (Anthropic) with n8n — step by step
Add an HTTP Request:
Method: POST
URL:
https://api.anthropic.com/v1/messagesHeaders:
x-api-key: {{ $env.ANTHROPIC_API_KEY }}anthropic-version: 2023-06-01content-type: application/json
Body (JSON):
{ "model": "claude-3-sonnet-20240229", "max_tokens": 350, "messages": [ { "role": "user", "content": "Classify the sentiment (positive/neutral/negative) of the following text and return JSON with {\"sentiment\",\"reason\"}: {{ $json.text }}" } ] }
Run the node and parse the response with Set or Code (if you need to transform the JSON).
4 smart flows ready to adapt
Automatic email service: Gmail Trigger → HTTP (ChatGPT) “respond with a friendly and brief tone” → Gmail Send.
Document summary: Google Drive Trigger → Extract Text → HTTP (Claude) “summarize in 3 bullets” → Notion Create Page.
Lead classification: Webhook (form) → HTTP (ChatGPT) “priority: high/medium/low” → Router (branches by priority) → Slack/CRM.
Review monitoring: Google Sheets Trigger → HTTP (Claude) “sentiment + topic” → weekly report in Google Docs.
Best practices and common mistakes
Clear context in the prompt: objective, output format, style and word limit.
Secure variables: store API Keys in Environment Variables (
$env), not in plain text.Cost control: use appropriate max_tokens and temperature; avoid overly long prompts.
Error handling: add error routes and retries for 429/5xx codes.
Output validation: request strict JSON and validate it before continuing in the flow.
AI + n8n: think in systems, not in “magic”
n8n executes and orchestrates; AI interprets and writes. The real value is in the system design: what triggers the flow, what data it receives, what it decides and how it publishes results. That's the difference between “trying” AI and using AI professionally.
Learn to build flows with support
If you want to master AI automations (n8n, Make, Flowise, AgentBuilder) with real projects and expert feedback, train at Coderhouse:
👉 AI Automation Course — build systems with n8n, Make, Flowise and agents.
👉 Introduction to Artificial Intelligence Course — understand the basics to design better prompts and flows.
👉 Prompt Generation Course — clear specifications, reliable results.
👉 AI Applied to Marketing Course — bring these flows to content, acquisition and support.
If you'd like to keep exploring this topic, you can also read how to learn artificial intelligence from scratch.
Recommended Coderhouse courses
If you want to understand and apply artificial intelligence in your work, Coderhouse has programs for all levels:
Introduction to Artificial Intelligence Course: to understand how AI models work and start applying them from scratch.
AI Automation Course: to automate workflows with tools like n8n and Make, without needing to code.
AI Engineering Course: for developers who want to integrate language models into real applications.
Frequently asked questions
Do I need to program to use n8n with AI?
No. You can do it 100% with visual nodes. Knowing JSON and APIs helps you scale, but it's not a requirement to start.
Can I use more than one model in the same flow?
Yes. For example, Claude for classification and ChatGPT for final writing, in separate branches with Router.
How do I handle costs and latency?
Limit max_tokens, cache repeated results and run heavy tasks during low-demand hours.
Can I validate that the AI returns correct JSON?
Ask “Return only valid JSON with the keys X, Y, Z” and use IF/Switch to check the structure before continuing.
Sources and references

Sobre el autor
Marketing Director with more than 10 years of experience leading teams, driving digital transformation and executing growth strategies. Solid track record in the Fintech and Startup ecosystem, with key roles at companies like Flybondi, Blockchain.com, Simplestate, SeSocio and Coderhouse. Specialist in Growth Marketing, Branding and Market Expansion, with a strong focus on metrics like ROI, ROAS and KPI analysis.