Skip to content

Security and governanceGuide

Leaked OpenAI API key? What to do in the first hour

An exposed OpenAI key is a bearer credential: whoever holds a copy can bill your organization until the key is gone. This runbook puts the first hour in order, with the dashboard pages and API endpoints OpenAI documents for each step.

By INFRO Editorial

Published

8 min read

An amber key inside a glowing glass hexagon on a dark ground, ringed by dashed orbits and small glass nodes

In short

If an OpenAI API key is leaked, delete it on the API keys page first, then find which project it belonged to and what permissions it had, review usage for that key in the Usage Dashboard or the Usage API, replace it everywhere it was deployed, set project spend limits and an IP allowlist, check whether an Admin API key was exposed too, and contact OpenAI Support with the details. OpenAI disables keys it detects on the public internet, but do not rely on that.

Key takeaways

  • Delete the key first: OpenAI's guidance for a compromised key is to delete it in the API key dashboard, review usage and contact support.
  • Find the blast radius from the key's project and permissions, then read usage for that key alone, in UTC, at a fine interval.
  • Replace the key everywhere it lived: secret managers, CI, environment files, laptops and every third-party tool that held a copy.
  • Set a project hard spend limit and an IP allowlist so the next leaked key is worth less; hard limits return 429 and are not instantaneous.
  • Treat a leaked Admin API key as a separate, worse incident: it can create and delete keys, projects and users.

Leaked OpenAI API key — what to do? Delete the key on the API keys page now, before you investigate anything else. Then work out which project it belonged to and what it could reach, read the usage for that key alone, replace it everywhere it was deployed, put a project spend limit and an IP allowlist in place, check whether an Admin API key leaked with it, and contact OpenAI Support. OpenAI's own guidance for a compromised key is short: delete it, review your usage and keep the details, contact support1.

An OpenAI key is a bearer credential. Anyone holding a copy can bill your organization until the key stops working, and nothing about the request tells OpenAI it is not you. The rest of this runbook is the first hour in order, with the dashboard pages and endpoints OpenAI documents for each step.

The first hour at a glance

WhenStepWhere
Minute 0–5Delete the exposed keyAPI keys page in the OpenAI dashboard
5–15Identify the key's project, owner and permissionsAPI keys page, project settings
15–30Read usage for that key and projectUsage Dashboard, Usage API
15–45Deploy a replacement everywhere the old key livedYour secret manager, CI, hosts, tools
30–50Set a project hard limit, alerts and an IP allowlistLimits page, Settings → Security
45–60Check admin keys and the audit log; contact supportAdmin keys page, Audit Logs API, Help Center

Steps overlap. The order that matters is the first one: nothing else waits for the investigation.

1. Delete the key

Delete the affected key through the API key dashboard1. Do it even if you are not sure it was used: a key you are unsure about has to be replaced anyway, and every minute it exists it can be spent.

Two things to know:

  • OpenAI may already have disabled it. OpenAI says that "When OpenAI detects an API key on the public internet, or leaked inside an app in an app store, the API key is disabled immediately"1. GitHub's secret scanning lists OpenAI API keys as a partner pattern, so a key pushed to a public GitHub repository is reported to OpenAI2. A key that leaked privately, through a breached third-party tool, a log file or a shared laptop, is not covered by either, so check the key's status yourself.
  • Revoking first means downtime for whatever used the key. For routine rotation OpenAI recommends creating the replacement, updating applications and revoking the old key once the new one works3. For a key you believe is in someone else's hands, the order flips: revoke, then restore service. If an outage is unacceptable, create the replacement in the same minute and deploy it as fast as you can, but do not leave the old key alive while you do.

2. Find which key, which project, what it could reach

Write down the key's name, its project, who created it and when it was last used. A project key belongs to one project, so the project tells you which traffic, limits and members the key shares.

Then check the key's permissions. A user-owned key can be All (the default), Restricted to chosen endpoints with None, Read or Write per resource, or Read Only; service account keys are created by users with service-account management permissions, typically organization or project owners4. A key with All permissions could do more than run models in that project: it could read or write the project's other resources, such as files and stored assistants. Record that, because it decides what else you have to review.

3. Check the usage

Open the Usage Dashboard. You need to be an organization owner or hold the Usage Dashboard permission. It has its own project selector, independent of the project selected elsewhere in the platform, and its data is in UTC, which matters when you compare it with your own logs. Usage detail pages accept a 1-minute interval for tokens per minute5.

For a per-key view, the organization Usage API (GET /organization/usage/completions) accepts group_by values including api_key_id and project_id, with bucket_width of 1m, 1h or 1d; the reference examples call it with an Admin API key6.

Usage by project, key and model, by hour
curl "https://api.openai.com/v1/organization/usage/completions?start_time=$START_UNIX&bucket_width=1h&group_by=project_id&group_by=api_key_id&group_by=model" \
  -H "Authorization: Bearer $OPENAI_ADMIN_KEY"

