Create an API Key
An API key identifies and authorizes requests. Treat it like a password because it can consume your account quota.
Create a key
- Sign in to the dashboard.
- Open API key management.
- Create a key with a recognizable name such as
macbook-codex. - Select the group or model scope required for this use case.
- Store the complete key immediately.
Use the key in the Authorization header:
http
Authorization: Bearer YOUR_API_KEYPrefer an environment variable instead of source code:
bash
export OPENAI_API_KEY="YOUR_API_KEY"Never commit a key to Git, expose it in browser code, or include it in screenshots and support messages.