Tech AI LabsAI Growth Infrastructure for Business

How to Connect ChatGPT API with n8n to Build AI Workflows

By the Tech AI Labs teamChecked 22 November 20265 min read
How to Connect ChatGPT API with n8n to Build AI Workflows: a practical workflow overview

Short answer: Create an API key in your OpenAI platform account, add it as a credential in n8n, then drop an OpenAI node into any workflow: give it a prompt, map data from earlier nodes into it, and use the model's output in the steps that follow.

Connecting the OpenAI API to n8n turns ChatGPT from a chat window into a component: one step in workflows that read your data, think with a world-class model, and act on the result. This guide covers the connection and a first real build, checked against n8n's official documentation in December 2026.

What you need

Step 1: Create an OpenAI API key

  1. 1Log in to the OpenAI platform dashboard.
  2. 2Open the API keys section and create a new secret key.
  3. 3Copy it immediately; it is shown only once. Store it somewhere safe, ideally a password manager.
  4. 4Set a spending limit or budget alert in the billing section while you are here. It is the cheapest insurance in this whole guide.

Step 2: Add the credential in n8n

  1. 1In n8n, open the credentials area and create a new OpenAI credential.
  2. 2Paste the API key and save.
  3. 3The credential is now available to every OpenAI node in every workflow, stored encrypted by n8n rather than pasted into prompts or nodes.

Step 3: Your first AI workflow

Build the classic starter, "summarize new content":

  1. 1Trigger: a schedule, a webhook, or a new item in an RSS feed or spreadsheet.
  2. 2OpenAI node: choose the model and write the message. The prompt is a template: fixed instructions plus live data from earlier nodes, inserted with n8n's expression editor. Example: "Summarize the article below in three bullet points for a busy executive. Article: [article text field]".
  3. 3Action: send the result somewhere useful, an email, a Slack channel, a new row in a sheet.

Run it manually and inspect the output. Congratulations: ChatGPT is now a component in your system.

The connection: API key, credential, OpenAI node in a workflow
Guide diagram: The connection: API key, credential, OpenAI node in a workflow

Step 4: Make prompts that survive production

Workflow prompts differ from chat prompts in one way that matters: they run thousands of times without you watching. So:

Step 5: Handle the failure modes

APIs fail; plan for it:

Step 6: Grow into agents

The single OpenAI node answers one prompt. n8n's AI Agent node puts an OpenAI model in charge of a loop: it can call tools (a sheet lookup, an HTTP request, a search) before answering. Connect the same OpenAI credential, attach tools as nodes, and the model decides which to use per request. n8n's newer agents feature (in Preview) goes further: a standalone assistant with instructions, a knowledge base and schedules, powered by your chosen model. See our n8n guide for the full picture.

From one OpenAI node to a full agent with tools
Guide diagram: From one OpenAI node to a full agent with tools

Builds to try next

FAQ

Is the ChatGPT API the same as a ChatGPT subscription?

No. The API is a separate developer product billed per token of usage, with its own platform dashboard. A ChatGPT Plus or Business subscription does not include API credits.

How much does API usage cost?

Per token, varying by model. Set a budget alert in the OpenAI billing dashboard, and use smaller models for routine steps to keep costs low.

Do I need to code to connect the API in n8n?

No. The OpenAI node takes a credential and a prompt through n8n's visual editor. Code nodes are optional extras.

Which OpenAI models can n8n use?

The models available to your API account, selectable in the node. Use capable small models for extraction and classification; reserve flagship models for steps where quality is visible.

Is my workflow data sent to OpenAI?

Yes, the content of each prompt is processed by the API. Review OpenAI's current API data usage terms, and keep sensitive data out of prompts or out of the cloud.

Sources

Key takeaways

Want ChatGPT wired into your business workflows? Book a free 30 minute call with Tech AI Labs and we will build the first one together.

FAQ

Quick answers

Is the ChatGPT API the same as a ChatGPT subscription?

No. The API is a separate developer product billed per token of usage, with its own platform dashboard. A ChatGPT Plus or Business subscription does not include API credits.

How much does API usage cost?

Per token, varying by model. Set a budget alert in the OpenAI billing dashboard, and use smaller models for routine steps to keep costs low.

Do I need to code to connect the API in n8n?

No. The OpenAI node takes a credential and a prompt through n8n's visual editor. Code nodes are optional extras.

Which OpenAI models can n8n use?

The models available to your API account, selectable in the node. Use capable small models for extraction and classification; reserve flagship models for steps where quality is visible.

Is my workflow data sent to OpenAI?

Yes, the content of each prompt is processed by the API. Review OpenAI's current API data usage terms, and keep sensitive data out of prompts or out of the cloud.

IN THE DIRECTORY

See how this tool compares, what it costs and what it is best for.

Open the tool page →
How to Automate Business Reports Using AI Agents: article illustration
TUTORIALS

How to Automate Business Reports Using AI Agents

Read →
How to Build an AI Email Assistant Using n8n: article illustration
TUTORIALS

How to Build an AI Email Assistant Using n8n

Read →
How to Use n8n to Build Your First AI Automation: article illustration
TUTORIALS

How to Use n8n to Build Your First AI Automation

Read →

Keep exploring

Move from research to a useful workflow. Check the source, learn the steps, then discuss implementation.

Discuss your workflow