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.
ON THIS PAGE
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 immediately1. 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 months2.
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 support1. 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.
- Open your live app in ChromeRight-click anywhere, choose Inspect, then click the Network tab. Leave it open.
- Use your app normallyClick the button that does the AI thing. Watch the list of requests fill up.
- Look at where the requests goIf 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. - Search for the key itselfIn 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. - Check GitHub, if your tool connected oneGitHub 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 directly3. 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 necessary4.
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.
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.
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
WHERE THIS COMES FROM
- Keeping your OpenAI account secure — OpenAI Help Center
- Open Ai messages me that AI key has been leaked? — OpenAI Developer Community, 18 November 2024
- Leaked OpenAI API Key on GitHub: How to Check and Rotate — Newly
- OpenAI API Key Exposure: Risks, Recovery, and Prevention — Rafter
- OpenAI API Key Leaked (sk-...): Fix It Fast — Lictor AI
- How to Stop Your AI App From Leaking API Keys and Running Up Your Bill: A 7-Step Beginner Guide — DEV Community
