Quick Answer
To access the GPT-5.4 API:
- Create an OpenAI account at platform.openai.com.
- Add a payment method in billing settings.
- Generate an API key from the API Keys section.
- Install the OpenAI SDK (
pip install openaiornpm install openai). - Set the
OPENAI_API_KEYenvironment variable. - Make requests to the
gpt-5.4model.
Pricing: $2.50/M input tokens, $15/M output tokens. Pro version ($30/$180) available for complex tasks.
Introduction
Accessing the GPT-5.4 API takes about 10 minutes from account creation to your first API call. The process requires billing verification, API key management, SDK installation, and understanding pricing tiers. This guide provides direct steps, code examples, and troubleshooting tips to get you integrated quickly.
This tutorial covers:
- Full account setup with billing
- Secure API key generation and storage
- SDK installation for Python, Node.js, and cURL
- First API request: example code and responses
- Complete pricing breakdown and optimization tips
- Rate limit details and quota management
💡 Tip: Before integrating GPT-5.4 into production, test API endpoints thoroughly. Apidog offers unified API debugging, testing, and docs—use it to validate requests, inspect responses, automate test suites, and mock responses to minimize token costs.
button
Prerequisites
You'll need:
- Email address: For OpenAI account
- Payment method: Credit/debit card (Visa, Mastercard, Amex)
- Phone number: For verification
- Development environment: Python 3.7+, Node.js 14+, or cURL
- Text editor/IDE: VS Code, Cursor, etc.
Time required: 10–15 minutes
Cost: $0 to start (pay-as-you-go)
Step 1: Create OpenAI Account
Go to platform.openai.com and click Sign Up.
Enter:
- Email address
- Password (min 8 chars)
- Full name
- Phone number (for verification)
OpenAI will send a verification code to your email. Enter it to verify.
Tip: Use a business email for commercial use. Account transfers require support.
Phone verification steps:
- Select country code
- Enter phone number
- Enter code received via SMS
If you get region restrictions, check OpenAI's supported countries list.
Step 2: Set Up Billing
You must add a payment method before making API requests.
Steps:
- Go to Settings > Billing in the dashboard.
- Click Add payment method.
- Enter card details (Visa, Mastercard, Amex).
- Make sure billing address matches card.
- Click Save.
OpenAI will make a small authorization charge ($0.50–$1.00), reversed in a few days.
Billing Tiers
- Tier 1: $5 initial credit (expires in 3 months), $5/month usage, requires card verification
- Tier 2: $120/month usage, after first successful payment
- Tier 3: Custom limits (contact sales)
To increase limits:
- Go to Settings > Billing > Limits
- Click Request limit increase
- Add use case and expected spend
- Wait 1–3 business days
Enable Usage Alerts
Set usage alerts to prevent overcharges:
- Settings > Billing > Overview
- Click Add alert
- Set threshold (e.g., $50, $100)
- Enter notification email
You’ll get emails when thresholds are reached.
Step 3: Generate API Key
API keys authenticate your OpenAI API requests.
Go to platform.openai.com/api-keys.
Create New Key
- Click Create new secret key
- Name it descriptively (e.g., "Dev", "Prod", "CI/CD")
- (Optional) Assign to project
- Click Create secret key
Copy your key immediately—you can't view it again.
Key format: Starts with sk-proj- (e.g., sk-proj-abc123...)
Key Permissions
- All capabilities: Full API access (default)
- Specific models: Restrict to models
- Specific endpoints: Restrict endpoints
For GPT-5.4: Ensure Chat Completions endpoint and GPT-5.4 model permission.
Key Rotation Best Practices
Rotate API keys every 90 days:
- Generate new key
- Update applications
- Test thoroughly
- Delete old key
Store keys securely: Use environment variables or secret managers (AWS, Vault).
Step 4: Install OpenAI SDK
Official SDKs: Python, Node.js. Or use cURL for direct requests.
Python Installation
pip install openai
Verify:
import openai
print(openai.__version__)
For virtual environments:
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
pip install openai
Node.js Installation
npm install openai
Verify:
const OpenAI = require('openai');
console.log(OpenAI.version);
For TypeScript:
npm install --save-dev @types/node
cURL (No Installation Needed)
Check cURL:
curl --version
Use cURL for quick testing.
Step 5: Configure Environment
Never hardcode API keys. Use environment variables.
Linux/macOS
Add to your shell profile (e.g., ~/.bashrc, ~/.zshrc):
export OPENAI_API_KEY="sk-proj-abc123def456..."
Reload:
source ~/.zshrc # or ~/.bashrc
Windows
Command Prompt:
set OPENAI_API_KEY=sk-proj-abc123def456...
PowerShell:
$env:OPENAI_API_KEY="sk-proj-abc123def456..."
Permanent:
- Search "Environment Variables" in Start.
- Edit system variables.
- Add
OPENAI_API_KEYwith your key. - Restart terminal.
.env File (Development)
Create .env in your project root:
OPENAI_API_KEY=sk-proj-abc123def456...
Load with python-dotenv:
pip install python-dotenv
from dotenv import load_dotenv
load_dotenv()
Add .env to .gitignore:
.env
Step 6: Make Your First Request
Test your setup with a simple GPT-5.4 request.
Tip: Use Apidog for visual API testing and code generation.
- Configure headers, auth, and body visually
- Save requests/collections
- Use environment variables for API keys
- Add test assertions and generate code snippets
Python Example
from openai import OpenAI
import os
client = OpenAI(
api_key=os.getenv("OPENAI_API_KEY")
)
response = client.chat.completions.create(
model="gpt-5.4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is GPT-5.4?"}
]
)
print(response.choices[0].message.content)
Node.js Example
const OpenAI = require('openai');
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY
});
async function main() {
const response = await client.chat.completions.create({
model: 'gpt-5.4',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'What is GPT-5.4?' }
]
});
console.log(response.choices[0].message.content);
}
main();
cURL Example
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-5.4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is GPT-5.4?"}
]
}'
Expected Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1741234567,
"model": "gpt-5.4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "GPT-5.4 is OpenAI's most advanced frontier model..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 150,
"total_tokens": 175
}
}
Verify GPT-5.4 Access
If you get a model access error:
- Check billing is active
- Verify API key permissions
- Confirm model name is exactly
gpt-5.4 - Contact OpenAI support if issues persist
GPT-5.4 API Pricing
Standard Pricing:
| Component | Price |
|---|---|
| Input tokens | $2.50 per million |
| Cached input tokens | $0.25 per million |
| Output tokens | $15 per million |
Pro Pricing:
| Component | Price |
|---|---|
| Input tokens | $30 per million |
| Output tokens | $180 per million |
Discount Programs
- Batch: 50% off, processed within 24 hours (non-real-time)
- Flex: 50% off, processed during low-demand
- Priority: 2x rates, lowest latency
Cost Example
Processing 10,000 queries/month (5M input, 2M output tokens):
- Standard: $12.50 input + $30 output = $42.50/month
- Batch (50% off): $6.25 input + $15 output = $21.25/month
Cost Optimization
- Use cached inputs: Repeated prompts cost 90% less
- Optimize prompts: Shorter = fewer tokens
-
Limit outputs: Set
max_tokens - Batch processing: 50% off for non-real-time
- Monitor usage: Set billing alerts
Context Window Pricing
- Standard context: 272K tokens
- Extended: Up to 1M tokens at 2x rate
Requests >272K tokens:
- Input: $5/M
- Output: $30/M
Rate Limits and Quotas
Default Rate Limits:
- Tier 1: 20 RPM, 40,000 TPM, 100,000 TPD
- Tier 2: 60 RPM, 150,000 TPM, 1,000,000 TPD
- Tier 3: Custom (contact sales)
API responses include rate limit headers:
x-ratelimit-limit-requests: 60
x-ratelimit-limit-tokens: 150000
x-ratelimit-remaining-requests: 59
x-ratelimit-remaining-tokens: 149500
x-ratelimit-reset-requests: 1s
x-ratelimit-reset-tokens: 200ms
Handling Rate Limits
HTTP 429 means you've hit a limit.
Retry with exponential backoff:
import time
from openai import OpenAI, RateLimitError
client = OpenAI()
def make_request_with_retry(messages, max_retries=3):
for attempt in range(max_retries):
try:
return client.chat.completions.create(
model="gpt-5.4",
messages=messages
)
except RateLimitError as e:
if attempt == max_retries - 1:
raise
wait_time = 2 ** attempt
time.sleep(wait_time)
- Use exponential backoff (1s, 2s, 4s)
- Add jitter
- Queue requests during peak
- Batch API for bulk processing
Requesting Limit Increases
Go to Settings > Billing > Limits and click Request limit increase. Provide use case, spend, traffic patterns, and contact info. Approval in 1–3 days.
Access Across Platforms
GPT-5.4 is available through different OpenAI products.
API Access
-
Model names:
gpt-5.4(standard),gpt-5.4-pro(pro) - Access: REST API (SDK/HTTP), API key, pay-per-token
- Best for: Custom apps, production, high volume
ChatGPT Access
- GPT-5.4 Thinking: ChatGPT Plus ($20/mo), Team ($25/user/mo), Pro ($200/mo)
- GPT-5.4 Pro: ChatGPT Pro/Enterprise
- Access: Web/mobile apps (no API)
- Best for: Ad-hoc, productivity, voice/image
Codex Access
- Default model in Codex, 1M context, Playwright,
/fastmode - Access: Desktop/cloud apps, Codex-specific API
- Best for: Software dev, codegen, browser automation
Platform Comparison
| Feature | API | ChatGPT | Codex |
|---|---|---|---|
| GPT-5.4 Access | Yes | Yes (+) | Yes |
| GPT-5.4 Pro | Yes | Yes (+) | Yes |
| Computer Use | Yes | Limited | Yes |
| Tool Search | Yes | No | Yes |
| 1M Context | Yes* | No | Yes |
| Custom Integrate | Yes | No | Limited |
| Pay-per-use | Yes | Subscr. | Subscr. |
Apidog for API Integration
When building GPT-5.4 integrations, Apidog helps you:
- Test API requests visually (no code)
- Manage API keys across environments
- Create automated test suites
- Mock GPT-5.4 responses (save tokens)
- Share API collections with your team
- Auto-generate code snippets (cURL, Python, Node.js, Go, Java)
Troubleshooting Common Issues
"Model not found" Error
Error: The model gpt-5.4 does not exist
Causes:
- Typo in model name
- No GPT-5.4 access for your account
- API key lacks permission
Fix:
- Use exact model name:
gpt-5.4 - Check billing is active
- Generate key with correct permissions
- Wait 24 hours if new account
"Insufficient quota" Error
Error: You exceeded your current quota
Causes:
- Hit token or billing limit
- Payment failed
- Account tier limits hit
Fix:
- Check usage at platform.openai.com/usage
- Verify payment method
- Request limit increase
- Wait for quota reset (midnight UTC)
Authentication Failures
Error: Invalid authentication - Please provide a valid API key
Causes:
- API key not set/incorrect
- Key expired/revoked
Fix:
- Verify
OPENAI_API_KEYvariable - Key format should start with
sk-proj-orsk- - Regenerate if needed
- Restart app after setting variable
Rate Limit Errors
Error: Rate limit reached for requests
Fix:
- Implement exponential backoff retry
- Lower request frequency
- Use Batch API for bulk jobs
- Request higher limits
Billing Issues
Error: Payment required or Billing information needs updating
Fix:
- Update payment info
- Check card expiry
- Verify billing address
- Contact bank/support if declines
Timeout Errors
Error: Request timed out or connection errors
Causes:
- Network/server delays
- Short client timeout
Fix:
- Increase client timeout
- Check network
- Add retry logic
- Use streaming for long requests




Top comments (0)