Unexpected OpenAI API charges
What you'll see once a hard limit is on429 project_spend_limit_exceeded
429 organization_spend_limit_exceeded
Turn on a hard spend limit now so it can't get worse, then use the Usage page to find which key and project spiked. It is usually a leaked key, a public endpoint with no limits, or a loop.
Why it happens
OpenAI bills per token. Three things usually cause a sudden jump:
- A leaked key being used by someone else.
- A public endpoint (say
/api/chat) that calls OpenAI with no login, no rate limit and no output limit, found by bots. - Your own code calling the API in a loop: retries without a cap, a frontend effect that re-runs, or a background job that never stops.
Spend alerts only send an email; OpenAI says traffic continues. Only a hard limit makes requests fail with a 429 once the limit is reached.
Fix it by hand
- Stop the bleeding. Open Project settings, then Limits. In Spend, choose Edit spend limit, enter a monthly amount, and turn on Enforce a hard limit. Do the same under Organization limits. OpenAI notes enforcement isn't instant, so spend can slightly exceed the amount.
- Find the spike. Open the Usage page and filter by project and API key. Note which key, model and day the jump came from.
- If the key or traffic isn't yours, treat it as a leak. Rotate the key now: see OpenAI API key leaked.
- If it's your code, find every place that calls OpenAI. For each one exposed to the internet, require a logged-in user, add a per-user rate limit, and set an output cap on every request (
max_output_tokensin the Responses API). - Look for loops. Retries need a maximum count and backoff. Frontend code must not call the API on every render. Background jobs need a stop condition.
- Contact OpenAI support through
help.openai.comif the usage came from someone else.
Stop it happening again
- Keep a hard spend limit on every project, set just above what you expect to spend.
- Use separate projects and keys for development and production.
- Never call OpenAI from the browser. Every call goes through your server, behind login and a rate limit.
- Give each key the narrowest permissions it needs.
Bill Spiked $7
Bill Spiked finds the uncapped calls, open endpoints and loops in your code, ranked by how much damage each could do, adds the limits as diffs you approve, and gives OpenAI's spend-cap checklist. Paste a usage export and it maps the spike to the code that caused it.
- Finds the uncapped calls, loops and open endpoints that run up a bill, ranked by how much damage each can do.
- Adds the limits as diffs you approve, and gives a spending-cap checklist for each paid provider in your code.
- 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.
Bill Spiked: 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.