OpenAI API Key Setup (Journal)
This flow is only for API keys on platform.openai.com, not for ChatGPT subscriptions.
1. Create or select an API project
- Sign in to OpenAI Platform.
- Select the project you want to use in your organization.
- If you need a new project, have an organization owner create it. Project members can create keys inside the project.
2. Create the API key
- Open API Keys.
- Click
+ Create new secret key. - Choose key permission level as needed:
AllRestrictedRead Only
- Copy and store the key securely. Prefer environment variables and never commit the key to source control.
3. Enable billing (to avoid quota or payment errors)
- Open Billing Overview.
- Add a payment method for your API organization.
- If you use prepaid credits, click
Add payment detailsin Billing Overview and follow the purchase flow.
4. Local environment variable
export OPENAI_API_KEY="your_api_key_here"5. Minimal verification
curl https://api.openai.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": "Return OK"
}'If the response includes model output, the key is working.
6. Common issues (direct cause -> direct fix)
- Symptom:
401 invalid_api_key- Cause: invalid key, incomplete copy, or env var not loaded.
- Fix: create a new key, export it again in the same terminal, and retry.
- Symptom:
429or quota-related errors- Cause: billing is not enabled, prepaid balance is depleted, or project limits were hit.
- Fix: check billing and project usage limits; top up credits or adjust limits.
- Symptom: ChatGPT subscription is active but API still fails
- Cause: ChatGPT billing and API Platform billing are separate systems.
- Fix: complete billing setup in API Platform.