DEV Community

Cover image for How to Access GPT-5.4 API
Wanda
Wanda

Posted on • Originally published at apidog.com

How to Access GPT-5.4 API

Quick Answer

To access the GPT-5.4 API:

  1. Create an OpenAI account at platform.openai.com.
  2. Add a payment method in billing settings.
  3. Generate an API key from the API Keys section.
  4. Install the OpenAI SDK (pip install openai or npm install openai).
  5. Set the OPENAI_API_KEY environment variable.
  6. Make requests to the gpt-5.4 model.

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.

Try Apidog today

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.

OpenAI Signup Screenshot

Tip: Use a business email for commercial use. Account transfers require support.

Phone verification steps:

  1. Select country code
  2. Enter phone number
  3. 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:

  1. Go to Settings > Billing in the dashboard.
  2. Click Add payment method.
  3. Enter card details (Visa, Mastercard, Amex).
  4. Make sure billing address matches card.
  5. Click Save.

OpenAI Billing Screenshot

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:

  1. Go to Settings > Billing > Limits
  2. Click Request limit increase
  3. Add use case and expected spend
  4. Wait 1–3 business days

Enable Usage Alerts

Set usage alerts to prevent overcharges:

  1. Settings > Billing > Overview
  2. Click Add alert
  3. Set threshold (e.g., $50, $100)
  4. 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

  1. Click Create new secret key
  2. Name it descriptively (e.g., "Dev", "Prod", "CI/CD")
  3. (Optional) Assign to project
  4. Click Create secret key

API Key Screenshot

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:

  1. Generate new key
  2. Update applications
  3. Test thoroughly
  4. 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
Enter fullscreen mode Exit fullscreen mode

Verify:

import openai
print(openai.__version__)
Enter fullscreen mode Exit fullscreen mode

For virtual environments:

python -m venv venv
source venv/bin/activate  # Linux/macOS
venv\Scripts\activate     # Windows
pip install openai
Enter fullscreen mode Exit fullscreen mode

Node.js Installation

npm install openai
Enter fullscreen mode Exit fullscreen mode

Verify:

const OpenAI = require('openai');
console.log(OpenAI.version);
Enter fullscreen mode Exit fullscreen mode

For TypeScript:

npm install --save-dev @types/node
Enter fullscreen mode Exit fullscreen mode

cURL (No Installation Needed)

Check cURL:

curl --version
Enter fullscreen mode Exit fullscreen mode

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..."
Enter fullscreen mode Exit fullscreen mode

Reload:

source ~/.zshrc  # or ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Windows

Command Prompt:

set OPENAI_API_KEY=sk-proj-abc123def456...
Enter fullscreen mode Exit fullscreen mode

PowerShell:

$env:OPENAI_API_KEY="sk-proj-abc123def456..."
Enter fullscreen mode Exit fullscreen mode

Permanent:

  1. Search "Environment Variables" in Start.
  2. Edit system variables.
  3. Add OPENAI_API_KEY with your key.
  4. Restart terminal.

.env File (Development)

Create .env in your project root:

OPENAI_API_KEY=sk-proj-abc123def456...
Enter fullscreen mode Exit fullscreen mode

Load with python-dotenv:

pip install python-dotenv
Enter fullscreen mode Exit fullscreen mode
from dotenv import load_dotenv
load_dotenv()
Enter fullscreen mode Exit fullscreen mode

Add .env to .gitignore:

.env
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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();
Enter fullscreen mode Exit fullscreen mode

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?"}
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

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
  }
}
Enter fullscreen mode Exit fullscreen mode

Verify GPT-5.4 Access

If you get a model access error:

  1. Check billing is active
  2. Verify API key permissions
  3. Confirm model name is exactly gpt-5.4
  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

  1. Use cached inputs: Repeated prompts cost 90% less
  2. Optimize prompts: Shorter = fewer tokens
  3. Limit outputs: Set max_tokens
  4. Batch processing: 50% off for non-real-time
  5. 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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode
  • 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, /fast mode
  • 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)

Apidog Screenshot

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:

  1. Use exact model name: gpt-5.4
  2. Check billing is active
  3. Generate key with correct permissions
  4. 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:

  1. Check usage at platform.openai.com/usage
  2. Verify payment method
  3. Request limit increase
  4. 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:

  1. Verify OPENAI_API_KEY variable
  2. Key format should start with sk-proj- or sk-
  3. Regenerate if needed
  4. 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:

  1. Update payment info
  2. Check card expiry
  3. Verify billing address
  4. Contact bank/support if declines

Timeout Errors

Error: Request timed out or connection errors

Causes:

  • Network/server delays
  • Short client timeout

Fix:

  1. Increase client timeout
  2. Check network
  3. Add retry logic
  4. Use streaming for long requests

Top comments (0)