DEV Community

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

Posted on

How to Access GPT-5.4 API

TL;DR

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 with pip install openai or npm install openai.
  5. Set the OPENAI_API_KEY environment variable.
  6. Send requests to the gpt-5.4 model.

Standard pricing is $2.50 per million input tokens and $15 per million output tokens. A Pro version is also available at $30 per million input tokens and $180 per million output tokens for complex tasks.

Try Apidog today

Introduction

Accessing the GPT-5.4 API takes approximately 10–15 minutes once you have the required account and payment details. The setup includes billing verification, API key management, SDK installation, and pricing configuration.

This guide covers:

  • OpenAI account and billing setup
  • API key generation and secure storage
  • SDK installation for Python and Node.js
  • Direct requests with cURL
  • A first GPT-5.4 API request
  • Pricing, rate limits, and quota management
  • Troubleshooting and production security practices

Before integrating GPT-5.4 into a production application, test your API endpoints thoroughly. Apidog provides a unified platform for API debugging, testing, documentation, request inspection, automated test suites, and response mocking.

Prerequisites

Before you begin, prepare:

  • An email address for OpenAI account creation
  • A credit or debit card
  • A phone number for verification
  • Python 3.7+, Node.js 14+, or cURL
  • A text editor or IDE such as VS Code or Cursor

Time required: 10–15 minutes

Initial cost: $0 to start, followed by pay-per-use pricing

Step 1: Create an OpenAI Account

Navigate to platform.openai.com and select Sign Up.

You will need to provide:

  • Email address
  • Password with at least eight characters
  • Full name
  • Phone number for verification

OpenAI sends a verification code to your email. Enter the code to verify your account.

Image

For commercial projects, use an email address that your organization controls. Account ownership transfers may require support.

Complete phone verification by following these steps:

  1. Select your country code.
  2. Enter your phone number.
  3. Enter the verification code sent by SMS.

Some regions may have limited API access. Check OpenAI’s supported countries list if you encounter access issues during signup.

Step 2: Configure Billing

The GPT-5.4 API uses pay-as-you-go pricing. You must add a payment method before making API requests.

In the platform dashboard, open Settings > Billing.

Add a Payment Method

  1. Select Add payment method.
  2. Enter your credit or debit card details.
  3. Confirm that the billing address matches the card registration details.
  4. Select Save.

Image

OpenAI may perform a small authorization charge of approximately $0.50–$1.00 to verify the card. This charge is typically reversed within 3–5 business days.

Billing Tiers

The account tiers described in the original setup are:

Tier 1: New accounts

  • $5 initial credit, expiring after three months
  • $5 monthly usage limit
  • Card verification required

Tier 2: After the first payment

  • $120 monthly usage limit
  • Activated automatically after a successful billing cycle

Tier 3: Verified high-volume accounts

  • Custom usage limits
  • May require contacting the sales team

To request higher limits:

  1. Open Settings > Billing > Limits.
  2. Select Request limit increase.
  3. Describe your use case and expected monthly spend.
  4. Submit the request.

The stated review time is 1–3 business days.

Enable Usage Alerts

Usage alerts help detect unexpected spending:

  1. Open Settings > Billing > Overview.
  2. Select Add alert.
  3. Set a threshold, such as $50, $100, or $500.
  4. Add an email address for notifications.

You receive an email when usage crosses the configured threshold.

Step 3: Generate an API Key

API keys authenticate requests to the OpenAI API.

Open the API Keys page at platform.openai.com/api-keys.

Create a Secret Key

  1. Select Create new secret key.
  2. Enter a descriptive name, such as Development, Production, or CI/CD.
  3. Select a project if your organization uses projects.
  4. Select Create secret key.

Image

Copy the key immediately. The full secret is not available after closing the creation dialog. If you lose the key, create a replacement.

A key may look like this:

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

Configure Key Permissions

Use the minimum permissions required by your application. Depending on your account configuration, permissions may include:

  • All capabilities
  • Specific models
  • Specific API endpoints

For GPT-5.4 access, verify that the key can access:

  • The Chat Completions endpoint
  • The gpt-5.4 model
  • Any required tool permissions, such as computer use or vision

Rotate Keys Safely

