# What Is an API Key? Connect OpenAI to n8n Safely

> An API key is a secret password that lets one app use another. How to create an OpenAI key for n8n, why it needs credit, and how to keep it safe.

Source: https://learn.ynteractive.com/content/blog/what-is-an-api-key · Updated 2026-10-09 · Free from Stepthrough (https://learn.ynteractive.com)

Quick answer

An [API key](https://learn.ynteractive.com/content/glossary#api-key) is a long secret code that lets one app use another app's service on your account, like a password made for software instead of people. If you use ChatGPT and want an n8n [automation](https://learn.ynteractive.com/content/glossary/automation) to use [OpenAI](https://learn.ynteractive.com/content/glossary#openai)'s models too, you create an OpenAI API key, add credit, and paste the key into n8n once as a saved credential. The free lesson [AI Social Media Idea Agent](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets) walks through every click in a practice copy, and [AI Receipt Extractor](https://learn.ynteractive.com/content/ai-receipt-extractor-n8n-google-sheets) shows how to reuse the same key.

Last updated October 9, 2026

[Take the free module →](https://learn.ynteractive.com/courses/intro-to-ai-automation/7)Module 7 of the free [Intro to AI Automation](https://learn.ynteractive.com/courses/intro-to-ai-automation) course, about 12 minutes. No account needed.

By [Robert Breen](https://learn.ynteractive.com/content/about/robert-breen) · Published October 9, 2026 · Updated October 9, 2026 · 5 min read

n8n · OpenAI · Security

## Watch: the idea in 0:52

### What is an API key?

Explainer · 0:52 · with captions

An API key is a secret password that lets one app use another. How to create an OpenAI key for n8n, why it needs credit, and how to keep it safe.

**Transcript**

You pay for ChatGPT, and it just works. Then an automation asks for an API key. Here's what that key is. An API key is a long secret code. It's like a password made for software. n8n attaches it to each request to OpenAI. OpenAI checks the key and bills your account. The API is a separate product from ChatGPT. Your plan covers chatting. The API is pay as you go, per request. Add credit first. Ten dollars goes a long way. On the API Keys page, create a secret key. Copy it right away. OpenAI shows it only once. Then paste it into n8n as a saved credential. Treat the key like a password. Never paste it into a chat or a repo, or show it in a screen recording. If one leaks, revoke it and make a new one. Try it yourself, free, in AI Social Media Idea Agent.

This guide explains what the key is, how to make one, why it needs credit, and the few rules that keep it safe.

## What is an API key, in plain words?

An API key is a secret string that identifies your account when one program talks to another. An [API](https://learn.ynteractive.com/content/glossary#api) is the doorway a service offers to other software; the [API key](https://learn.ynteractive.com/content/glossary#api-key) is what proves the request is yours, so the service knows whom to bill.

When n8n sends a request to OpenAI, it attaches your key. OpenAI checks the key, runs the model and charges the cost to your OpenAI account. Anyone holding the key can do the same, which is why you treat it like a password.

## Why does n8n need an OpenAI API key if I already pay for ChatGPT?

Because the OpenAI API is a separate product from ChatGPT, with its own billing. A ChatGPT plan covers chatting at chatgpt.com. An automation calling OpenAI's models from n8n uses the API, which is pay-as-you-go and billed on platform.openai.com.

The lessons put it simply: you pay per request, not per month. [OpenAI API vs ChatGPT Plus](https://learn.ynteractive.com/content/blog/openai-api-vs-chatgpt-plus) explains the difference in more detail, and the glossary has a short entry on [API usage billing](https://learn.ynteractive.com/content/glossary#api-usage-billing).

## How do I create an OpenAI API key?

You add credit first, then create the key, then copy it once. These are the steps from the [AI Social Media Idea Agent](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets) lesson:

1. Go to **platform.openai.com**, then **Billing**, and click **Add to credit balance**. The lesson notes that a key with no credit behind it just errors, and that ten dollars goes a long way.
2. Click **Continue** and add a card. In the practice copy, no card is needed.
3. Click **API Keys** in the left menu.
4. Click **+ Create new secret key**.
5. Name it after what will use it. The lesson types **n8n agent**.
6. Leave **Project** and **Permissions** alone and click **Create secret key**.
7. Click **Copy**. This is the only time OpenAI shows you the key, so paste it somewhere safe right away.
8. Click **Done**.

## Try it free, step by step

**How to Create an AI Agent in n8n That Saves Ideas to Google Sheets**. Build an AI agent for BrightPath Marketing that generates social media post ideas and saves them to Google Sheets — chat trigger, AI Agent, system prompt, model, memory, and the Sheets tool. You do every step yourself in a practice copy of n8n, it checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, and nothing touches your real accounts.

[Start the free lesson](https://learn.ynteractive.com/modules/n8n-ai-agent)

[Or read the full step-by-step guide](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets)

## How do I add the API key to n8n?

You paste it into a credential on the OpenAI Chat Model node, and n8n stores it for every future workflow. In the lesson:

1. On the AI Agent, click the **+** under **Chat Model** and pick **OpenAI Chat Model**.
2. Open the **Credential to connect with** dropdown and click **+ Create new credential**.
3. Paste the key and click **Save**. n8n tests the connection and stores the key.
4. Open the **Model** dropdown and pick a model. The lesson uses **gpt-5-mini**, described as fast and cheap.

A [credential](https://learn.ynteractive.com/content/glossary#credential) in n8n is a saved login for another service. Once it exists, other workflows reuse it: in [AI Receipt Extractor](https://learn.ynteractive.com/content/ai-receipt-extractor-n8n-google-sheets), you simply open the **Credential** dropdown and choose **OpenAI account**, the key you already saved, instead of pasting it again.

## How do I keep an API key safe?

Treat it like a password: store it in one safe place and only paste it where a program needs it. The lesson's rule is short: never paste it into a chat, a repo, or a screen recording.

A few habits that follow from that rule:

- **One key per job.** Naming the key after what uses it ("n8n agent") makes it easy to see which key to turn off later.
- **Keep it out of shared documents.** A key in a team Google Doc is a key anyone with the link can use.
- **Keep it out of screenshots.** Training videos and support tickets are a common way keys leak.
- **Delete a key you think was exposed.** In the API Keys list on platform.openai.com, you can revoke a key and make a new one, then update the credential in n8n.

Paying per request also means a leaked key can run up charges. Start with a small credit balance, like the lesson's ten dollars, so mistakes stay small.

## What happens when the key runs out of credit?

The AI step fails. The workflow can work in testing and then stop once the balance hits zero, because, as the lessons warn, a key with no credit behind it just errors.

If an AI step that used to work suddenly fails, check **Billing** on platform.openai.com before changing anything in n8n. [n8n Workflow Not Running Automatically?](https://learn.ynteractive.com/content/blog/n8n-workflow-not-running) has a full checklist for workflows that go quiet.

## Is an API key the same as signing in with Google?

No. Google accounts in n8n use [OAuth](https://learn.ynteractive.com/content/glossary#oauth): you click **Sign in with Google**, pick the account and approve what n8n may do, and you never see a secret code. OpenAI uses an API key you copy and paste. Both end up as saved credentials in n8n, which is why one credential list holds both kinds.

## Key takeaways

- An API key is a secret code that lets one program use a service on your account and bills that account.
- The OpenAI API is pay-as-you-go and billed on platform.openai.com, separately from ChatGPT plans.
- OpenAI shows a new secret key only once, so copy it right away and store it somewhere safe.
- n8n saves the key as a credential, so later workflows reuse it from the Credential dropdown.
- Never paste an API key into a chat, a repo or a screen recording, and revoke any key you think was exposed.

## Frequently asked questions

**Is an OpenAI API key free?**

Creating the key is free, but using it costs money per request. You add credit under Billing on platform.openai.com; the lessons suggest ten dollars to start.

**Can I see my OpenAI API key again after I create it?**

No. OpenAI shows the full key only once, when you create it. If you lose it, create a new key and update the credential in n8n.

**Does my ChatGPT Plus subscription cover the API?**

No. ChatGPT plans and the OpenAI API are billed separately. An n8n workflow that calls OpenAI uses API credit.

**What should I do if my API key leaked?**

Revoke it in the API Keys list on platform.openai.com, create a new one, and paste the new key into the n8n credential.

## Free lessons in this post

- [How to Create an AI Agent in n8n That Saves Ideas to Google Sheets](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets): Build an AI agent for BrightPath Marketing that generates social media post ideas and saves them to Google Sheets — chat trigger, AI Agent, system prompt, model…
- [How to Do OCR in n8n: Read Receipt Photos into Google Sheets with AI](https://learn.ynteractive.com/content/ai-receipt-extractor-n8n-google-sheets): Drop a photo of a receipt into an n8n chat. An AI agent reads it, pulls out the date, vendor and amount, picks a category, and adds a row to Google Sheets.

## Watch it in a free lesson: How to Create an AI Agent in n8n That Saves Ideas to Google Sheets

### AI Social Media Idea Agent: video walkthrough

Full walkthrough · 8:07 · with captions

Build an AI agent for BrightPath Marketing that generates social media post ideas and saves them to Google Sheets — chat trigger, AI Agent, system prompt, model, memory, and the Sheets tool. The whole lesson narrated step by step, recorded in Stepthrough’s simulated practice environment.

[Watch it with chapters and the full transcript](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets#watch)

From the free lesson [How to Create an AI Agent in n8n That Saves Ideas to Google Sheets](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets)

## Related terms

Plain-English definitions, each with an example from a free lesson.

[API key](https://learn.ynteractive.com/content/glossary#api-key) · [Automation](https://learn.ynteractive.com/content/glossary/automation) · [OpenAI](https://learn.ynteractive.com/content/glossary#openai) · [A/B testing](https://learn.ynteractive.com/content/glossary) · [Accounts payable](https://learn.ynteractive.com/content/glossary) · [AI agent](https://learn.ynteractive.com/content/glossary/ai-agent) · [Append row](https://learn.ynteractive.com/content/glossary#append-row) · [AR aging report](https://learn.ynteractive.com/content/glossary#ar-aging-report)

[The full AI glossary](https://learn.ynteractive.com/content/glossary)

## Related prompts

- [Case study interview questions prompt](https://learn.ynteractive.com/content/prompts/case-study-interview-questions-prompt): Plan a client interview that gets a case study's before, during and after story in their own words, with follow-up probes and…

[All free prompt templates](https://learn.ynteractive.com/content/prompts)

## Visual guides

The same ideas as quick visual guides: swipe through the slides, or read each one as text.

- [Receipts to Google Sheets with an AI agent in n8n](https://learn.ynteractive.com/content/ai-receipt-extractor-n8n-google-sheets): A box of paper receipts at the end of the month. Typing them in is slow and easy to get wrong.
- [5 Steps to an n8n AI Agent That Saves to Google Sheets](https://learn.ynteractive.com/content/n8n-ai-agent-tutorial-google-sheets): A visual guide: build an n8n AI agent that writes social media ideas and saves each one as a Google Sheets row, in 5 steps from the free lesson.

[All visual guides](https://learn.ynteractive.com/content/visual)

## Keep reading

- [OpenAI API vs ChatGPT Plus: What You Pay For](https://learn.ynteractive.com/content/blog/openai-api-vs-chatgpt-plus): OpenAI API vs ChatGPT Plus: why your ChatGPT plan doesn't power n8n, how pay-per-request API billing works, and how to set up a key safely.
- [n8n Defined Automatically by the Model, Explained](https://learn.ynteractive.com/content/blog/n8n-defined-automatically-by-the-model): What "defined automatically by the model" means in n8n tools, when to click the sparkle button, and when a fixed expression is the safer choice.
- [Google Sheets as a Database for Automation: Set It Up](https://learn.ynteractive.com/content/blog/google-sheets-as-a-database): Use Google Sheets as a database for automation: exact headers in row 1, one row per item, a lookup tab, a review column, and reading vs appending in n8n.

[All blog posts](https://learn.ynteractive.com/content/blog) · [All free tutorials](https://learn.ynteractive.com/content)
