Skip to content

Getting Your OpenAI API Key

Getting your API key is straightforward, but there are a few gotchas that trip people up. Let me walk you through it so you don’t get stuck on the basics.



Before you start, grab these:

  • A valid email address and mobile phone number (for verification)
  • A payment method that can add credit to your OpenAI account
  • An OpenAI account (create one at https://platform.openai.com if you don’t have one)

Quick note: VOIP numbers usually don’t work, so use your actual mobile.


  1. Go to the OpenAI Platform: https://platform.openai.com
  2. Click Log in or Sign up and follow the steps
  3. Verify your email address (check your inbox for the confirmation link)

Here’s where it gets more involved. OpenAI requires phone verification before you can generate any API keys:

  1. In the dashboard, you’ll see a prompt to Add a phone number
  2. Enter a valid mobile number (VOIP numbers usually get rejected)
  3. Enter the 6-digit code sent via SMS to complete verification

Once verified, the “API keys” section becomes available.

This is OpenAI’s way of preventing abuse. One phone number per account, so choose wisely.


Now for the main event:

  1. In the left sidebar, click API keys (under the Developers section)
  2. Press + Create new secret key
  3. (Optional) Give the key a name that describes its use—e.g., personal‑backend, chat‑app‑prod, etc.
  4. Select a usage scope:
    • Default project (personal use) – good for testing, hobby apps, local development
    • Service account / team project – best for production servers, SaaS products, or CI/CD
  5. Click Create secret key
  6. Copy the key immediately—this is the only time it will be displayed
  7. Store the key securely (password manager, environment variables, etc.)
# .env (example)
OPENAI_API_KEY=sk-proj-...

Never hard-code the key in your source files and never share it publicly. People scan GitHub for these keys constantly.


Here’s the part that catches everyone off guard. OpenAI requires a small initial credit load before your account can make live requests:

  1. In the sidebar, click Billing → Payments
  2. Select Add payment method and enter card details
  3. Choose Add credit → type $5Add funds
  4. Once the transaction succeeds, your usage quota becomes active

Without at least US$5 of prepaid credit (or an approved billing plan), API calls will return invalid_request_error: Must add funds first.

Five dollars goes pretty far when you’re learning - probably weeks of experimentation unless you go crazy with requests.


Now that you have a working API key:

  • Integrate the key into your backend (process.env.OPENAI_API_KEY)
  • Rotate or revoke keys periodically via API keys → ⋯ → Delete
  • Monitor usage in Usage → Daily cost to avoid unexpected charges

Set up billing alerts while you’re at it - nothing ruins your day like a surprise $200 bill because you left a loop running.


You’re all set! Your OpenAI API key is ready for use in your apps and automations.

Next up: we’ll build a Node.js backend and make your first API call. The fun part starts now! 🚀