A basic rotation workflow is:

  1. Generate a new key.
  2. Update applications and deployment systems.
  3. Run integration tests.
  4. Confirm the new key works in production.
  5. Delete the old key from the OpenAI dashboard.

The original guidance recommends rotating keys every 90 days. Store keys in environment variables or a secret management system such as AWS Secrets Manager or HashiCorp Vault.

Step 4: Install an OpenAI SDK

OpenAI provides SDKs for Python and Node.js. You can also make HTTP requests directly with cURL.

Python

Create and activate a virtual environment:

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

Install the SDK:

pip install openai
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

import openai

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

The stated minimum Python version is 3.7.

Node.js

Install the SDK:

npm install openai
Enter fullscreen mode Exit fullscreen mode

Verify the package installation:

const OpenAI = require("openai");

console.log(OpenAI.version);
Enter fullscreen mode Exit fullscreen mode

The stated minimum Node.js version is 14. For TypeScript projects, install the Node.js type definitions if needed:

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

cURL

cURL is pre-installed on many systems. Check whether it is available:

curl --version
Enter fullscreen mode Exit fullscreen mode

cURL is useful for quickly testing an endpoint without installing an SDK.

Step 5: Configure the API Key

Store the API key in an environment variable. Do not hardcode it in application source code.

Linux and macOS

Add the variable to ~/.bashrc, ~/.zshrc, or another shell profile:

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

Reload the profile:

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

Windows PowerShell

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

To make the variable permanent:

  1. Search for Environment Variables in the Start menu.
  2. Select Edit the system environment variables.
  3. Select Environment Variables.
  4. Under User variables, select New.
  5. Set the name to OPENAI_API_KEY.
  6. Enter your API key as the value.
  7. Restart the terminal.

Use a .env File During Development

Create a .env file in the project root:

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

Install python-dotenv for Python projects:

pip install python-dotenv
Enter fullscreen mode Exit fullscreen mode

Load the variable:

from dotenv import load_dotenv

load_dotenv()
Enter fullscreen mode Exit fullscreen mode

Never commit .env files. Add the file to .gitignore:

.env
Enter fullscreen mode Exit fullscreen mode

Step 6: Make Your First Request

Test the integration with a simple GPT-5.4 request.

Apidog can also be used to test the integration before writing application code. Its visual interface can help you:

  • Configure headers, authentication, and request bodies
  • Save requests to collections
  • Use environment variables across development, staging, and production
  • Add pre-request scripts
  • Create assertions for response validation
  • Generate cURL, Python, or Node.js snippets from working requests

Python

import os

from openai import OpenAI

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

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

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

Example 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 Model Access

If the API reports a model access error:

  • Confirm that billing is active.
  • Check that the API key has the required permissions.
  • Use the exact model name gpt-5.4.
  • Contact OpenAI support if the issue persists.

GPT-5.4 began rolling out gradually on March 5, 2026, so some accounts may experience delayed access.

GPT-5.4 API Pricing

Pricing depends on the number and type of tokens processed.

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

Processing Options

Batch Processing

  • 50% discount on standard rates
  • Requests are processed within a 24-hour window
  • Suitable for non-real-time workloads

Flex Processing

  • 50% discount on standard rates
  • Requests run during low-demand periods
  • Latency may vary from minutes to hours

Priority Processing

  • Costs 2x standard rates
  • Requests are processed ahead of the standard queue
  • Intended for time-sensitive workloads

Cost Calculation Example

Assume an application processes 10,000 customer support queries per month:

  • 500 input tokens per query
  • 200 output tokens per query
  • 5 million input tokens total
  • 2 million output tokens total

Standard pricing:

Input:  5M × $2.50/M = $12.50
Output: 2M × $15/M   = $30.00
Total:                 $42.50/month
Enter fullscreen mode Exit fullscreen mode

With Batch pricing at 50% off:

Input:  5M × $1.25/M = $6.25
Output: 2M × $7.50/M = $15.00
Total:                 $21.25/month
Enter fullscreen mode Exit fullscreen mode

Cost Optimization

Use the following techniques to control costs:

  • Cache repeated inputs where supported.
  • Keep system prompts concise.
  • Limit response length with the appropriate token parameter.
  • Use Batch processing for non-real-time workloads.
  • Configure billing alerts.
  • Track token usage for every request.

