OpenAI API keys: formats, revoking and limits
A reference card for OpenAI keys: what each prefix means, how to revoke a key from the dashboard or the Admin API, and which limits to put on a key before it leaks. The full zero-downtime rotation procedure is in our step-by-step guide.
- Key formats
- Project keys start with
sk-proj-, service account keys can start withsk-svcacct-, Admin API keys withsk-admin-. Older user keys are a baresk-. - Where to create and revoke
- platform.openai.com/api-keys for project keys; Admin keys under Organization settings → Admin keys (organization owners only).
- Several keys at once
- Yes. A project can hold several live keys, so a replacement can work before the old key is deleted.
- Expiry
- Project keys can carry an expiration date, and admins can enforce a maximum key lifetime per organization or project.
- Permissions
- Per-key scopes, such as read-only. A key never gets more access than its owner (a user or a service account) has.
- Spend limits
- Monthly spend limits are set per project, so they cover every key in it. Alerts alone don't stop traffic.
- Programmatic revoke
DELETE /v1/organization/projects/{project_id}/api_keys/{key_id}with an Admin API key.- Keysquid
- Automatic rotation, through a dedicated project service account.
Which OpenAI key is this?
OpenAI has three kinds of credential, and the prefix tells you which one you are holding. The prefix matters most after a leak: an admin key can create and delete other keys, so it is the one to kill first.
| Prefix | What it is | Owned by | Use it for |
|---|---|---|---|
sk-proj- | Project API key | A user, or a project service account | Calling the API inside one project |
sk-svcacct- | Service account key | A project service account (no person) | Production apps, CI and scheduled jobs |
sk-admin- | Admin API key | The organization | Managing projects, users and keys. Never in an app. |
sk- only | Legacy user key | A user | Replace it with a project key |
Prefixes as listed in OpenRouter's secret-format reference; the sk-admin- prefix also appears in OpenAI's Admin API reference.
User-owned keys act with that person’s access and are meant for their own development. Service account keys belong to the project, so a person leaving the company never takes production down with them. OpenAI’s docs also note that user-owned project keys can’t be created through the API on someone else’s behalf; the Admin API creates service account keys instead.
Not sure what you have? Paste it into the key identifier. It checks the format in your browser and never sends the value anywhere.
How to revoke an OpenAI API key
In the dashboard:
- Open API keys and switch to the project the key belongs to.
- Find the key by name or by its redacted value (the first and last characters are shown).
- Open its menu and delete it. Requests that still use it now fail with an authentication error.
With the Admin API, list the project’s keys to find the key’s ID, then delete it:
curl -s "https://api.openai.com/v1/organization/projects/$PROJECT_ID/api_keys?limit=100" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY" \
| jq -r '.data[] | [.id, .name, .redacted_value, .owner.type] | @tsv'
curl -s -X DELETE "https://api.openai.com/v1/organization/projects/$PROJECT_ID/api_keys/$KEY_ID" \
-H "Authorization: Bearer $OPENAI_ADMIN_KEY"The list response includes each key’s last_used_at, expires_at and owner type, which is how you tell an abandoned key from one production still depends on. The delete call answers with the key’s id and deleted: true.
Revoking because of a leak? Revoke first and accept a few failed requests. Then check the Usage page for traffic you don’t recognise, and contact OpenAI through help.openai.com if there is any. Our first 10 minutes after a leak checklist covers the rest.
Rotating without downtime: the short version
OpenAI’s own guidance is four steps: issue a replacement, update the workload, verify it works, then revoke the previous key. Because a project can hold several keys, the old and new keys overlap for as long as you need:
- Create the new key in the same project (same models, limits and billing), owned by a service account.
- Update every place the old key lives, and restart anything that reads it only at boot.
- Verify the new key with a real call, then watch the old key’s
last_used_atstop moving. - Delete the old key.
The details (finding every consumer, scripting each step with the Admin API, how long to wait before revoking) are in How to rotate an OpenAI API key without downtime.
Limits to set on every key
- An expiry date. OpenAI recommends creating keys with an expiration and rotating on a schedule. An expired key fails safe, even if everyone forgot about it.
- Read-only where it’s enough. A dashboard that only lists models or files doesn’t need write access.
- A project spend limit. It caps what a leaked key can cost. It applies to the whole project, which is one more reason to give each app its own project.
- No keys in browsers, mobile apps or repos. OpenAI’s docs list source control, logs and customer-facing responses as places a secret key must never appear.
How Keysquid handles OpenAI keys
Automatic Keysquid creates, verifies, distributes and revokes OpenAI keys on a schedule, with no one in the loop. Project API keys via a dedicated service account.
Setup, as the app shows it:
- In OpenAI, open Organization settings → Admin keys and create a key named “Keysquid”.
- Keysquid uses it only to create and delete project service-account keys. Store nothing else with it.
- Pick the project whose key you want rotated and copy its ID (proj_…).
- Writes to: API key (default variable OPENAI_API_KEY), in every platform and secret store you map it to.
- Interval: from every 1 hour to every 4 weeks, subject to your plan’s minimum.
- Limits Keysquid applies: Per-key expiry and read-only access, plus a monthly hard spend limit on the key's project.
- Inventory: Keysquid lists every OpenAI key the connection can see, including keys it doesn’t manage, with names and last use.
Every rotation runs in the same order: create the new key, verify it, write it everywhere, redeploy where a platform needs it, and only then revoke the previous key after a grace period. If any write fails, everything written so far is restored and the new key is revoked. The value is encrypted to the agent you run, so Keysquid’s servers never see it.
In practice that means one admin key you create once, and a project service account whose key changes on your schedule. Each rotation adds a key to the service account, pushes it to your platforms, checks it against /v1/models, and deletes the previous key once the grace period ends. The expiry, read-only and project spend limit you set are applied to every new key.
Frequently asked questions
What does sk-proj- mean in an OpenAI API key?
It marks a project API key: a key that belongs to one project in your OpenAI organization and can only use that project's models, limits and billing. It can be owned by a user or by the project's service account.
How do I revoke an OpenAI API key?
Open platform.openai.com/api-keys, select the key's project, and delete the key from its menu. To do it in a script, call DELETE /v1/organization/projects/{project_id}/api_keys/{key_id} with an Admin API key.
Can I see an OpenAI API key again after creating it?
No. The full value is shown once, when the key is created. Afterwards only a redacted value is shown, so a lost key has to be replaced, not recovered.
Is an sk-admin- key the same as a normal API key?
No. An Admin API key manages the organization: projects, users, service accounts and their keys. It isn't meant for model calls and should never be deployed with an application.
Does deleting a key reset my rate limits or spend?
No. Rate limits and spend limits belong to the organization and project, not to a key, so a new key in the same project has the same limits and the same usage history.