- 01
Revoke the key
In the OpenAI platform, open the API keys page for the project the key belongs to and revoke it. If OpenAI already emailed you that the key was leaked, it has been disabled; you still need to replace it.
- 02
Create a scoped replacement
Create a new key inside a project, not at the organization level, and give it only the permissions the app needs. One key per app or environment makes the next revocation painless.
- 03
Update every place that used it
Server environment variables, CI secrets, workers, cron jobs. Search your repos for the old key's last characters and the variable name. Keys never belong in browser or mobile code; call OpenAI from your server.
- 04
Check what it cost
Open the usage dashboard, narrow it to the project and, where available, the key, and look at the window since the leak. Recent usage can take a while to appear, so check again later. Unexpected spend goes to OpenAI support.
- 05
Put a hard limit in front of the next key
Turn on a project spend limit with "Enforce a hard limit" in OpenAI. It's monthly. For a daily ceiling and a cap per key, keep the OpenAI key in Fuse and give apps Fuse keys: a leaked Fuse key can only spend what's left under its cap, and it's revoked in one click.
app.tsimport OpenAI from "openai"; const client = new OpenAI({ baseURL: process.env.FUSE_BASE_URL, apiKey: process.env.FUSE_API_KEY, });
OpenAI API key leaked? Revoke, check, and cap the next one
Updated October 2026
OpenAI keys (sk-…) that land in a public GitHub repo are often caught by GitHub's secret scanning, reported to OpenAI and disabled, and you get an email. Don't count on that: keys also leak through screenshots, logs, chat messages, front-end bundles and private repos that become public later.
Whatever the route, the steps are the same: revoke, replace, check the bill, and put a hard limit on whatever replaces it.
Questions
OpenAI emailed me that my key leaked. Is it still working?
No. That email means OpenAI disabled the key. Create a new one and update the places that used the old one.
Do I need to rewrite git history?
Revoking the key is what makes it safe. Rewriting history is optional afterwards, and on its own it doesn't help: copies may already exist.
How much can a leaked key spend?
Without a limit, as much as your account allows. With a project hard limit, up to the monthly amount. Through Fuse, up to the key's cap or what's left under the project's daily or monthly ceiling.