Repeated cached inputs are listed at $0.25 per million tokens compared with $2.50 per million standard input tokens.

Context Window Pricing

The stated standard context window is 272K tokens. Extended context can reach up to 1M tokens and uses a 2x usage rate.

For requests exceeding 272K tokens:

  • Input: $5.00 per million tokens
  • Output: $30.00 per million tokens

Rate Limits and Quotas

Rate limits depend on account tier and usage history.

Default Limits

Tier 1: New accounts

  • 20 requests per minute
  • 40,000 tokens per minute
  • 100,000 tokens per day

Tier 2: Established accounts

  • 60 requests per minute
  • 150,000 tokens per minute
  • 1,000,000 tokens per day

Tier 3: High-volume accounts

  • Custom limits based on the use case
  • Enterprise tiers may require contacting sales

Rate Limit Headers

Responses can include headers such as:

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

Handle HTTP 429 Responses

A rate-limited request returns HTTP 429 with an error similar to:

{
  "error": {
    "message": "Rate limit reached for requests",
    "type": "rate_limit_error",
    "code": "rate_limit_exceeded"
  }
}
Enter fullscreen mode Exit fullscreen mode

Implement exponential backoff and retry only when appropriate:

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:
            if attempt == max_retries - 1:
                raise

            wait_time = 2 ** attempt
            time.sleep(wait_time)
Enter fullscreen mode Exit fullscreen mode

For production systems:

  • Use exponential delays such as 1, 2, 4, and 8 seconds.
  • Add jitter to avoid synchronized retries.
  • Queue requests during traffic spikes.
  • Use Batch processing for bulk workloads.

Request Higher Limits

To request higher limits:

  1. Open Settings > Billing > Limits.
  2. Select Request limit increase.
  3. Provide your use case.
  4. Include expected monthly spend and peak traffic patterns.
  5. Add technical contact information.

The original guidance lists a review time of 1–3 business days. Approval depends on payment history, use case, technical requirements, and current capacity.

GPT-5.4 Access Across Platforms

GPT-5.4 access differs between the API, ChatGPT, and Codex.

API Access

Model names:

  • gpt-5.4
  • gpt-5.4-pro

Access method:

  • REST API through an SDK or HTTP client
  • API key authentication
  • Pay-per-token pricing

The API is intended for:

  • Custom applications
  • Production integrations
  • High-volume workloads
  • Tool use and computer use features

ChatGPT Access

GPT-5.4 Thinking is listed as available to:

  • ChatGPT Plus: $20/month
  • ChatGPT Team: $25/user/month
  • ChatGPT Pro: $200/month

GPT-5.4 Pro is listed as available to ChatGPT Pro and Enterprise subscribers.

Access is provided through:

  • The web interface at chatgpt.com
  • iOS and Android apps

ChatGPT subscriptions do not provide API access through the ChatGPT interface.

Codex Access

GPT-5.4 is listed as the default model in Codex with:

  • An experimental 1M-token context window
  • Playwright Interactive skill
  • /fast mode with 1.5x token velocity

Access methods include:

  • Codex desktop application
  • Codex cloud interface
  • Codex-specific API endpoints

Codex is intended for:

  • Software development
  • Code generation and debugging
  • Frontend development
  • Browser automation testing

Platform Comparison

Feature API ChatGPT Codex
GPT-5.4 access Yes Yes, Plus+ Yes
GPT-5.4 Pro Yes Yes, Pro+ Yes
Computer use Yes Limited Yes
Tool Search Yes No Yes
1M context Yes, experimental No Yes
Custom integrations Yes No Limited
Billing model Pay-per-use Subscription Subscription

Apidog for API Integration

Image

When integrating GPT-5.4 into an application, Apidog can support the API development workflow with:

  • Request testing: Configure and test GPT-5.4 requests through a visual interface.
  • Environment variables: Manage API keys across development, staging, and production.
  • Automated testing: Create assertions for response validation.
  • Mock servers: Simulate GPT-5.4 responses during frontend development.
  • Team collaboration: Share collections and documented integration patterns.
  • Code generation: Generate cURL, Python, Node.js, Go, and Java snippets.

Troubleshooting Common Issues

Model not found

