Products

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

  1. Sign in to OpenAI Platform.
  2. Select the project you want to use in your organization.
  3. 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

  1. Open API Keys.
  2. Click + Create new secret key.
  3. Choose key permission level as needed:
    • All
    • Restricted
    • Read Only
  4. 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)

  1. Open Billing Overview.
  2. Add a payment method for your API organization.
  3. If you use prepaid credits, click Add payment details in 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: 429 or 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.

Official references (verified on 2026-04-13)