Keys / OpenAI
OPENAI_API_KEY
The key your app calls the OpenAI API with.
- Expires
- you choose, or never
- API
- create service-account keys, list and delete, with an admin key
Get it
Recorded 2026-11-16 on platform.openai.com/api-keys
- Open API keys and click Create new secret key.
- Type a name for the key.
- Open the Expiration menu.
- Choose when the key expires, such as 30 days.
- Click Create secret key, then copy the key.
Set it
OPENAI_API_KEY=...
The Python, Node.js, Go and Ruby SDKs read it when you don't pass a key, and the Java SDK reads it in fromEnv(). Or keep it out of .env with keypin: keypin run -- npm run dev
Replace it
- Create a replacement key. Choose Service account under Owned by, since
keypin rotaterefuses a key owned by a user. - Update every app that uses the old key.
- Check that the new key works, then revoke the old one.
Sources, checked 2026-11-16
- OpenAI: Developer quickstart
- OpenAI: API keys and service accounts
- OpenAI: Production best practices, API keys
- OpenAI API: Create a service account API key
- OpenAI API: Project API keys
- openai-python: reads OPENAI_API_KEY
- openai-node: reads OPENAI_API_KEY
- openai-go: reads OPENAI_API_KEY
- openai-ruby: reads OPENAI_API_KEY
- openai-java: fromEnv reads OPENAI_API_KEY