Example error:

The model gpt-5.4 does not exist
Enter fullscreen mode Exit fullscreen mode

Possible causes:

  • The model name contains a typo.
  • Your account does not have access yet.
  • The API key lacks model permissions.

Try the following:

  1. Use the exact model name gpt-5.4.
  2. Confirm that billing is active.
  3. Generate a key with the required permissions.
  4. Wait up to 24 hours if the account was recently created.

Insufficient quota

Possible causes:

  • Daily or monthly token limits were reached.
  • A billing payment failed.
  • The account tier limit was reached.

Try the following:

  • Check usage at platform.openai.com/usage.
  • Verify that the payment method is current.
  • Request a higher limit under Settings > Billing > Limits.
  • Wait for the quota reset. Daily limits reset at midnight UTC according to the original guidance.

Authentication Failures

Example error:

Invalid authentication - Please provide a valid API key
Enter fullscreen mode Exit fullscreen mode

Check the following:

  • The OPENAI_API_KEY environment variable is set.
  • The key value is correct.
  • The key starts with sk-proj- or sk-.
  • The key has not been revoked or expired.

For a quick shell check:

echo $OPENAI_API_KEY
Enter fullscreen mode Exit fullscreen mode

If the key may have been compromised, revoke it and create a replacement. Restart the application after changing the environment variable.

Rate Limit Errors

For HTTP 429 responses:

  • Add exponential backoff.
  • Reduce request frequency.
  • Queue requests.
  • Use Batch processing for bulk work.
  • Request a higher limit for production traffic.

Billing Errors

For payment or billing errors:

  • Update the payment method in Settings > Billing.
  • Check the card expiration date.
  • Confirm that the billing address matches the card.
  • Contact the bank if charges are repeatedly declined.
  • Contact OpenAI support if the account needs review.

Timeout Errors

Possible causes include:

  • Network connectivity problems
  • Server-side processing delays
  • A client timeout that is too short

Possible mitigations:

  • Increase the HTTP client timeout.
  • Check network connectivity.
  • Add retry logic with backoff.
  • Use streaming for long-running requests.

Security Best Practices

Protect both your API keys and the data sent to the API.

Apidog can help create security test suites for GPT-5.4 integrations. For example, you can:

  • Test invalid-key and expired-token scenarios.
  • Validate rate-limit handling.
  • Create pre-request scripts for key rotation during testing.
  • Mock error responses.
  • Document security requirements in shared collections.

API Key Management

Do:

  • Store keys in environment variables.
  • Use a secret management system such as AWS Secrets Manager or HashiCorp Vault.
  • Rotate keys every 90 days.
  • Use separate keys for development, staging, and production.
  • Restrict permissions to the minimum required.

Do not:

  • Hardcode keys in source code.
  • Commit keys to version control.
  • Share keys through email or chat.
  • Use production keys in client-side code.
  • Log API keys.

Secure Request Patterns

Use HTTPS for every API request. Do not disable SSL verification.

Validate and sanitize user input before sending it to the API. For example:

def sanitize_input(user_input):
    dangerous_patterns = [
        "ignore previous instructions",
        "system prompt",
        "api key"
    ]

    for pattern in dangerous_patterns:
        user_input = user_input.replace(pattern, "[REDACTED]")

    return user_input
Enter fullscreen mode Exit fullscreen mode

This is only a basic example. Prompt-injection defenses should be designed for the specific application and threat model.

Log Usage, Not Sensitive Content

Record operational data such as token usage without logging sensitive prompts or responses:

import logging

logging.info(
    "API call completed: %s tokens",
    response.usage.total_tokens
)
Enter fullscreen mode Exit fullscreen mode

Avoid logging complete responses when they may contain sensitive information:

# Avoid:
logging.info(
    "API response: %s",
    response.choices[0].message.content
)
Enter fullscreen mode Exit fullscreen mode

Data Privacy

The original guidance lists the following considerations:

Zero Data Retention (ZDR): OpenAI offers ZDR for enterprise customers. It is intended for cases where API requests should not be stored for training and may be required for certain cyber safety features.

Data residency: EU data residency options are available for some customers. Contact OpenAI for details.

