Back to Playbooks
HighVerifiedOfficial Docs

OpenAI — API Key

OpenAI API keys authenticate requests to GPT, DALL-E, Whisper, and other models. Exposure leads to unauthorized usage billed to your account.

Verified Jan 15, 2025Category: AI & Developer APIs

Immediate Action Required

Deleting a leaked credential from a repository does not invalidate it. Assume it has already been copied. Follow the revocation steps below immediately, then investigate for unauthorized access.

What Is This Credential?

OpenAI API keys authenticate requests to GPT, DALL-E, Whisper, and other models. Exposure leads to unauthorized usage billed to your account.

Permissions Granted

  • Access to all OpenAI models on the account
  • Fine-tuning and model management
  • Usage data access
  • Organization-level access if org key

Exposure & Blast Radius

  • Unauthorized API usage billed to your account
  • Potential exposure of conversation history
  • Access to fine-tuned models and training data
  • Rate limit exhaustion blocking legitimate usage

Immediate Response Steps

1

Revoke the key

Go to platform.openai.com → API keys → Delete the exposed key.

2

Check usage dashboard

Review platform.openai.com → Usage for unexpected API calls and cost spikes.

3

Create a new key

Generate a replacement key with a descriptive name for tracking.

4

Set usage limits

Configure monthly spending limits in platform.openai.com → Billing → Usage limits.

Revocation vs Rotation

Revocation

Delete the key at platform.openai.com/api-keys. Revocation is immediate.

Rotation

Create a new key at platform.openai.com/api-keys. Consider using project-scoped keys for better isolation.

Grace Period & Session Persistence

Grace Period

None. Key deletion is immediate.

Session Persistence

OpenAI API keys are stateless — each request is independently authenticated. No session invalidation required.

Investigation Checklist

  • Review usage dashboard for unexpected model calls
  • Check for unusual cost spikes in billing
  • Look for calls to expensive models (GPT-4, DALL-E 3) you don't use
  • Review fine-tuning jobs for unauthorized model training
  • Check for bulk data extraction patterns

Recovery Steps

  • Update all environment variables with the new key
  • Set spending limits to prevent future runaway costs
  • Consider using project-scoped API keys for better isolation
  • Enable email alerts for unusual usage

Prevention

  • Use project-scoped keys with minimal permissions
  • Set monthly spending limits
  • Store keys in environment variables or secrets managers
  • Never include keys in client-side code
  • Rotate keys regularly

Sources & Evidence

Always verify critical instructions with official provider documentation before taking action. Provider behavior may change without notice.

Found an issue with this playbook?

If these instructions are incorrect, outdated, or missing important information, please report it so we can improve the playbook.

Report an Issue on GitHub