Look for traffic on the leaked key outside your own hours, models your code never calls, and volume out of proportion to your workload; signs your key is being abused lists the patterns. Keys created before 20 December 2023 did not have usage tracking enabled by default, and their earlier usage appears as "Untracked"3. Keep screenshots and exports: OpenAI asks for the details when you report it.

4. Rotate everywhere

Create the replacement with an expiration date. OpenAI "strongly recommends" an expiry on project keys and a regular rotation process3. Give it the narrowest permissions the workload needs.

Then find every copy of the old key, because the leak has told you that your inventory of where it lived was incomplete:

  • Secret manager entries and the services that read them
  • CI/CD secrets and deployment variables
  • .env files on servers and developer machines
  • Third-party tools that were given the key: IDE assistants, coding agents, notebooks, hosted consoles
  • Other projects or organizations where someone may have pasted the same value

Confirm the old key now fails, and that nothing in production still sends it. A service that keeps retrying a deleted key is noise in your error logs and hides real failures.

5. Put limits in place

These make the next leaked key worth less:

  • A project hard spend limit. When it is reached, affected requests return 429 with project_spend_limit_exceeded; an organization limit covers every project. OpenAI notes that enforcement "is not instantaneous, so recorded spend can slightly exceed the configured amount", and that spend alerts "do not enforce a cap"7.
  • Spend alerts at several thresholds, such as 90% and 95% of a monthly budget, sent to a mailing list or incident tool rather than one person1.
  • An IP allowlist under Settings → Security → IP allowlist, at project or organization level, up to 50 addresses or CIDR ranges. Requests from other addresses fail with 401 and ip_not_authorized even with a valid key; changes can take up to 15 minutes, and OpenAI is clear it does not prevent every form of misuse8.
  • Key governance. Admins can enforce a maximum key lifetime at organization or project level, and allow only service-account keys or only user-owned project keys; these settings apply to new keys only3.
  • Separate keys per feature, team or project, so usage per key means something1.

6. Check whether an admin key leaked too

If the leak came from somewhere that also held an Admin API key, such as a FinOps tool, a CI pipeline that manages projects, or a breached vendor, treat it as a separate and worse incident. Admin keys are created by organization owners and can manage invitations, users, projects, service accounts, API keys and admin keys; they cannot call model endpoints910. An attacker with one does not need your inference key: they can create their own.

Delete any admin key that may be exposed and create a new one with only the scopes the integration needs. Then read the audit log: OpenAI's Audit Logs API records the lifecycle of API keys, users, service accounts and projects, login failures and organization setting changes9. Look for keys, service accounts or members created during the exposure window. Audit logging has to be enabled in organization settings before events are recorded, so if it is off, switch it on now. Least privilege for provider admin keys covers how to hold one safely.

7. Contact OpenAI Support

Open a chat from any Help Center page and include the activity you did not perform or authorize1. For a compromised account or key there is also an Unauthorized Activity webform, with the option "Report unauthorized activity involving my account"11. OpenAI's Services Agreement requires customers to "promptly notify OpenAI if it becomes aware of unauthorized access to the Account"12, so report even if the usage looks small.

Include the key's name and project, the time window in UTC, the models and volumes you believe are not yours, and what you have already done. Whether any charges are adjusted is OpenAI's decision; what the terms say about stolen-key charges explains why prevention is the only protection you control.

If the leak also exposed a dashboard login, change the password, log out of all sessions (on Platform, Your Profile → Security → Log out of all devices) and turn on multi-factor authentication1.

How INFRO handles a leaked OpenAI key

If your OpenAI key is connected to INFRO, step 4 has one more stop: replace the credential on the connection in the console or through the management API. INFRO seals the key with AES-256-GCM on arrival and never shows it again, and replacing it takes effect on the next request; it does not revoke the old key at OpenAI, which you still do yourself (see Connect a provider). Your applications use INFRO gateway keys rather than the OpenAI key, so a leaked application credential is an INFRO key you can revoke, rotate with an overlap window, restrict to IP ranges, and cap with budgets checked before OpenAI is called.

INFRO's controls govern traffic that goes through INFRO. A copy of the OpenAI key itself, wherever it leaked from, including from a platform like INFRO that holds it, can be used directly against OpenAI, and no INFRO budget, allowlist or alert sees that traffic. That is why steps 1, 5 and 7 happen at OpenAI. On the Business plan, with usage access on, reconciliation reads OpenAI's own usage per key and can show traffic that did not pass through INFRO.

Summary

Delete the key first. Then find its project and permissions, read its usage per key in UTC, replace it everywhere it lived, cap the project at OpenAI and allowlist your egress addresses, rule out an admin key exposure through the audit log, and report it to OpenAI with the details. The limits you set in step 5 are what make the next leak an incident instead of an invoice.

Questions readers ask

