Get ChatGPT API Key
To use OpenAI's ChatGPT API, you need an API Key. This guide describes how to get an OpenAI API Key.
π Prerequisites
- β OpenAI Account (Sign up if none)
- β Payment Method (Credit/Debit Card)
- β Email Verification
β οΈ Note: ChatGPT Plus subscription and API are separate!
π API Key Issuance Steps
Step 1: Access OpenAI Website
Go to https://platform.openai.com
Step 2: Account Creation or Login
- Click "Sign up" if you don't have an account
- Sign up with Email or Google/Microsoft account
- Complete email verification
Step 3: Register Payment Method
- Click account menu in top right
- Select "Billing"
- Go to "Payment methods" β "Add payment method"
- Enter credit card info
π‘ Tip: We recommend charging at least $5.
Step 4: Create API Key
- Click "API keys" in left menu
- Click "Create new secret key" button
- Enter key name (e.g., "CodeFreeAI-Workflow")
- Click "Create secret key"
Step 5: Copy and Store API Key
β οΈ Important: API Key is displayed only once!
- Copy the displayed API Key
- Save it in a safe place (Password Manager, etc.)
- Click "Done"
π API Key Format
sk-proj-1234567890abcdefghijklmnopqrstuvwxyzABCDEFGH
- Starts with
sk-proj- - Total length: Approx. 50-60 chars
π° Pricing Guide
As of Dec 2024 (GPT-4o)
| Model | Input | Output |
|---|---|---|
| GPT-4o | $0.15 / 1M Tokens | $0.60 / 1M Tokens |
| GPT-4o-mini | $0.03 / 1M Tokens | $0.12 / 1M Tokens |
Estimated Cost Calculation
1,000 AI Requests (Avg 500 tokens/request)
Input: 250,000 Tokens Γ $0.15 = $0.0375
Output: 250,000 Tokens Γ $0.60 = $0.15
Total: $0.1875
Monthly Estimate:
- Small (10k req/mo): ~$19
- Medium (100k req/mo): ~$190
- Large (1M req/mo): ~$1,900
π‘ Cost Saving Tips:
- Use GPT-4o-mini (80% cheaper)
- Optimize Prompts (Remove unnecessary words)
- Reuse System Prompts
βοΈ Setting up in CodeFreeAI
1. Add ChatGPT Node to Workflow
- Workflow Edit Screen
- Find "ChatGPT" in left node list
- Drag to Canvas
2. Enter API Key
- Click ChatGPT Node
- Paste copied key into "API Key" field
- Save
3. Select Model
| Model | Purpose | Price |
|---|---|---|
gpt-4o |
General, High Quality | Standard |
gpt-4o-mini |
Fast & Cheap | 80% Off |
4. Test
Test with simple prompt:
Hello. Is it working?
If you get a normal response, setup complete! π
π Security Requirements
β Do's
- β Manage API Key as Environment Variable
- β Regenerate key periodically (Every 6 months)
- β Set Usage alerts
- β Set Workflow to Private
β Don'ts
- β Upload to public repo like GitHub
- β Share screenshots
- β Print to logs
- β Share with multiple people
π Usage Monitoring
1. Access OpenAI Dashboard
https://platform.openai.com/usage
2. Checkable Info
- Daily/Monthly Usage
- API Call Count
- Token Usage
- Cost Accumulation
3. Set Alerts
- "Billing" β "Limits"
- Set "Usage limits"
- Monthly Limit: $50
- Notification Threshold: $40
- Receive alerts via Email
π API Key Regeneration
When to Regenerate?
- π Key is exposed
- π Regular security maintenance (Every 6 months)
- β Suspicious usage pattern detected
- π« Workflow no longer in use
How to Regenerate
- Go to API keys page
- Click "..." next to existing key
- Select "Revoke" (Delete existing key)
- "Create new secret key" (Generate new key)
- Update CodeFreeAI Workflow
π― Next Steps
β FAQ
Q: Is API free if I have ChatGPT Plus? A: No. ChatGPT Plus and API are separate services.
Q: Is there a free trial? A: New signups get $5 credit, but it's limited.
Q: How is API cost calculated? A: It is charged based on usage (input/output tokens).
Q: Difference between GPT-4o and GPT-4o-mini? A: GPT-4o-mini is faster and cheaper, but GPT-4o is better for complex tasks.
Q: How much will it cost per month? A: Depends on usage, small scale is around $10-20/month.
Q: My API Key is exposed! A: Immediately Revoke the key and issue a new one.