Launch offer: everything is 100% off. Download any skill free, no sign-up. Get the skills
TechFixError fixesKey leaked
Key leaked

OpenAI API key leaked: what to do right now

What you might see
# OpenAI disables keys it finds on the public internet. Calls then fail with:
401 Incorrect API key provided

# or a GitHub secret scanning alert for an OpenAI API Key
Short answer

Treat the key as stolen. Delete it on the API keys page, create a new one, put the new one only on your server, then check usage for anything you didn't do.

Why it happens

OpenAI keys are secret credentials. Anyone who has one can run requests billed to you. Bots scan public repositories and websites for them, so a key pushed to GitHub or shipped in browser JavaScript is found quickly.

OpenAI's help center says that when it detects a key on the public internet, the key is disabled immediately. That stops the abuse but also breaks your app until you replace it. Deleting the key from your code doesn't help on its own: copies live on in git history, forks and caches.

Fix it by hand

  1. Delete the leaked key. Open the API keys page in the OpenAI platform (platform.openai.com/settings/organization/api-keys), find the key by its name and redacted value, and delete it. Do this even if OpenAI already disabled it.
  2. Create a replacement in the right project. Where you can, choose Restricted or Read Only permissions instead of All, and use a service account key for servers and CI.
  3. Update it everywhere: your host's environment variables, CI secrets and local .env files. Redeploy so running services pick it up.
  4. Check usage. Open the Usage page and filter by project and API key for the time since the leak. If you see activity you didn't do, contact OpenAI support through help.openai.com.
  5. Fix how it leaked. If the key was in browser code (a NEXT_PUBLIC_ or VITE_ variable, or a direct call from the frontend), move the OpenAI call to a server route. OpenAI says never to deploy keys in browsers or mobile apps. If it was committed, see removing .env from git history, after rotating.
  6. Set a hard spend limit on the project so the next leak can't run up an open-ended bill. Spend alerts alone don't stop traffic.

Stop it happening again

Let TechFix do this for you

Key Leaked $7

Paste the alert or say "I leaked my OpenAI key". Key Leaked finds every copy of the key in your files, git history and browser bundles, gives OpenAI's revoke-and-replace steps in order, writes the code change that moves the call to your server, and lists the other secrets waiting in the same repo.

  • Finds every secret in your files, every commit on every branch, and the JavaScript you ship to browsers.
  • Gives exact revoke-and-replace steps for 19 providers, and never prints your full secrets.
  • Verdict first. Every finding shows the file and line, what it breaks, and the fix as a diff that is applied only with your OK.

Key Leaked: how it works, with examples · Install guide

Works with Claude Code, Claude.ai, Cursor, Codex and other agents that read SKILL.md files. No installs, no accounts, works offline. No-questions refund.

Sources (checked 2026-10-13)