What should I do first if my OpenAI API key is leaked?
Delete the key on the API keys page of the OpenAI dashboard. OpenAI's own guidance for a compromised key is to delete it, review your API usage for unexpected activity and keep the details, then contact OpenAI Support.
Does OpenAI automatically disable leaked API keys?
OpenAI says that when it detects an API key on the public internet, or leaked inside an app in an app store, the key is disabled immediately. GitHub also reports OpenAI keys found in public repositories to OpenAI. Neither covers a key leaked privately, for example from a breached tool or a log file, so revoke it yourself.
How do I see what a leaked OpenAI key was used for?
Open the Usage Dashboard, select the key's project with the dashboard's own project selector, and narrow the interval; times are in UTC. For a per-key breakdown, the organization Usage API accepts group_by=api_key_id with an Admin API key.
Will OpenAI refund charges from a stolen API key?
OpenAI does not publish a refund policy for unauthorized usage, and its Services Agreement makes the customer responsible for all activity under its account. Report it through support or the Unauthorized Activity webform with the details; any adjustment is OpenAI's decision. See our guide on stolen API key charges.

From the team that builds it

Where this shows up in INFRO

INFRO is a control plane in front of the provider accounts you already hold. The capabilities below are the parts of it this article touches, each with the documentation that defines its behaviour.

  • Provider connections

    Available with a plan

    Connect provider accounts you already hold. Each credential is encrypted when saved, scoped to your organization and never shown again; applications use INFRO gateway keys instead.

    Read the documentation for Provider connections
  • Key limits and rotation

    Available with a plan

    Limit a gateway key to chosen providers or IP ranges, and rotate it with an overlap window so the old key keeps working while you deploy the new one.

    Read the documentation for Key limits and rotation
  • Budgets and spend ceilings

    Available with a plan

    A hard cap per organization, project, member, and key, with alerts at your own thresholds.

    Read the documentation for Budgets and spend ceilings
  • Spend anomaly and drift alerts

    Available with a plan

    Each scope's usual day is learned from its own history; a day that departs from it, a budget forecast to be exceeded, cost estimates drifting from the provider's own figures, unpriced traffic and failing connections become findings in the console. Routed to email on every plan, and to Slack and signed webhooks from the Startup plan.

    Read the documentation for Spend anomaly and drift alerts
  • Provider cost reconciliation

    Available with a plan

    Daily comparison of estimated spend against the cost reported by OpenAI's and Anthropic's own cost APIs, using a separate admin credential, with the likely cause of a persistent gap and a suggested rate you can apply. Included on the Business plan.

    Read the documentation for Provider cost reconciliation
  • Audit log

    Available with a plan

    Member, key, and policy changes recorded with actor and timestamp, viewable in the console.

    Read the documentation for Audit log

INFRO accounts are self-serve. Provider usage is billed to you by your providers; INFRO charges a software subscription and takes 0% of model spend. See plans.

Sources

Numbered in order of first citation. Each was opened and checked against the claim on the date shown.

  1. 1.Keeping your OpenAI account secure (opens in a new tab) — OpenAI Help Center. Accessed Oct 21, 2026.
  2. 2.Supported secret scanning patterns (opens in a new tab) — GitHub. Accessed Oct 21, 2026.
  3. 3.Production best practices (opens in a new tab) — OpenAI. Accessed Oct 21, 2026.
  4. 4.Assign API Key Permissions (opens in a new tab) — OpenAI Help Center. Accessed Oct 21, 2026.
  5. 5.Reviewing API usage and costs (opens in a new tab) — OpenAI Help Center. Accessed Oct 21, 2026.
  6. 6.Completions usage (API reference) (opens in a new tab) — OpenAI. Accessed Oct 21, 2026.
  7. 7.Spend limits (opens in a new tab) — OpenAI. Accessed Oct 21, 2026.
  8. 8.IP allowlisting for OpenAI API (opens in a new tab) — OpenAI Help Center. Accessed Oct 21, 2026.
  9. 9.Admin and Audit Logs API for the API Platform (opens in a new tab) — OpenAI Help Center. Accessed Oct 21, 2026.
  10. 10.Admin APIs (opens in a new tab) — OpenAI. Accessed Oct 21, 2026.
  11. 11.I'm seeing unrecognized activity on my OpenAI account (opens in a new tab) — OpenAI Help Center. Accessed Oct 21, 2026.
  12. 12.Services Agreement (opens in a new tab) — OpenAI. Accessed Oct 21, 2026.

About this article

Every UI and API name was checked against OpenAI's help center (account security, usage dashboard, key permissions, IP allowlisting, Admin and Audit Logs API, unrecognized activity) and developer documentation (production best practices, spend limits, Admin APIs, Usage API reference), plus GitHub's secret scanning pattern list and OpenAI's Services Agreement, all opened on 2026-10-21. Written by the team that builds INFRO.

Last checked against its sources on . The next review is due by . No separate named reviewer is recorded for this article.

How articles are written, sourced and corrected is set out in the editorial standards.