Guides
Sign in

Guide · Leaked keys and files

Your OpenAI, Anthropic or OpenRouter key leaked: what to do now

Delete the key in the provider’s dashboard first, before you touch your code. Taking it out of your code doesn’t help on its own: anyone who already copied it can keep using it, on your bill, until the key itself is gone.

Which key is it?

OpenAIsk-proj-…, sk-svcacct-…Server only
Anthropicsk-ant-…Server only
OpenRoutersk-or-v1-…Server only

Our checker looks for keys that start like these. Whoever holds one can call the models as you, and every call is billed to your account. None of them belongs in a browser. OpenAI says never to put a key in browsers or mobile apps (OpenAI), and Anthropic points out that anyone who uses a web page can read a key in its code (Anthropic).

AI services charge per use, so a leaked key turns into someone else’s usage on your card. A small family tire shop reported a $14,000 bill from a Google key that could call Gemini (Google AI forum). If yours is a Google key that starts with AIza, read Is your public Google API key unrestricted? instead. If your app calls Gemini with that key, treat it like any other leaked AI key: change the key (rotate it) and move the call to a server function.

Do this now, in this order

  1. Delete the key in the provider’s dashboard (where, below). Anthropic also offers Disable, which can be undone. For a leaked key, delete it.
  2. Look at the usage since the key leaked. If you see spending you didn’t make, write to the provider’s support with the dates. OpenAI asks you to do this for a compromised key (OpenAI).
  3. Set a hard spend limit, so a future leak stops at a number you chose. An alert only tells you. A hard limit stops the requests.
  4. Make a new key and put it only in your server’s settings: your host’s environment variables or your edge functions’ secrets. Never put it in a variable whose name starts with VITE_ or NEXT_PUBLIC_, as those are copied into the browser code on purpose (Vite docs).
  5. Move every call to the model into a server function, so the browser asks your server and your server asks the AI. Here’s the same prompt our checker gives you:

Prompt for Lovable, Bolt, Cursor or Claude Code

Secret keys are visible in my app’s public JavaScript. 1) Find every place in my code that uses a secret key in the browser. 2) Move each call that needs a secret into a server-side function (an API route or edge function) so the browser never sees the key. 3) Remind me to rotate each exposed key in its provider’s dashboard, because removing it from the code doesn’t un-leak it.

If the key was ever committed to a repository, it stays in the history even after you remove it. So deleting the key is what makes that copy harmless.

Where each provider keeps these settings

OpenAI. Delete the key on the API keys page of your organization settings (platform.openai.com). The Usage page shows usage by key, but keys made before 20 December 2023 show as untracked unless you turn tracking on (OpenAI). To cap spending, set a spend limit for the organization or a project and turn on “Enforce a hard limit”. Spend alerts alone don’t stop anything, and a hard limit can run slightly over before it takes effect (OpenAI).

Anthropic. In the Console, open API keys, then the menu next to the key, and Delete API key (Anthropic). Check the Usage and Logs pages for calls you didn’t make. Set a spend limit for the organization on the Billing page, or for a workspace under Workspaces, and once it’s reached, requests are refused (Anthropic, workspaces).

OpenRouter. Delete the key under Settings › Keys (OpenRouter). The Activity page can be filtered by API key and shows its spend, requests and tokens (OpenRouter). Give each key a credit limit, and once it’s used up, that key’s requests are refused (OpenRouter).

Did the provider already turn it off?

Maybe. OpenAI says it disables a key immediately when it finds one on the public internet or inside an app in an app store (OpenAI). When GitHub finds an Anthropic key in a public repository, Anthropic deactivates it and emails you (Anthropic). OpenRouter takes part in GitHub’s secret scanning and emails you if a key is compromised (OpenRouter).

Check your inbox for that email, but don’t wait for it. These catch the keys their scanners happen to find, so delete the key yourself.

Stop it happening again

  • Keep AI keys on your server only. The browser calls your server, never the AI provider.
  • Use a separate key for each app or feature, so you can see which one leaked and delete just that one. OpenAI recommends separate keys for this reason (OpenAI).
  • Keep a hard spend limit on, and on OpenRouter a credit limit on every key.
  • Check your live app after each deploy: a new feature can bring a key back into the browser code.

What this can’t tell you

We read the JavaScript your page loads, up to five of your own files, and look for the key beginnings above. We can’t see keys in files that only load after sign-in, in your server code or in your repository’s history. We never use a key we find, so we can’t tell if it still works. Delete it either way. A clean result means the public code we read has no secret keys, not that there are none anywhere.

Related

Sources

Provider pages read on 10 November 2026. Menus move; if a name differs, look for API keys, Usage and Limits.