OpenAI and Anthropic API Keys: What They Are and How to Get One

If you’re setting up an AI agent, connecting ChatGPT to n8n, building an automation in Make, or integrating Claude into your own application, you’ll quickly run into the term API key. For many beginners, this is the first confusing step.

What exactly is an API key? Why do you need one? Is it free? And where do you actually get it?

This guide answers all of those questions and walks you through creating API keys for both OpenAI and Anthropic.

An API key is a unique secret code that allows applications to securely communicate with AI services such as OpenAI and Anthropic on your behalf. Without it, tools like n8n, Make, or custom applications cannot access AI models through their APIs.

If you’re new to AI automation, you may also want to read our guide What Is an AI Agent? before continuing. It explains the basic concepts you’ll need to understand when building AI-powered workflows.

What Is an API Key?

An API key is a unique authentication token issued by a service provider. It identifies your account whenever an application sends requests to an API.

Think of it as a secure digital key. Instead of logging in every time an application needs to communicate with an AI model, it uses your API key to prove that the request is authorized.

When your workflow in n8n sends a prompt to GPT-4.1 or Claude, the AI platform first verifies your API key. If the key is valid, the request is processed. If it isn’t, the request is rejected.

Without a valid API key, most AI integrations simply won’t work.

When Do You Need an API Key?

If you only use ChatGPT or Claude through their official websites, you usually don’t need an API key.

You do need one when you want to:

  • build AI agents in n8n;
  • create automations with Make;
  • connect AI models to your own software;
  • develop AI-powered websites or mobile apps;
  • build Telegram, Slack, or Discord bots;
  • process documents automatically with AI;
  • integrate AI into third-party services.

In short, whenever software needs to communicate directly with an AI model, an API key is required.

Planning to build your first workflow? Continue with our step-by-step tutorial Build an AI News Workflow in n8n with OpenAI.

Is an API Key Free?

Creating an API key is free for both OpenAI and Anthropic.

However, using the API is generally billed separately. You’re charged for the requests your applications send to the AI models, not for generating the key itself.

Before building your first project, check the current API pricing on the official website of the provider you’re using.

How to Create an OpenAI API Key

  1. Sign in to your OpenAI account.
  2. Open the API Platform.
  3. Go to the API Keys page.
  4. Click Create new secret key.
  5. Optionally give the key a descriptive name.
  6. Click Create secret key.
  7. Copy the key immediately and store it somewhere safe.

Important: OpenAI only displays the secret key once. If you close the dialog without saving it, you’ll need to generate a new key.

 

API Keys pageCreate new secret key dialog

How to Create an Anthropic API Key

  1. Sign in to your Anthropic account.
  2. Open the Anthropic Console.
  3. Navigate to API Keys.
  4. Click Create Key.
  5. Enter a name for your key.
  6. Create the key.
  7. Copy and securely save it.

Just like OpenAI, Anthropic only shows the secret key once after it has been generated.

 

Anthropic page

Anthropic API Keys page

Create Key window

Where Should You Store Your API Key?

Your API key should be treated like a password. Anyone who has access to it can make API requests using your account, which could result in unexpected charges or unauthorized access to your projects.

The safest places to store an API key include:

  • the built-in Credentials manager in n8n;
  • a trusted password manager such as 1Password, Bitwarden, or KeePass;
  • environment variables for your applications or servers.

Avoid storing API keys in:

  • plain text files on your computer;
  • Google Docs or shared notes;
  • email conversations or messaging apps;
  • public GitHub repositories;
  • screenshots that may later be shared online.

If you ever believe your API key has been exposed, revoke it immediately and generate a new one.

How to Use Your API Key in n8n

Once you’ve created an API key, you only need to configure it once inside n8n.

  1. Open a node that uses OpenAI or Anthropic.
  2. Click Create New Credential (or Add Credential).
  3. Paste your API key into the authentication field.
  4. Save the credential.

From that point on, every workflow using that credential can securely communicate with the AI service without asking for the key again.

 

Creating credentials in n8n

After adding your credentials, you can start building intelligent automations. Our n8n AI Workflow tutorial walks you through the entire process from start to finish.

Common Mistakes

Closing the window before copying the key

Both OpenAI and Anthropic display a newly generated secret key only once. If you close the dialog without saving it, you won’t be able to view it again. Simply generate a new key and replace the old one.

Using the wrong API key

An OpenAI API key only works with OpenAI services, while an Anthropic API key only works with Anthropic services. They cannot be used interchangeably.

Authentication errors

If your application reports an authentication error, double-check that the key was copied correctly. Even an extra space at the beginning or end of the key can cause authentication to fail.

Billing or quota issues

If your API key is valid but requests still fail, check your API billing settings, usage limits, and available credits in your account dashboard.

Frequently Asked Questions

Do I need ChatGPT Plus to use the OpenAI API?

No. ChatGPT Plus and the OpenAI API are separate products with separate billing. Having a ChatGPT Plus subscription does not automatically include API usage.

Can I create multiple API keys?

Yes. Creating separate API keys for different applications or projects is considered a best practice because it makes access management much easier.

Can I delete an API key?

Absolutely. Both OpenAI and Anthropic allow you to revoke or delete API keys at any time. Applications using that key will stop working until a new one is configured.

Can I share my API key?

No. API keys should always remain private. Anyone with your key can make requests using your account, potentially generating unexpected costs.

Do I need an API key to use ChatGPT or Claude in a web browser?

No. If you’re using the official ChatGPT or Claude websites, you don’t need an API key. API keys are only required when applications or automation tools connect directly to AI models.

Final Thoughts

An API key is the foundation of almost every AI integration. It allows applications to securely communicate with models from OpenAI and Anthropic while identifying your account.

Creating an API key only takes a few minutes, but it unlocks powerful possibilities—from building AI agents in n8n to creating your own AI-powered applications and automations.

Once your API key is ready, you’re ready to build your first AI-powered workflow. If you’re just getting started, continue with our Build an AI News Workflow in n8n with OpenAI. You may also find our guides What Is an AI Agent? and How to Use ChatGPT Agent helpful as you continue learning AI automation.

Leave a Comment

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

Scroll to Top