Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    How to self-host n8n on Hostinger VPS

    June 13, 2026

    n8n_community_packages_allow_tool_usage: How to Configure It

    June 12, 2026

    n8n access blocked Google verification process fix

    June 12, 2026
    n8n Automation Tutorialn8n Automation Tutorial
    • Home
    • n8n AI Workflows & Tool Comparisons
    • n8n Integrations & Nodes
    • n8n Setup & Self-Hosting
    • AI Automation & Enterprise Workflows
    • n8n Security & Vulnerabilities
    • n8n Tutorials & Comparisons
    • Contact Us
    Home ยป How to Add an OpenAI API Key to an n8n Node
    n8n Integrations & Nodes

    How to Add an OpenAI API Key to an n8n Node

    Olaitan OladipoBy Olaitan OladipoMay 22, 2026No Comments8 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp VKontakte Email
    n8n search results for OpenAI nodes
    Type OpenAI into the node search field and choose the OpenAI node that matches the task you want to automate.
    Share
    Facebook Twitter LinkedIn Pinterest Email

    This guide shows how to connect n8n to OpenAI by adding an OpenAI API key to an OpenAI node credential. Once the credential is saved, you can use n8n to automate AI-powered tasks such as text generation, chat responses, classification, summaries, content workflows, and agent-style automations.

    You will need access to your n8n instance and an OpenAI Platform account that can create API keys. The process is simple, but the key must be handled carefully because it can authorize API usage on your account. For the previous guide in this series, read How to fix access blocked: n8n.cloud has not completed the google verification process.

    n8n workflows overview before creating an OpenAI workflow
    Start inside n8n from the workflows overview. This is where you can create or open the workflow that will use OpenAI.

    Security first: OpenAI API keys are secrets. Do not share them publicly, paste them into frontend code, or commit them to a repository. If a key is exposed, revoke or rotate it immediately.

    Quick Setup Summary

    • Open n8n and create or open a workflow.
    • Add an OpenAI node to the canvas.
    • Open the node credential section.
    • Create a new OpenAI credential in n8n.
    • Open the OpenAI Platform API keys page in another tab.
    • Create a new secret key and copy it right away.
    • Paste the key into n8n’s API Key field.
    • Save the credential and make sure the OpenAI node uses it.
    • Add a small test input and execute the node.

    Step 1: Open n8n and Create a Workflow

    Start from the n8n workflow overview. You can create a brand-new workflow or open an existing test workflow. For beginners, a blank workflow is the safest option because you can test the credential without changing production automations.

    n8n workflow list with existing workflows
    Give the workflow a clear name so it is easy to find later among your other n8n workflows.

    Give the workflow a descriptive name such as OpenAI API Key Test or OpenAI Credential Setup. Naming it clearly helps you find it later when you need to reuse or troubleshoot the OpenAI connection.

    Blank n8n workflow canvas with Add first step button
    Open a blank workflow canvas, then use Add first step to begin adding the OpenAI node.

    Step 2: Add a Starter Node or Use a Blank Canvas

    The video shows a blank n8n canvas. You can add a manual trigger to keep the workflow tidy, but for credential setup, the most important step is adding the OpenAI node and saving the credential.

    n8n trigger suggestions panel
    n8n may first ask what should trigger the workflow. A manual trigger is fine for a simple credential test.

    If you choose a trigger, Trigger manually is useful for testing. It lets you run the workflow only when you click the execute button.

    Step 3: Search for the OpenAI Node

    Click the plus button or search area on the canvas, then search for OpenAI. n8n will show OpenAI-related nodes and models. Choose the OpenAI node that matches what you want to build.

    n8n node search panel before typing OpenAI
    Use the node search panel to find OpenAI-related nodes inside n8n.
    n8n search results for OpenAI nodes
    Type OpenAI into the node search field and choose the OpenAI node that matches the task you want to automate.

    For general setup, the main OpenAI node is enough. If you are building AI-agent flows, you may also see options such as OpenAI Chat Model. The credential setup is still the same idea: n8n needs an API key before it can call OpenAI.

    OpenAI node options in n8n
    n8n shows multiple OpenAI-related options, including the main OpenAI node and OpenAI Chat Model.

    Step 4: Open the OpenAI Node Credentials

    After adding the OpenAI node, open its parameters. Near the top, you should see a Credential section. If you have not connected OpenAI before, n8n will show that no credentials exist yet.

    OpenAI node parameters panel in n8n
    Once the node is added, open its parameter panel. The credential area appears near the top of the node settings.

    Click Set up credential. This opens the OpenAI account credential panel where n8n expects your API key.

    OpenAI node Set up credential button in n8n
    If no OpenAI credential exists yet, click Set up credential to create one.

    Step 5: Create an OpenAI Secret Key

    Open a new browser tab and go to the OpenAI Platform API keys page. Official OpenAI guidance says new secret keys are created from the API Keys page, and each key can have permissions such as All, Restricted, or Read Only depending on your needs.

    OpenAI Platform API keys page
    In a new tab, open the OpenAI Platform API keys page. This is where you create and manage secret keys for API access.

    Click Create new secret key. When the dialog opens, give the key a clear label, for example n8n OpenAI Main. If you manage multiple projects, make sure the correct OpenAI project is selected.

    OpenAI create new secret key dialog
    Click Create new secret key to open the key creation dialog.
    OpenAI secret key name and project fields
    Give the key a descriptive name and select the project it should belong to before creating it.

    Copy the key immediately: API dashboards commonly show a secret key only once. Copy it before closing the dialog, then store it somewhere secure if your workflow documentation requires it.

    Step 6: Paste the API Key into n8n

    Return to the n8n OpenAI credential panel. Paste the secret key into the API Key field. The default Base URL should normally stay as https://api.openai.com/v1 unless you intentionally use a compatible proxy or custom endpoint.

    n8n OpenAI account credential setup window
    Return to n8n’s OpenAI credential panel after creating the secret key in the OpenAI Platform.
    n8n OpenAI credential API key field
    Paste the OpenAI secret key into the API Key field in n8n. Leave the base URL as the default OpenAI API endpoint unless you know you need a custom endpoint.

    The Organization ID field is optional for many users. Only add it if your OpenAI account setup requires a specific organization value.

    n8n OpenAI credential advanced fields
    The n8n credential panel also includes optional organization, custom header, and allowed-domain settings.

    If you click Save before entering the key, n8n will show that the API Key field is required. Paste the key first, then save the credential.

    n8n OpenAI credential required field warning
    If you try to save without a key, n8n warns that the API Key field is required. Paste the copied key before saving.

    Step 7: Select the Credential in the OpenAI Node

    Once saved, go back to the OpenAI node and make sure the new credential is selected. If n8n still says no credential exists, reopen the credential dropdown and choose the credential you just created.

    Step 8: Add a Small Test Input

    The node needs a task to run. Add the minimum input required by your selected operation. For example, if you are testing a text or chat-style operation, use a simple prompt such as Write one sentence explaining what n8n does.

    n8n OpenAI node with Execute step button
    After the credential is saved, return to the OpenAI node and add the minimum input required for the selected operation.

    Step 9: Execute the Node

    Click Execute step or Execute node. If the setup is correct, n8n should return data in the output panel. If the credential is missing or invalid, n8n will show an error that you can use for troubleshooting.

    n8n OpenAI node output panel before execution
    Use Execute step or Execute node to test the setup. A successful run will return data in the output panel.

    Troubleshooting

    • If n8n says the API Key field is required, the key was not pasted before saving.
    • If the node returns an authentication error, copy a fresh key from the OpenAI Platform and paste it again without leading or trailing spaces.
    • If you use multiple OpenAI projects, confirm the key belongs to the project with API access and billing configured.
    • If you use restricted key permissions, make sure the key has permission for the endpoint or model feature your n8n node is calling.
    • If the node executes but returns no useful output, check that the selected operation has a prompt, text input, model, and other required fields.
    • If you exposed the key accidentally, revoke it and create a new one before running more automations.

    Best Practices for OpenAI API Keys in n8n

    • Use a dedicated key for n8n instead of reusing one key everywhere.
    • Name the key clearly so you can identify it later in the OpenAI Platform.
    • Use restricted permissions when possible, especially for production workflows.
    • Rotate keys periodically and remove keys you no longer use.
    • Never publish screenshots that show the full key.
    • Limit who can edit credentials inside your n8n workspace.

    Official OpenAI References

    For current OpenAI guidance, review OpenAI API authentication, API key permissions, and API key safety best practices.

    That is the full setup: create the OpenAI key, paste it into n8n’s OpenAI credential, save it, select it in the node, and run a small test before building larger automations.

    Olaitan Oladipo

    Olaitan Oladipo holds a BSc in Sociology from Olabisi Onabanjo University. He is a self-taught automation builder who has spent years inside n8n doing the work that most tutorials skip: debugging OAuth errors at 2am, migrating client automations from Make.com mid-project, fighting reverse proxy misconfigurations on AWS EC2, and figuring out through trial and error what actually holds up in production versus what only looks clean in a demo.

    He is not a developer by training and not a SaaS founder. He is the person in the Discord server who actually answers the question instead of linking to the docs.

    His writing on n8n Automation Tutorial covers self-hosting, AI agent workflows, tool comparisons, and the security vulnerabilities the automation industry would rather not discuss. He has built AI-assisted invoice approval flows using OpenAI function calling, connected Claude via HTTP Request nodes, and holds considered opinions about Zapier, Make.com, LangChain, and CrewAI that their marketing teams would not appreciate.

    He writes for people who are technical enough to follow a tutorial but experienced enough to want the honest version.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp Email
    Previous ArticleSAP Embedded n8n Into Joule Studio. Here Is Why That Single Decision Changes the Entire Enterprise Software Market.
    Next Article Make.com to n8n Script Translator: EASILY Convert Make Automations to n8n
    Olaitan Oladipo
    • Website

    Olaitan Oladipo holds a BSc in Sociology from Olabisi Onabanjo University. He is a self-taught automation builder who has spent years inside n8n doing the work that most tutorials skip: debugging OAuth errors at 2am, migrating client automations from Make.com mid-project, fighting reverse proxy misconfigurations on AWS EC2, and figuring out through trial and error what actually holds up in production versus what only looks clean in a demo. He is not a developer by training and not a SaaS founder. He is the person in the Discord server who actually answers the question instead of linking to the docs. His writing on n8n Automation Tutorial covers self-hosting, AI agent workflows, tool comparisons, and the security vulnerabilities the automation industry would rather not discuss. He has built AI-assisted invoice approval flows using OpenAI function calling, connected Claude via HTTP Request nodes, and holds considered opinions about Zapier, Make.com, LangChain, and CrewAI that their marketing teams would not appreciate. He writes for people who are technical enough to follow a tutorial but experienced enough to want the honest version.

    Related Posts

    n8n_community_packages_allow_tool_usage: How to Configure It

    June 12, 2026

    n8n access blocked Google verification process fix

    June 12, 2026

    Unrecognized node type n8n-nodes-mcp.mcpclienttool

    June 12, 2026

    n8n Puppeteer:Install Puppeteer in n8n via Community Node

    May 27, 2026
    Leave A Reply Cancel Reply

    Recent Posts
    • How to self-host n8n on Hostinger VPS
    • n8n_community_packages_allow_tool_usage: How to Configure It
    • n8n access blocked Google verification process fix
    • Unrecognized node type n8n-nodes-mcp.mcpclienttool
    • Unrecognized node type n8n-nodes-base.executecommand
    • n8n Community License Activation Error: Fix Connection Failed on npm Self-Hosting
    • Your Agent Passed the Demo. Nobody Can Explain What It Did at 3am.

    Subscribe to Updates

    Get the latest creative news from SmartMag about art & design.

    About Us

    n8n Automation Tutorial is a free resource for developers, freelancers, and business owners who want to build and deploy n8n workflows. Tutorials cover self-hosting, Docker, AWS, API integrations, and real-world automation use cases - from beginner setups to production-ready deployments.

    n8n Automation Tutorial
    • Contact Us
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    © 2026 n8n Automation Tutorial.

    Type above and press Enter to search. Press Esc to cancel.