How to Open an OpenAI API Key: Step-by-Step Guide
What "Opening an API Key" Actually Means
If you searched "how to open ai api key," you're almost certainly trying to figure out how to generate an OpenAI API key so you can call GPT models from your own code instead of using ChatGPT in a browser. "Opening" a key isn't a technical term — it just means creating one through OpenAI's dashboard, copying it, and using it as credentials in your API requests.
The process itself takes under five minutes. The part people usually get wrong is what happens after — storing the key securely, setting spending limits, and understanding that raw API access bills you per token with no fixed monthly cost. This guide covers both halves.
Step 1: Create or Log Into an OpenAI Account
Go to platform.openai.com and sign in with an email, Google, or Microsoft account. This is separate from a regular ChatGPT Plus subscription — API access and ChatGPT are billed independently, even though they share a login.
Step 2: Add a Payment Method
OpenAI's API is pay-as-you-go. Before you can generate a working key, you need to add a credit card under Settings → Billing. New accounts sometimes get a small free credit grant, but it expires after a few months, so don't count on it for anything long-term.
Step 3: Generate the API Key
- Go to Settings → API Keys
- Click Create new secret key
- Give it a name (e.g., "production-backend" or "local-dev")
- Copy the key immediately — it starts with
sk-and is shown only once
If you lose it, you can't recover it. You'll have to revoke it and generate a new one.
Step 4: Store It Somewhere Safe
Never hardcode the key into your source files or commit it to git. Use environment variables instead:
export OPENAI_API_KEY="sk-..."
And reference it in code:
const apiKey = process.env.OPENAI_API_KEY;
If you're deploying to a hosting platform (Vercel, Render, Railway, etc.), set the key in that platform's environment variable settings, not in your repo.
Step 5: Make Your First Request
Once the key is set, test it with a simple curl call:
curl https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'
If you get a JSON response back with a choices array, the key works.
Step 6: Set Usage Limits
This is the step most people skip and later regret. Go to Settings → Limits and set a monthly budget cap. Token-based billing means a bug in a retry loop or an unbounded conversation history can burn through dollars fast without any warning. A hard cap turns a surprise bill into a stopped script.
Common Mistakes When Opening a Key
- Sharing keys across projects. Create a separate key per project or environment so you can revoke one without breaking everything else.
- Committing keys to GitHub. Even private repos get scanned by bots looking for leaked credentials. If a key leaks, revoke it immediately from the dashboard.
- Confusing API access with ChatGPT Plus. A ChatGPT subscription does not include API credits — they're billed and managed separately.
- Ignoring rate limits. New accounts start on lower rate limits (requests per minute, tokens per minute) that increase automatically as you spend more, not immediately after signup.
When Raw API Access Isn't Enough
Once you've opened a key and started building, a few limitations show up quickly if you're shipping something with multiple team members or a production app:
- No built-in seat management — everyone shares one key or you manually juggle several
- No per-team-member usage breakdown, just a single billing total
- You're responsible for handling retries, streaming edge cases, and rate-limit backoff yourself
If you're working with Claude specifically rather than OpenAI's models, SubToAPI turns your existing Claude access into a proper HTTPS API: you get application keys (sub_live_...), streaming, tool use, and usage metadata per team member in one dashboard, instead of managing raw credentials by hand. It's not a replacement for OpenAI's API — it's a layer on top of Claude access designed for teams. Plans start at Solo €9, with Team (€19/seat) and Scale (€49/seat) tiers, and a free trial at signup.
Either way — OpenAI's raw key or a managed wrapper — the fundamentals are the same: keep the key out of source control, cap your spend, and test with a minimal request before wiring it into a full application.
Quick Reference Checklist
- [ ] Create/log into platform.openai.com
- [ ] Add a payment method under Billing
- [ ] Generate a key under API Keys and copy it once
- [ ] Store it as an environment variable, never in code
- [ ] Test with a single curl request
- [ ] Set a monthly spending limit under Limits
- [ ] Use separate keys per project/environment
FAQ
Do I need a paid account to open an API key? You can generate a key without immediately paying, but you can't make real requests until you add a payment method. Free trial credits, when offered, are limited and expire after a few months.
Is my ChatGPT Plus subscription the same as API access? No. ChatGPT Plus gives you higher usage limits inside the chat interface. API access is billed separately, per token, and requires its own key and payment method.
What do I do if my API key gets leaked? Go to Settings → API Keys in your OpenAI dashboard and revoke it immediately, then generate a new one. Update every environment variable or config file that referenced the old key before deploying again.