What you need before you start
To connect OpenAI to N8N, you need three things: an OpenAI account with an active API key, an N8N instance (either self-hosted or cloud), and a workflow where you've already placed an OpenAI node. The API key is a string of characters that proves to OpenAI that your N8N workflow has permission to use their services — it's like a password, but specifically for automated tools instead of people.
If you don't have an OpenAI API key yet, go to platform.openai.com, sign in or create an account, click your profile icon in the top right, select "API keys", and click "Create new secret key". Copy it when ready — OpenAI won't show it again. Store it somewhere safe, like a password manager, because anyone with this key can use your OpenAI account and be charged for it.
Key Takeaways
- Your OpenAI API key is a secret string you create at platform.openai.com and must keep private, because it controls access to your account and billing.
- In N8N, you add the key by creating a new credential of type "OpenAI API", pasting your key into the "API Key" field, and naming the credential so you can reuse it.
- Once the credential is saved, you select it from the dropdown in any OpenAI node's "Authentication" section.
- If your workflow stops working after adding the key, the most common cause is a typo in the key or a key that has been deleted from your OpenAI account.
Creating a new credential in N8N
Open your N8N workflow and click on any OpenAI node you've already placed in the canvas. On the right side, you'll see a panel with fields for that node. Look for a section labeled "Authentication" or "Credentials" — the exact label depends on your N8N version, but it's always near the top of the panel.
Click the dropdown that says "Create New" or shows a plus icon. N8N will open a modal window asking you to choose a credential type. Search for or select "OpenAI API". A form will appear with a field labeled "API Key" — paste your OpenAI key there. Give the credential a name like "My OpenAI Key" or "Production OpenAI" so you can identify it later if you create more than one. Click "Save" or "Create".
N8N now stores this credential securely and associates it with your account. You won't see the actual key again in the interface — N8N only shows you the name you gave it. This is intentional: it keeps the key from being accidentally exposed if someone screenshots your screen or looks at your monitor.
Selecting the credential in your node
After you save the credential, the dropdown in the OpenAI node's Authentication section will automatically show the name you just created. If it doesn't, refresh the page or click the dropdown arrow to see the list. Select your credential from the list.
The node is now connected to your OpenAI account. You can configure the rest of the node's settings — like which model to use (GPT-4, GPT-3.5-turbo, etc.), the prompt, temperature, and other parameters — without touching the credential again. If you add another OpenAI node to the same workflow, you can select the same credential from the dropdown instead of creating a new one.
Testing the connection
To verify the key works, run your workflow by clicking the "Execute Workflow" button or the play icon. If the OpenAI node runs without error, the credential is valid. If you see an error message like "Invalid API key" or "Unauthorized", the key is either wrong, has been deleted from your OpenAI account, or has expired.
Check that you copied the entire key with no extra spaces at the beginning or end. If you're certain the key is correct, log into platform.openai.com and verify the key still exists in your API keys list. If it's gone, someone may have deleted it, or you may have created it in a different OpenAI account. Create a new key and update the credential in N8N.
Keeping your key find
Never paste your OpenAI API key into a chat, email, or public document. Never commit it to a GitHub repository or any version control system. If you accidentally expose your key, delete it when ready from platform.openai.com and create a new one — exposed keys can be used by anyone to run up charges on your account.
If you're sharing your N8N workflow with others, don't export it with the credential embedded. In N8N, you can share a workflow as a JSON file, but the credential will be redacted. The person importing the workflow will need to add their own OpenAI API key or use a credential you've already set up on a shared N8N instance.
Troubleshooting common problems
If your workflow was working and suddenly stops, the most common cause is that your OpenAI API key has been deleted or rotated. Check platform.openai.com to confirm the key still exists. If you've rotated your keys for security, you'll need to create a new credential in N8N with the new key and update any nodes using the old one.
If you see "Rate limit exceeded" errors, you've hit OpenAI's usage limits for your account tier. This isn't a credential problem — it means you're sending too many requests too quickly. Wait a few minutes and try again, or upgrade your OpenAI plan if you need higher limits. If you see "Insufficient quota", you've run out of credits or your trial period has ended. Add a payment method to your OpenAI account.
If the node runs but produces unexpected results, the credential is working correctly — the problem is with how you've configured the prompt, model, or other settings in the node itself, not with the key.
Using multiple OpenAI credentials
You can create more than one OpenAI credential in N8N if you have multiple OpenAI accounts or want to separate billing by project. Create each credential the same way: click the dropdown in an OpenAI node, select "Create New", paste a different API key, and give it a descriptive name like "Client A OpenAI" or "Testing Account".
In a single workflow, different OpenAI nodes can use different credentials. This is useful if you want one part of your workflow to use a high-cost model like GPT-4 and another part to use a cheaper model like GPT-3.5-turbo, and you want to track costs separately. Just select the appropriate credential from the dropdown in each node.
Frequently Asked Questions
Can I use the same OpenAI API key in multiple N8N workflows?
Yes. Once you create a credential in N8N, you can select it from the dropdown in any OpenAI node across all your workflows. You don't need to create a new credential for each workflow — one credential can be reused everywhere.
What happens if I delete a credential that's being used in a workflow?
The workflow will fail when it tries to run the OpenAI node. N8N will show an error saying the credential no longer exists. You'll need to create a new credential and update the node to use it before the workflow can run again.
Can I see my OpenAI API key after I've saved it in N8N?
No. N8N hides the actual key for security reasons and only shows you the name you gave the credential. If you need to verify the key is correct, you'll have to check it in your OpenAI account at platform.openai.com.
What if I accidentally shared my API key with someone?
Delete it when ready from platform.openai.com by clicking the trash icon next to the key in your API keys list. Create a new key and update your N8N credential with the new one. Anyone with the old key can no longer use it.
Do I need a paid OpenAI account to use the API in N8N?
You need a payment method on file with OpenAI, even if you have free trial credits. Once your trial ends, you'll be charged for API usage. Check your usage and costs at platform.openai.com/account/billing/overview to see how much you're spending.