Connecting OpenAI to n8n: credentials, models and best practices (complete guide)
Published 1 August 2026 · 6 min read
OpenAI is the most widely used AI provider in n8n workflows, yet that first connection still trips up plenty of users: the API key is nowhere to be found, the ChatGPT subscription gets confused with API credit, a 429 error shows up on the very first call, or five different nodes carry the OpenAI logo and it is unclear which one to pick. This guide walks through everything in order: creating the key, configuring the credential (including the Base URL field, often overlooked even though it unlocks OpenAI-compatible endpoints), a tour of the OpenAI node family, model selection, and fixing the most common errors. If you are still weighing OpenAI against Anthropic, our comparison guide for connecting Claude or GPT to n8n gives the big picture across both providers; this page is the dedicated, 100% OpenAI deep dive.
Step 1: create the API key on platform.openai.com
The OpenAI API is managed on platform.openai.com, a separate space from ChatGPT. One essential point before anything else: a ChatGPT Plus subscription gives you zero API credit. The two products are billed separately, and this is the number one cause of 429 errors for beginners.
- Create an account (or sign in) on platform.openai.com.
- In the billing settings, add prepaid credit or a payment method. Without this, the key will exist but every call will fail.
- In the API keys section, create a new secret key. OpenAI organizes keys by project: create a project dedicated to n8n, so you can track and cap its consumption independently.
- Copy the key immediately: it will never be shown in full again.
- If your account belongs to several organizations, also note the Organization ID in the organization settings.
Set a monthly spending limit in the project's billing right away: an n8n workflow stuck in a loop can fire hundreds of calls in minutes, and a hard cap remains your best safety net.
Step 2: create the OpenAI credential in n8n
In n8n, open Credentials → Add credential → OpenAI. Three fields are available:
- API Key (required): the secret key you copied in the previous step.
- Organization ID (optional): only needed if your account belongs to several organizations, to designate the one that gets billed. Otherwise, leave it blank.
- Base URL (optional): the API URL, pointing to OpenAI's official endpoint by default. This is the most underrated field in the credential.
The Base URL field deserves a closer look: the OpenAI API format has become a de facto standard, widely implemented elsewhere. By swapping it for the URL of a compatible provider — OpenRouter to access dozens of models with a single key, a corporate proxy, or a local inference server speaking the OpenAI format — you reuse the same n8n nodes without touching your workflows.
Save, then test with a minimal OpenAI node (a simple "reply OK") before building anything: this separates authentication problems from workflow problems. And apply the habits from our guide to securing API credentials in n8n: never hardcode a key in a Code or HTTP Request node, always use the encrypted credentials system.
The family of nodes that use this credential
This is a classic source of confusion: several n8n nodes carry the OpenAI name, and they all share the same credential. Each has a distinct role, though.
- The classic OpenAI node: the Swiss army knife. It groups operations by resource — sending a message to a model (chat), generating an image, transcribing or translating audio, generating speech, analyzing an image, and managing files or assistants. It is the right choice for a one-off call: "summarize this text", "transcribe this recording".
- OpenAI Chat Model: a sub-node that is never used on its own. It plugs underneath an AI Agent, an LLM chain or a Text Classifier to provide their "brain". If this architecture is new to you, our guide to getting started with n8n's AI nodes explains the difference between nodes and sub-nodes.
- Embeddings OpenAI: another sub-node, dedicated to turning text into vectors for RAG architectures — it plugs underneath a vector store to index and search documents.
- Audio transcription (Whisper): available through the OpenAI node's audio operation, it turns a binary audio file into text. Our guide to transcribing and summarizing meetings with Whisper and n8n builds a complete use case around it.
- Image generation: the OpenAI node's image operation produces visuals from a prompt, returned as binary data or a URL.
A concrete example: an OpenAI node (chat operation) whose response is consumed downstream with an expression:
{{ $json.message.content }}
And if you expect structured JSON rather than free text, combine the Chat Model with a Structured Output Parser to guarantee a format the next nodes can rely on.
Choosing the model for each use case
The Model field of each node lists the models your key can access. Rather than quoting prices (they change too fast to be carved into an article), keep the logic by family:
- Lightweight models (gpt-4o-mini and equivalents): classification, simple extraction, rewriting, routing. The vast majority of automation tasks need nothing more.
- Flagship models (gpt-4o / GPT-4.1 class): polished writing, multi-step reasoning, agents with tools.
- Reasoning models (o-series): complex problems where quality matters more than latency and cost — reserve them for the steps that justify it.
- Specialized models: whisper-1 for audio, text-embedding-3-small or large for embeddings, the image models for visual generation.
This choice is not just about comfort: a study by Lingjiao Chen, Matei Zaharia and James Zou (Stanford), FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance, published in 2023 and later in the Transactions on Machine Learning Research journal, shows that a model cascade — querying a lightweight model first and only escalating to the strongest one when needed — can match the performance of the best single model while cutting costs by up to 98% on some query sets. In n8n, this pattern comes naturally: a lightweight model classifies, an IF node routes the hard cases to a stronger model.
Common errors: 401, 429 and their real causes
Three errors cover most of the blockers:
- 401 – invalid_api_key: the key is wrong, truncated (one extra copied space is enough), revoked, or the Base URL points to a service that does not accept it. Recreate the credential cleanly by re-pasting the key.
- 429 – insufficient_quota: the classic trap. This is not a speed problem but an exhausted or missing credit problem — typically an account without billing enabled. Head to platform.openai.com, Billing section.
- 429 – rate_limit_exceeded: here it really is the call frequency exceeding your usage tier's limits. The fixes — batching, pauses, retry with backoff — are covered in our guide to handling AI API rate limits in n8n.
For a production workflow that must never stop, plan a fallback too: our article on multi-provider AI fallback in n8n shows how to automatically switch to another model or provider when OpenAI returns an error.
Tracking and controlling costs
The platform.openai.com dashboard provides usage reporting per project — one more reason to use a key dedicated to n8n. But to know which workflow consumes what, you need to instrument on the n8n side: API responses include the number of tokens consumed, which you can log to Google Sheets or a database after each call. Our guide to tracking the cost of your AI calls in n8n details this setup end to end.
Three habits avoid nasty surprises: a hard spending limit on the OpenAI side, a lightweight model as the default, and short prompts — useless context is paid for on every run, thousands of times a month on a scheduled workflow.
Key takeaways
Connecting OpenAI to n8n comes down to two steps — an API key created in a dedicated project on platform.openai.com (with API credit, independent of ChatGPT Plus), then an n8n credential with the key, the Organization ID if needed, and a Base URL you can point at OpenAI-compatible endpoints. That single credential powers the whole node family: the classic OpenAI node, the Chat Model for the AI Agent, Embeddings, Whisper transcription and image generation. Stick to the lightest model that does the job, keep the two faces of the 429 error apart (quota versus rate limit), and log your tokens from your first serious workflow onwards. For AI workflows already built on this foundation, browse our ready-to-use n8n workflows.
FAQ
Frequently asked questions
Is my ChatGPT Plus subscription enough to use OpenAI in n8n?
No. ChatGPT Plus and the OpenAI API are two separate products with separate billing. For n8n you need an account on platform.openai.com with prepaid API credit (or billing enabled): without credit, every call returns a 429 error with the insufficient_quota code, even if your ChatGPT subscription is active.
Does a single OpenAI credential work for all OpenAI nodes in n8n?
Yes. The classic OpenAI node, the OpenAI Chat Model sub-node used by the AI Agent, the Embeddings OpenAI sub-node and the audio or image operations all share the same credential type. You create it once and select it in each node. It is still worth creating separate API keys per project to isolate costs and revocations.
What is the Base URL field in the n8n OpenAI credential for?
It points to the official OpenAI API by default. By replacing it with the URL of a service that implements the OpenAI API format (OpenRouter, some local inference servers, corporate proxies), you reuse the exact same n8n nodes with another provider, without changing your workflows.
Why does my OpenAI node return a 404 model_not_found error?
Either the model name is misspelled, or your project or organization does not have access to that model (some models require a usage tier or verification), or the credential's Base URL points to a service that does not offer it. Check the exact name in the OpenAI documentation and test with a standard model to isolate the cause.
Bundle FlowKit Complet
€269