---
title: "Someone found your API key and ran up a bill"
description: "A charge you didn't make on your OpenAI account? Delete the key first, then find where it leaked and get your app working again."
url: https://www.fomio.ai/blog/someone-found-your-api-key-and-ran-up-a-bill
published: 2026-11-07T19:00:00.602+00:00
updated: 2026-11-07T19:00:00.602+00:00
topic: consequence
words: 2098
---

# Someone found your API key and ran up a bill

The bleeding stops in about four minutes — here's that part first, and the quieter problem it leaves behind.

**In short:**

- Delete the exposed key at OpenAI before you do anything else — that single action stops the spending.
- Make a new key, but don't paste it back into the same place the old one lived.
- Most leaks in apps built with Lovable, Bolt, v0 or Replit happen because the key ended up in the half of the app that every visitor downloads.
- Once the key is dead, your live app is quietly broken for real users and will not tell you.

### What should I do first if my OpenAI API key was leaked?

Delete the key itself at platform.openai.com/api-keys — not the app, not your password. The moment it's deleted, whoever has a copy is holding a dead string and the charges stop. Then create a new key, check your usage page for when the strange spending began, and contact OpenAI support the same day.

You opened your email and there was a charge you didn't make. Or a message saying your key was disabled. Or your usage graph has a cliff in it at 3am on a Tuesday, when you were asleep and your app had eleven users.

Nothing is on fire. The money that's gone is gone, and we'll get to that. But the bleeding stops in about four minutes, and it's worth doing that part first and reading the rest after.

## How do I stop the charges right now?

Delete the key. An API key is just a password your app hands to OpenAI to prove the charges belong to you. It isn't tied to a device or a person — anyone holding that string of characters can spend your money, and OpenAI has no way to tell them apart from you.

So go to your API keys page and delete that specific key. Not disable the app, not change your account password. The second it's gone, the bill stops growing.

Then make a new one and don't put it anywhere yet. Leave it in a note on your desk for ten minutes. If you paste it straight back into the same place the old one was, you've just handed the same person a fresh one. Some people find this out twice.

There's a chance OpenAI already did this for you. Their security guidance says that when they spot a key out on the public internet, or inside an app published to an app store, they switch it off immediately[^1]. If you got an email saying your key was leaked and has been disabled with immediate effect, that's what that is. People have been receiving that email for years, sometimes several times in a few months[^2].

> **Why this gets expensive so fast** — These keys can't be limited. You can't make one that's only allowed to spend ten dollars, or only allowed to use the cheap model. A copy has exactly as much power as the original and doesn't expire on its own. It works until somebody deletes it.

## Can I get the money back?

Open your usage page and look at the shape of it. You want two things: when the spending started, and whether it's still happening. If the line is flat after the moment you deleted the key, you've stopped leaking and you're just counting. Write down the date and time the unusual usage began.

Then contact OpenAI support and say it plainly: my key was exposed, here is when the usage I didn't authorise started, I have deleted the key. OpenAI's own guidance tells you to do exactly this — delete your keys, review usage for unexpected activity, and contact support[^1]. Do it the same day, while the timeline is clean.

I'm not going to promise you a refund. People ask constantly on OpenAI's developer forum and the outcomes are not consistent. Ask anyway — it costs you one message — but plan as if the answer is no, so a yes is a nice surprise rather than the thing holding your week together. If the amount is large and it went on a card, your card issuer is a separate conversation you're allowed to have.

## Where did my key actually get out?

For apps built with Lovable, Bolt, v0, Replit and the rest, one cause dwarfs the others, and it isn't carelessness. These tools will happily write working code that puts the key in the wrong half of your app.

Your app has two halves. One runs on a server somewhere and nobody can see inside it. The other gets downloaded into the browser of every single person who visits — images, buttons, text, and any code that came with them. All of it is readable by anyone who looks, because their browser has to run it.

If your key ended up in that second half, it was never hidden. It was published. People run automated scanners looking for exactly this, which is why the charges often start within hours of a deploy and come from somewhere you've never been.

1. **Open your live app in Chrome** — Right-click anywhere, choose Inspect, then click the Network tab. Leave it open.
2. **Use your app normally** — Click the button that does the AI thing. Watch the list of requests fill up.
3. **Look at where the requests go** — If you see requests going straight to `api.openai.com`, your key is in the browser — there's no other way those requests could be signed. If everything goes to your own domain instead, that's the good sign.
4. **Search for the key itself** — In that same panel, press Ctrl-F and search for `sk-`. That's how OpenAI keys start. If you find one, you've found the leak — and so did everyone else.
5. **Check GitHub, if your tool connected one** — GitHub scans public repositories for known key formats across the whole history of a project, not just the current version, and reports hits for OpenAI keys directly[^3]. It also blocks pushes containing detected secrets to public repos by default — though anyone can override that block by giving a reason, a button many people have clicked in a hurry.

One thing that trips people up: deleting the key out of a file doesn't remove it from the project's history. The old version is still sitting there. That's exactly why you kill the key at OpenAI rather than editing your code — once the secret is dead, rewriting history often isn't necessary[^4].

## How do I put the new key somewhere it can't be read?

Move the call to OpenAI out of the browser and onto a server, so the key never leaves a machine you control. Your app's front end asks your server, your server asks OpenAI, the key stays home.

You don't have to build that by hand. Tell the tool you built the app with what you need, in roughly these words.

**Paste this into your AI tool**