Personally identifiable information: Avoid sending unnecessary PII, including:

  • Names and email addresses
  • Phone numbers
  • Social security numbers
  • Financial account numbers
  • Health information

If PII is required:

  • Send only the minimum necessary data.
  • Anonymize data before the API call.
  • Encrypt data in transit and at rest.

Network Security

Enterprise accounts can configure IP allowlists to restrict API access to approved IP ranges.

AWS PrivateLink is listed as an available enterprise option for private connectivity to the OpenAI API. Contact OpenAI to confirm availability and requirements for your account.

If your application needs answers grounded in live web content rather than a static training snapshot, the Perplexity Search API offers a retrieval-augmented alternative worth benchmarking against GPT-5.4 for knowledge-intensive queries.

Once your credentials are provisioned, putting the GPT-5.4 API into practical use requires choosing the right request structure, model parameters, and prompting patterns for your workload.

Conclusion

Setting up the GPT-5.4 API involves six primary steps:

  1. Create an OpenAI account.
  2. Add a payment method and enable billing.
  3. Generate an API key with the required permissions.
  4. Install the Python or Node.js SDK, or use cURL.
  5. Store the key in an environment variable.
  6. Send a test request with the gpt-5.4 model.

For production integrations, add retry handling, usage monitoring, billing alerts, and key rotation before scaling traffic. Use Apidog to test requests, validate responses, mock API behavior, and document integration patterns for your team.

Pricing Summary

  • Standard: $2.50 per million input tokens and $15 per million output tokens
  • Pro: $30 per million input tokens and $180 per million output tokens
  • Batch and Flex: 50% discount on standard rates
  • Tier 2 defaults: 60 RPM, 150,000 TPM, and 1,000,000 TPD

Recommended Next Steps

  • Test the model with representative prompts.
  • Explore computer use, tool search, and vision capabilities.
  • Add exponential backoff and jitter.
  • Configure usage monitoring and billing alerts.
  • Review API key and data-handling practices.
  • Scale gradually while tracking token usage and response quality.

FAQ

How do I get access to the GPT-5.4 API?

Create an account at platform.openai.com, add a payment method in Billing settings, generate an API key, and use gpt-5.4 in your requests. Access began rolling out gradually on March 5, 2026.

Is the GPT-5.4 API free?

No. Standard pricing is $2.50 per million input tokens and $15 per million output tokens. New accounts are listed as receiving $5 in credit that expires after three months. Batch and Flex processing offer 50% discounts.

What is the difference between gpt-5.4 and gpt-5.4-pro?

The Pro version is intended for complex tasks and costs more:

  • Standard: $2.50 per million input tokens and $15 per million output tokens
  • Pro: $30 per million input tokens and $180 per million output tokens

Use the standard model for most workloads and evaluate Pro for tasks that require its additional capabilities.

How do I fix a model not found error?

Verify that the model name is exactly gpt-5.4. Check that billing is active and that your API key has model permissions. Newly created accounts may need to wait for access to become available.

What are the GPT-5.4 API rate limits?

The listed Tier 2 defaults are:

  • 60 requests per minute
  • 150,000 tokens per minute
  • 1,000,000 tokens per day

New accounts are listed at Tier 1 with:

  • 20 requests per minute
  • 40,000 tokens per minute
  • 100,000 tokens per day

Request higher limits through Settings > Billing > Limits.

Can I use GPT-5.4 for free in ChatGPT?

The original access information lists GPT-5.4 Thinking for ChatGPT Plus, Team, and Pro subscribers. API access uses separate pay-per-token pricing.

How can I reduce GPT-5.4 API costs?

Use cached inputs where supported, shorten prompts, limit response length, and use Batch processing for non-real-time workloads. Billing alerts and token usage tracking can also help identify unexpected costs.

Is GPT-5.4 available worldwide?

The API is listed as available in most countries where OpenAI operates, but some regions may have restrictions. Check availability during signup.

How do I rotate API keys securely?

Generate a new key, update every application and deployment system, run tests, confirm the new key works, and then delete the old key. Store keys in environment variables or a secret management system.

What happens if I exceed a rate limit?

The API returns HTTP 429. Implement exponential backoff with delays such as 1, 2, and 4 seconds, add jitter, and consider Batch processing or a limit increase for sustained production traffic.

Top comments (0)