Skip to content

What does 'We have determined that your OpenAI API key was leaked' mean?

Short answer

OpenAI found your key somewhere public, usually a GitHub repo or a website's JavaScript, and disabled it immediately. The key won't work again. Create a new one, keep it server-side, check Usage for spend you didn't make, and remove the old key from the code and git history so the replacement doesn't leak the same way.

Last updated 2026-11-25 · Reviewed by ProofForge

The exact error

text
We have determined that your OpenAI API key "<name>" (sk-pro…XXXX) was leaked, and have disabled it with immediate effect.

Why it happens

  • The key was committed to a public repository.
  • The key was bundled into frontend code (a VITE_ / NEXT_PUBLIC_ variable or a hard-coded string) on a live site.
  • It was pasted into a public gist, issue, notebook or forum post.

How to fix it

  1. Find the leak: search your repo history and your deployed JS for the key's last 4 characters.
  2. Create a new key at platform.openai.com/api-keys and put it in a server-side env var.
  3. Move every OpenAI call behind your own backend route.
  4. Remove the old key from git history (or make the repo private and rewrite it). It's disabled, but the habit leaks the next key.
  5. Check Usage for spend you didn't make, and set a project spend limit.
bash
# find the old key in history (use its last 4 chars)
git log -p --all | grep -n "XXXX"
# find it in your production bundle
grep -rn "sk-" dist/ .next/static/ 2>/dev/null

Check it's fixed

Run a ProofForge scan on the live URL. It should find no OpenAI-style key in your JavaScript or source maps.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

FAQ

Can I re-enable the key?

No. Create a new one.

Will I be charged for what the leaker used?

Contact OpenAI support through help.openai.com with the details. Rotating fast and having spend limits limits the damage.

Where do leaked keys usually come from?

Public GitHub commits and production JavaScript. Both are scanned constantly, by providers and by attackers.

Sources

Related

Read as Markdown · Scan methodology