```text
My OpenAI API key is currently exposed in the client-side code. Move all OpenAI calls to a server-side function. Store the key as a server secret, not in any file that ships to the browser, and not in any variable the front end can read. Then show me every place the old key appears so I can confirm it's gone.
```

If your app uses Supabase — most Lovable and Bolt apps do — the specific shape of this is a Supabase Edge Function with the key stored as a Supabase secret. Mention that in the prompt and you'll get a better answer.

While you're in your OpenAI billing settings, find the spending limit and set one. A number that would annoy you but not hurt you. It won't stop a leak, but it turns an open tap into a puddle.

## Why is my app still broken after I deleted the key?

Because your live app was using that key, and every feature that depended on it is failing for real users right now. Deleting the key was the right move; it also pulled the plug on the working half of your product.

It won't look broken. The page loads. The button is there. Someone types something, waits, and gets a spinner that never stops or an error they don't understand. They won't email you. They'll leave, and you'll find out in a week when you happen to use your own app.

> **The quiet week** — This is the genuinely nasty part of a key incident. There's the hour of panic, and then there's the week afterwards where the app is half-dead and nobody says anything.

So the last step is to have something watching the app other than you. Something that checks the live site on a schedule and tells you when it stops behaving — not when the server catches fire, which is rare, but when the app is up and the thing it does has quietly stopped working, which is what this kind of incident actually leaves behind.

That's what we built Fomio for. You paste in a link to your app and it works out what to watch; there's nothing to set up. It checks from outside, the way a real visitor would, and reports one of three things: Working, Having trouble, or Down. When something breaks it tells you in plain English what likely went wrong, and on the paid plans it writes the prompt for you to paste straight into Lovable or Replit or whatever you built with.

The free plan watches one app, checks every five minutes, emails you when it breaks and keeps seven days of history, with no card needed. Builder covers three apps, checks every minute and includes the fix prompts. Pro goes to fifteen apps, a year of history, and a public status page your users can look at themselves. Current prices are at fomio.ai/pricing. Alerts come by email — that's the only way it contacts you today, so if you need a phone buzzing at 2am, that's not us yet.

## What should I do in the next ten minutes?

Delete the key. Make a new one and don't paste it anywhere yet. Check your usage page and write down when the strange spending started. Message OpenAI support today.

Then open your live app, Inspect, Network, and see whether requests are going straight to OpenAI. Get the key onto a server using the prompt above, set a spending limit, and put something in place to tell you when the app stops working. Next time, finding out in four minutes instead of four days is the entire difference.

## Questions people also ask


### Can I just change the key instead of deleting it?

No — creating a new key doesn't switch the old one off. Both keep working until you explicitly delete the old one, and the copy someone else is holding will carry on spending. Delete first, create second. The same goes for changing your account password: it protects your login, but it does nothing to a key that's already out in the world, because a key doesn't need your password to work.

### Will OpenAI disable a leaked key automatically?

Sometimes. OpenAI says that when it detects a key published on the public internet or shipped inside an app in an app store, it disables that key immediately and emails the account owner. That's a safety net, not a plan — detection isn't instant and a leak that never touches a public page may not be spotted at all. Treat an automatic disable as confirmation you have a problem, then do the rest of the cleanup yourself.

### How do I know whether the key is in the browser half of my app?

Open your live app in Chrome, right-click and choose Inspect, then open the Network tab and use the app as a visitor would. If you see requests going directly to api.openai.com, the key is in the browser. If every request goes to your own domain, the call is happening on a server. As a second check, press Ctrl-F in that panel and search for sk-, which is how OpenAI keys begin.

### Does deleting the key from my code fix the GitHub leak?

Not by itself. A project's history keeps the old versions of every file, so the key is still readable to anyone who looks back through it, and scanners do exactly that. The useful move is to kill the key at OpenAI, which makes the copy in history worthless. Once the secret is dead, going back and rewriting the project history often isn't necessary — the thing it exposed no longer works.

### Will a spending limit protect me next time?

It caps the damage rather than preventing it. Keys themselves can't be restricted — you can't issue one that's only allowed to spend a small amount or use a cheaper model — so an account-level limit is the main brake available to you. Set it to a number that would annoy you but not hurt you. Pair it with checking your usage page occasionally, because a limit tells you nothing until it's already been hit.


## Sources

[^1]: Keeping your OpenAI account secure — OpenAI Help Center. https://help.openai.com/en/articles/8304786-how-can-i-keep-my-openai-accounts-secure
[^2]: Open Ai messages me that AI key has been leaked? — OpenAI Developer Community (2024-11-18). https://community.openai.com/t/open-ai-messages-me-that-ai-key-has-been-leaked/1022084
[^3]: Leaked OpenAI API Key on GitHub: How to Check and Rotate — Newly. https://newly.app/security/ai-service-api-keys-leaked-openai-key-github
[^4]: OpenAI API Key Exposure: Risks, Recovery, and Prevention — Rafter. https://rafter.so/blog/secrets/openai-api-key-exposure
[^5]: OpenAI API Key Leaked (sk-...): Fix It Fast — Lictor AI. https://lictor-ai.com/openai-api-key-leaked/
[^6]: How to Stop Your AI App From Leaking API Keys and Running Up Your Bill: A 7-Step Beginner Guide — DEV Community. https://dev.to/siteory/how-to-stop-your-ai-app-from-leaking-api-keys-and-running-up-your-bill-a-7-step-beginner-guide-3hie
