What to do when an AI tool exposes your provider keys
By Flavio
Updated
Tagged: AI
Respond to exposed AI provider keys: revoke the credentials at their source, inspect usage, replace shared access, and distinguish alerts from hard limits.
Say you pasted an API key into an AI tool so it could call a model for you, and now you’re staring at a notice saying someone got unauthorized access to their stored credentials.
Your first instinct might be to open that tool’s settings and delete the key. That won’t help if someone already copied it. The key lives with the model provider, so that’s where you have to revoke it. Start by reading the vendor’s notice to pin down the affected product and time window, because a local client and a hosted account often store credentials in completely different places.
Find the credential’s actual owner
One thing that trips people up with AI apps is how many accounts end up tangled together. You might sign in through GitHub, pay the app for a subscription, and separately paste in your own Anthropic key.
Each of those connections unlocks something different. Changing your GitHub password won’t touch your Anthropic key, and cancelling your subscription to the app won’t stop requests from hitting your model-provider bill.
Before you jump into dashboards, I recommend jotting down a quick inventory so nothing slips through the cracks:
| Item | What to record |
|---|---|
| Vendor connection | Which workspace or hosted product got the key |
| Issuing provider | OpenAI, Anthropic, Google, or another issuer |
| Credential identity | Key name or ID, never the secret itself |
| Scope | Project, workspace, account, and any restrictions |
| Other users | Apps or teammates sharing that same key |
Stick to names and IDs in your incident note. Keep the secret itself out of your notes, screenshots, and support messages.
If you aren’t sure which key you gave the tool, compare its connected accounts against your provider’s key list. A key named after the tool gives you the answer right away, while a shared key called default leaves you guessing.
Revoke at the provider
Go straight to the provider’s controls and disable or delete the affected key, replace it in the apps that still need access, and confirm the old one is inactive.
Don’t leave the exposed key running while you work through a slow migration. Whoever copied it can keep using it the whole time. I’d much rather live with a broken integration for a bit than leave a leaked key open.
You can handle all of this in each provider’s web dashboard, though if you have an admin key, the APIs are faster when you need to check every key at once.
Anthropic
In the Claude Console, you can disable or delete keys through workspace key management. If you’re on an organization account, you can also use the Admin API with an Admin API key (the ones starting with sk-ant-admin, which only org admins can create), an OAuth token with the org:admin scope, or an organization-wide personal or service-account key. Individual accounts don’t get access to it.
Here’s how you list the active keys in a workspace:
curl "https://api.anthropic.com/v1/organizations/api_keys?limit=10&status=active&workspace_id=wrkspc_01JwQvzr7rXLA5AGx3HKfFUJ" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21"
Make sure ANTHROPIC_API_KEY holds your admin key here instead of a regular one. Each entry in the response includes an id like apikey_..., a name, its scope, and expires_at.
Once you have the right ID, set its status to inactive to shut it down:
curl "https://api.anthropic.com/v1/organizations/api_keys/apikey_01Rj2N8SVvo6BePZj99NhmiT" \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2026-10-21" \
-H "content-type: application/json" \
-d '{
"status": "inactive"
}'
The Admin API lets you read, rename, and change the status of keys, though it can’t create new ones. You’ll need to head into the Console to generate the replacement.
OpenAI
With OpenAI, keys belong to a project. You can pull a project’s keys through the Admin API using an admin key:
curl https://api.openai.com/v1/organization/projects/$PROJECT_ID/api_keys \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"
Every key comes back with its id, name, redacted_value, owner, created_at, and last_used_at. The masked value shows you which key the tool had, and last_used_at tells you whether anyone kept calling the API after you stopped the tool.
Once you spot the ID, delete the key:
curl -X DELETE https://api.openai.com/v1/organization/projects/$PROJECT_ID/api_keys/key_abc \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
-H "Content-Type: application/json"
If it belonged to a service account, deleting that key leaves the service account and its other keys in place.
If you’re on Gemini, Google’s API key guide covers key management and restrictions.
Watch out for a second layer if the app also had its own access token for a gateway. Revoking that token cuts off calls through the gateway, but it won’t invalidate an upstream provider key that someone copied separately. Check both layers whenever both were involved.
Inspect usage without delaying containment
As soon as the key is revoked, look through your usage logs for anything outside your normal pattern. Line up the provider’s records with the times your app was running, and break things down by project, key, or model if you can.
Don’t stop at request counts. A few huge prompts can cost way more than lots of small ones, so check token usage and total spend too. Keep reporting delays in mind before deciding the incident is over, since dashboards often lag behind live traffic.
Save the time window and any suspicious request IDs, then contact the provider through its official support channel. Lay out what you saw and what you revoked, and wait for their answer before assuming you’ll get a refund.
If the provider has an audit log, check it for changes to the account itself. An admin credential reaches much further than a regular model key, so trace everything the exposed key had permission to touch.
On a team, put one person in charge of the inventory. Otherwise it’s easy for two people to each think the other already rotated a shared key.
Give each integration its own access
When you reconnect, create a key just for that tool and environment, with separate keys for a test project and production. That way you can cut off an experiment without breaking production, and a usage spike points straight to one place. Name the key after the tool too, so the list commands from earlier tell you what it’s for right away.
Turn on the restrictions the provider gives you. Google lets you restrict a key to the Gemini API, Anthropic keys can be bound to one workspace, and OpenAI keys to one project. A restriction limits which resources a key can reach, but it can still burn through a lot of money inside them, so test it with a harmless request before you rely on it.
Never hand an ordinary coding integration an admin key just because it works.
Check what a budget setting actually does
A dashboard can show a monthly budget and still keep accepting requests right past it.
In OpenAI’s rate-limit and spend guide, spend alerts and enforced limits are two different things. An alert sends a notification and leaves the API running. Request and token rate limits control how fast calls can go through on their own, and the token rate calculator shows you which of those two ceilings you’ll hit first.
For every provider you use, check what the setting you turned on does: an alert, a request-rate limit, or a hard spend cutoff, along with its scope and how fast it takes effect. Even a hard cutoff can lag behind in-flight requests or delayed accounting. Route the alert to someone who can act, and make sure they know which key to deactivate.
A broker changes where authority lives
Putting a gateway in front keeps your upstream key away from a coding client. The client gets a narrower credential for the gateway, and the gateway calls the provider on its behalf.
That gives you one place to manage rules and shut off access, while also giving the gateway the power to spend on your upstream account. Check what its client credentials can request, and check whether anyone can bypass it with a direct key.
A secret manager controls who can fetch a secret, but once a process grabs it, that process holds a copy. Keeping the raw key inside a broker lets your tools make model calls without spreading extra copies around.
My advice before you reconnect a hosted integration is to test the failure once on purpose. Find the new key by name in the list, deactivate a test key, and confirm that only the tool you meant to cut off loses access.
Want me to talk about your product? You can sponsor this site.
Related posts about ai: