How to Add Your OpenAI API Key in n8n Node (Full Setup)
10 November 2025

How to Add Your OpenAI API Key in n8n Node (Full Setup)

Integrating the OpenAI API with n8n can unlock powerful automation capabilities powered by AI. For developers, marketers, analysts, and businesses using n8n workflows, connecting to OpenAI’s API opens doors to generating content, summarizing data, translating text, and much more. To get started, one essential step is to correctly add your OpenAI API key to the n8n OpenAI node.

TL;DR

To add your OpenAI API key in n8n, first, retrieve your unique API key from your OpenAI account. Then, open n8n, navigate to “Credentials”, and configure new API credentials for OpenAI. After choosing the appropriate authentication method (usually API Key), paste the key and save. Once that’s done, simply select this credential in any OpenAI node in your workflow.

Step-by-Step Guide: How to Add Your OpenAI API Key in n8n

1. Retrieve Your OpenAI API Key

Before setting anything up in n8n, you must first retrieve your OpenAI API key. Follow these steps:

  • Log in to your OpenAI account.
  • Navigate to the “API Keys” section in your profile dashboard.
  • Click on the “+ Create new secret key” button.
  • Copy the generated API key and store it somewhere secure. You will only see the full key once upon creation.

2. Log into Your n8n Instance

With your API key ready, log into the web interface of your n8n instance. This can be a self-hosted n8n installation or a cloud-hosted version via platforms like n8n.cloud.

3. Navigate to Credentials Settings

Once inside your n8n workspace:

  1. Click on the gear icon (⚙️), typically located at the top-right of the screen.
  2. Select “Credentials” from the dropdown menu.
  3. Click the “+ New Credential” button located in the upper-right corner.

4. Select “OpenAI API” from Credential Types

In the new credentials window:

  • Type “OpenAI” in the search box or scroll to find it manually.
  • Click on the “OpenAI API” credential type.

5. Configure the OpenAI API Credential

Now the actual configuration begins. This is where you paste your OpenAI key.

  • Enter a name for the credential that you can easily recognize later (e.g., “OpenAI – Personal”).
  • Select Authentication Method as ‘API Key’.
  • A field labeled “API Key” will appear where you need to paste your key.
  • Paste your API key that you obtained from the OpenAI dashboard.

Click “Save” once you’re done. You’re now ready to use this credential in OpenAI nodes.

6. Use the Credential in an OpenAI Node

The final step is using this credential in a workflow. Here’s how:

  1. Create or edit an n8n workflow.
  2. Click on the “+” icon to add a new node.
  3. Search for “OpenAI” and select it from the list.
  4. With the node selected, look for a dropdown labeled “Credentials”.
  5. Select your newly saved OpenAI credential from the list.

Your OpenAI node is now ready to use. You can configure prompts, set models like GPT-4 or GPT-3.5-turbo, enter temperature settings, and define maximum tokens—all from the n8n UI.

Best Practices for API Key Management

  • Do Not Share: Never share your API key in public tools like GitHub or shared Google Docs.
  • Use Environment Variables (Advanced): For more secure deployment, store your API key in environment variables and reference from n8n.
  • Rotate Keys Regularly: In case of leaked credentials or suspected misuse, rotate your OpenAI keys promptly.
  • Limit Usage: Use OpenAI’s dashboard tools to set usage limits or monitor consumption by IP or user profile.

Advanced Tip: Use the HTTP Request Node (Optional)

Although n8n has a built-in OpenAI node, you can also use the HTTP Request node if you need more customization:

  • Enter the API endpoint from OpenAI, such as https://api.openai.com/v1/chat/completions.
  • Under Headers, set Authorization key with value Bearer YOUR_API_KEY.
  • Set the method to POST and format your JSON input accordingly.

This approach is perfect for users needing flexibility not offered in the precompiled OpenAI node.

Conclusion

Adding your OpenAI API key in an n8n node is a quick yet critical step that enables seamless interaction with one of the most powerful AI platforms available today. Whether you’re summarizing customer support tickets, auto-generating blog content, or working on smart workflow automation, integrating OpenAI with n8n offers infinite possibilities. By following the steps above, both beginners and power users can unlock new layers of automation and intelligence within minutes.

Frequently Asked Questions (FAQ)

  • Q: Can I use multiple OpenAI API keys in n8n?
    A: Yes, you can create and store multiple credentials under different names and select them within different nodes.
  • Q: What if my OpenAI node says “authentication failed”?
    A: Ensure your API key is pasted correctly and has not expired or been revoked from your OpenAI dashboard.
  • Q: Does n8n support GPT-4?
    A: Yes. If your OpenAI account has access to GPT-4, you can select it from the model dropdown in supported nodes.
  • Q: Can I use OpenAI via HTTP request instead of the pre-built node?
    A: Absolutely. The HTTP Request node provides more control and customizability, though it requires manual setup of headers and payload.
  • Q: Is there a way to store OpenAI keys securely in a shared n8n workspace?
    A: Yes, use the credentials section to create credentials limited to certain users or workflows, based on your workspace permissions.

Implementing AI into your automated workflows has never been easier. With just a few configuration steps, you can harness the power of OpenAI in your n8n ecosystem.

Leave a Reply

Your email address will not be published. Required fields are marked *