Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

OpenAI API Key (2026): How to Get One and Keep It Safe

You create an OpenAI API key on the API key page of your OpenAI platform account, and OpenAI only shows you the full secret key once, at the moment you create it. As of Nov 2026 OpenAI's own safety rules are one key per person, an expiry date on every key, and never putting a key in a browser, a mobile app or your code.

An API key is the code that lets software talk to OpenAI's models on your account's behalf. If you're not sure what the API itself is for, start with my plain-English guide to the OpenAI API. This page is only about the key: getting it, storing it and not losing control of it.

Where your OpenAI API key lives

OpenAI's Help Center keeps this simple. You create and manage keys on the API key page. For security, a full secret key is only shown when you create it. If you lose it or didn't save it, you can't get it back: you create a new key and update your application to use the new one.

Deleting is just as blunt. You select the trash can icon next to a key, and deleted keys can't be used, so any app that relies on that key may stop working. Before you delete anything, find out what's using it. OpenAI's own reminder on that page is short: don't share your API key with anyone.

Creating and storing a key, step by step

  1. Sign in to your OpenAI platform account and open the API key page. The developer quickstart says to create the key in the dashboard before you do anything else.
  2. Create a new key, and give it an expiration date if the option is there. Project keys can be created with an expiry, after which requests from that key are rejected.
  3. Copy it straight away. You won't see the full key again.
  4. Store it as an environment variable, not in a document, an email or your code. OpenAI recommends the name OPENAI_API_KEY.
  5. Check your billing. New API accounts use prepaid billing, so you buy credits before using the API, and requests start returning a billing error when the credits run out.
  6. Set a monthly spend limit with hard enforcement, so a leaked key can't run up an open-ended bill.

The variable name OpenAI recommends

OPENAI_API_KEY

On Windows, OpenAI's safety article shows a setx command in the command prompt, or the Environment Variables screen under Advanced system settings. On a Mac, you add an export line for that variable to the .zshrc file. If that sentence made your eyes glaze over, that's fine: it's a two-minute job for whoever builds your integration, and the point is that the key lives on the computer or server, never inside the code you share. Each OpenAI SDK reads the key from that variable automatically.

Five mistakes OpenAI warns about

MistakeWhat OpenAI saysDo this instead
Sharing one key around the teamSharing API keys is against the Terms of Use, and OpenAI doesn't support itInvite people from the Members page; each person gets their own key on sign-in
Keys that never expireStrongly recommends an expiry date and a regular rotation processCreate a replacement before expiry, switch your apps over, then revoke the old key
A key inside a website or mobile appMalicious users can take it and make requests on your behalf, which may mean unexpected chargesRoute requests through your own backend server
A key committed to a code repositoryA common way keys get compromised; even private repositories can leak in a data breachUse environment variables
No spend limitSpend alerts alone don't stop API trafficSet monthly spend limits and switch on hard enforcement

The website one catches small businesses most. A developer wiring up a quick chatbot on your site can drop the key into the page itself. Anyone who looks at the page source can then use it. OpenAI's rule is clear: keys belong on a backend server you control.

Keys for a team: one each, with a lifetime

The team rule is the one most small businesses break, usually by pasting one key into a shared doc. Instead, invite each person from the Members page. They get their own key when they sign in, and you can assign permissions to individual keys. When someone leaves, you revoke their key without breaking everyone else's work.

Administrators can also enforce a maximum key lifetime at organisation or project level in Platform settings, so new keys can't stay valid forever. A project's limit can't be longer than the organisation's. For supported workloads, OpenAI suggests workload identity federation, where your system swaps an identity from a trusted provider for a short-lived access token, so there's no long-lived key to steal. For production apps, it also recommends a key management service, and IP allowlisting, which rejects requests from unknown addresses even when they carry a valid key.

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

If you think a key has leaked

Don't wait. OpenAI says a compromised key gives someone access to your account quota without your consent, which can mean data loss, unexpected charges, a drained monthly quota and interrupted access. Rotate the key immediately from the API Keys page, update any apps in production with the new value, and review the Usage page to see whether the activity matches your team's work. If you belong to more than one organisation, say a company one and a personal one, make sure tracking is on and your default organisation is set, or you'll be looking at the wrong numbers. Then contact OpenAI through its Help Center.

What I'd tell a non-developer who's been handed a key

Treat it like the password to your bank's online portal, because in practice it's a card that spends your credits. I'd create a key with an expiry date and keep it out of the code, and I'd make sure it sits behind a spend limit from day one. Skip sharing one key around the team, however convenient it feels. If you're weighing up another provider, the same habits apply to a Claude API key from Anthropic, and my list of OpenAI API alternatives covers the other options.

If you're connecting an AI model to your business tools and want the keys handled safely, that's the kind of AI enablement I help with. I run AI training and workshops for teams, and help businesses with AI enablement and workflow automation, so the busywork runs itself and people get time back. Most of that work is with SaaS marketing teams and small businesses. Here's how we can work together.

Frequently asked questions

Where do I find my OpenAI API key?

On the API key page of your OpenAI platform account. You can create and manage keys there, but a full secret key is only shown once, when you create it.

I lost my OpenAI API key. Can I see it again?

No. OpenAI only shows the full key at creation. Create a new key, update your application to use it, then delete the old one.

Can my team share one OpenAI API key?

OpenAI says sharing API keys is against its Terms of Use and it doesn't support it. Invite each person from the Members page so they get their own key.

Where should I store my OpenAI API key?

In an environment variable, which OpenAI recommends naming OPENAI_API_KEY. Never in a browser, a mobile app or a code repository.

Does an OpenAI API key work without credits?

New API accounts use prepaid billing, so you buy credits before using the API. When they run out, requests return a billing error until you add more.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.