n8n + OpenAI

Build AI Agents Without Code Using n8n + OpenAI

Connect n8n to OpenAI to run GPT-4o inside your automations — qualify leads, process documents, draft replies, and build autonomous agent loops. No coding required.

Five things you can automate with n8n + OpenAI

🤖
AI agent with memory and tool use
Build autonomous GPT-4o agents that can search the web, query databases, send emails, and remember context across sessions — all orchestrated in n8n.
🎯
Lead qualification with GPT-4o scoring
Pass inbound leads to GPT-4o with a custom scoring rubric. Get a structured score, reasoning, and recommended action — written directly to your CRM.
📄
Document Q&A using RAG + OpenAI
Upload PDFs or documents to a vector store (Pinecone, Supabase), then use OpenAI embeddings and GPT-4o to answer questions over your own knowledge base.
✍️
Content generation pipeline
Trigger GPT-4o to write blog posts, product descriptions, or social content from structured data — then publish directly to your CMS or Google Docs.
📧
Email classification and routing
Parse incoming emails with GPT-4o to classify intent, extract key data, and route each message to the right team or trigger the right downstream workflow.

Setting Up n8n + OpenAI

1
Create an OpenAI API key
Visit platform.openai.com, navigate to API Keys in the sidebar, and click Create new secret key. Give it a descriptive name (e.g. "n8n production") and copy it immediately — OpenAI won't show it again.
platform.openai.com → API Keys → Create new secret key
2
Add OpenAI credentials in n8n
In n8n, go to Settings → Credentials → New and search for OpenAI. Select it, paste your API key, and save. The credential is now available across all OpenAI and AI Agent nodes in your instance.
3
Add an AI Agent node (or OpenAI node)
For autonomous multi-step tasks, use the AI Agent node — it handles tool-calling, memory, and reasoning loops. For single-shot prompts (summarize, classify, generate), use the OpenAI node directly. Configure the model (gpt-4o), system prompt, and any tools.
4
Connect trigger → AI Agent → action nodes, activate
Wire your trigger node (webhook, schedule, Gmail, etc.) to the AI Agent node. Connect the agent's output to action nodes — update a CRM, send a Slack message, write to a database. Test with a live run, then activate the workflow.

Real workflows Xelionlabs has delivered

Workflow 01
Lead Qualification Agent
Form submission triggers n8n. GPT-4o scores the lead (0–100) against ICP criteria, writes a plain-English justification, and updates HubSpot with the score + recommended next action. Sales team sees only pre-qualified leads.
n8nGPT-4oHubSpotTypeform
Workflow 02
Customer Support Agent with RAG
Incoming support tickets trigger a RAG pipeline: n8n retrieves relevant docs from Pinecone, passes them + the ticket to GPT-4o, and posts a drafted reply for human approval — or auto-sends if confidence is above threshold.
n8nOpenAIPineconeGmail
Workflow 03
Multi-step Document Processor
PDFs are uploaded to a shared folder. n8n extracts text via OpenAI Vision, runs structured extraction (entities, dates, amounts) via GPT-4o, and writes a clean JSON record to a Postgres database — replacing hours of manual data entry.
n8nOpenAI VisionGPT-4oPostgres

n8n + OpenAI — Common Questions

How do I connect n8n to OpenAI?
In n8n, go to Settings → Credentials → New and search for OpenAI. Paste your OpenAI API key (from platform.openai.com) and save. The credential is then available in all OpenAI and AI Agent nodes across your workflows — no repeated setup needed.
What is the n8n AI Agent node?
The n8n AI Agent node is a special node that connects an LLM (like GPT-4o) with tools (web search, code execution, database queries) and memory. It can reason across multiple steps autonomously — making it suitable for complex tasks like lead qualification, document analysis, and customer support.
Can n8n run GPT-4o agent loops?
Yes. n8n's AI Agent node supports multi-step reasoning loops with tool-calling, persistent memory (via vector stores), and custom system prompts. You can build fully autonomous agents that decide which tools to call based on the task — exactly like a custom ChatGPT with your own data and integrations.
How much does n8n + OpenAI cost?
n8n is free for self-hosted deployments; n8n Cloud starts at $20/month. OpenAI charges per token — GPT-4o is roughly $2.50 per million input tokens and $10 per million output tokens. Most automation workflows process a few hundred tokens per run, making costs very manageable — often under $5/month for typical volumes.

Want a custom n8n + OpenAI agent built for you?

Tell us your use case and we'll scope, build and deploy a production-ready AI workflow — typically within a week.

Get in Touch →