Quick Answer
Complete walkthrough for creating an OpenAI API key in 2026 — platform signup, payment method, usage limits, key creation, security best practices, and your first GPT-4o or GPT-5 call in Python and Node.js.
Quick Answer
Visit platform.openai.com → sign up → add payment method → set usage limit → API Keys → Create new secret key → copy immediately.The key is shown once. Store in environment variables. ChatGPT Plus does NOT include API access — they're separate billing systems. New API accounts get $5 free credits valid for 3 months.
Step 1: Sign up at platform.openai.com
Go to platform.openai.com. The platform account is separate from chatgpt.com — you may need to create a new account or sign in with the same Google/Microsoft SSO and accept developer terms.
Step 2: Add a Payment Method
- Click your profile icon → Settings → Billing → Payment Methods
- Add a credit card
- Optionally pre-pay credits via Add to Credit Balance
New accounts receive $5 in free credits valid for 3 months — enough to test most workloads.
Step 3: Set Usage Limits (Critical)
Before creating any API keys, set hard usage limits to prevent runaway charges:
- Settings → Billing → Usage Limits
- Set a monthly hard limit (e.g., $50)
- Set a monthly soft limit (e.g., $25) — emails you when reached
If a bug in your code triggers a million accidental requests, you cap your loss at the hard limit instead of waking up to a $5,000 bill.
Step 4: Create an API Key
- Go to Dashboard → API Keys
- Click Create new secret key
- Name it descriptively (
production,dev-laptop,staging) - Optional: assign to a Project (limits the key's scope)
- Click Create
- Copy the key immediately — it's shown only once
Step 5: Store It Securely
Five non-negotiable rules:
- Environment variables only. Never hard-code in source files.
- Server-side only. Never expose to client-side code, even via Next.js public env vars.
- Separate keys per environment. One for dev, one for staging, one for production.
- Use a secrets manager. Vercel env vars, AWS Secrets Manager, GCP Secret Manager, or 1Password.
- Rotate quarterly. Or immediately on suspicion of leak.
Step 6: Your First API Call
Python
pip install openai
# Set OPENAI_API_KEY env var, then:
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-5",
messages=[
{"role": "user", "content": "Hello, world"}
]
)
print(response.choices[0].message.content)Node.js
npm install openai
// Set OPENAI_API_KEY env var, then:
import OpenAI from 'openai'
const client = new OpenAI()
const response = await client.chat.completions.create({
model: 'gpt-5',
messages: [{ role: 'user', content: 'Hello, world' }]
})
console.log(response.choices[0].message.content)2026 Pricing Snapshot
- GPT-5: $5/M input, $15/M output. Flagship model for complex reasoning.
- GPT-4o: $5/M input, $15/M output. Multimodal (image, voice).
- GPT-4o-mini: $0.15/M input, $0.60/M output. Cheap production workhorse.
- GPT-3.5-turbo: $0.50/M input, $1.50/M output. Legacy — most users have moved to 4o-mini.
- o1-preview: $15/M input, $60/M output. Reasoning model for hard problems.
Common Issues
- “You exceeded your current quota”: Add a payment method (free credits aren't enough), or you hit your usage limit.
- “Invalid API key”: Key was revoked or copied with whitespace. Check for trailing newlines.
- Rate limit errors: New accounts have low limits. Pre-pay $5+ to upgrade tiers automatically.
- “Model not found”: Some models require Tier 2+ (after $50 spent). Use GPT-4o-mini until you graduate.
Build AI SaaS With the API Stack That Wins
OpenAI key plus Claude key = the dual-model setup most production AI products run in 2026. Routing requests by task type beats picking one. Our AI SaaS Builder course shows you the exact stack — Claude for code/agents, GPT-4o for multimodal, n8n for orchestration — and the playbook to ship at $10K MRR.
AI SaaS Builder: Idea → $10K MRR in 30 Days
The exact API stack, automation orchestration, and monetization playbook for shipping AI SaaS products that scale.
Get AI SaaS Builder →