DEV Community

Preecha
Preecha

Posted on

GPT-5.4 mini Pricing and How to Use GPT-5.4 mini API

L;DR

GPT-5.4 mini costs $0.75 per 1M input tokens and $4.50 per 1M output tokens, with a 400k context window and 2x the speed of GPT-5 mini. Call it with the gpt-5.4-mini model ID through OpenAI's API, then validate responses visually in Apidog or programmatically with Python and pytest.

Try Apidog today

Introduction

OpenAI announced GPT-5.4 mini in March 2026 as its most capable small model yet, bringing near-flagship intelligence at a lower cost. This guide covers GPT-5.4 mini pricing, API capabilities, and two integration paths:

  1. Test requests and assertions in Apidog.
  2. Build and test a Python integration with pytest.

Before calling the API, download Apidog for free. You can test prompts, inspect responses, add unit test assertions, and review token usage visually without writing code.

GPT-5.4 mini Pricing Breakdown

Input and output token costs

GPT-5.4 mini pricing:

  • Input tokens: $0.75 per 1M tokens
  • Output tokens: $4.50 per 1M tokens
  • Context window: 400,000 tokens

For regional processing, OpenAI applies a 10% uplift:

  • Regional input tokens: $0.825 per 1M tokens
  • Regional output tokens: $4.95 per 1M tokens

GPT-5.4 mini vs. GPT-5.4 nano

Model Input (per 1M tokens) Output (per 1M tokens) Context window
GPT-5.4 ~$5.00 ~$20.00 400k
GPT-5.4 mini $0.75 $4.50 400k
GPT-5.4 nano $0.20 $1.25 400k

GPT-5.4 nano is the lower-cost option. GPT-5.4 mini is positioned between cost and capability for coding, reasoning, and multimodal tasks where nano may not be sufficient.

GPT-5.4 mini in Codex

In OpenAI's Codex environment, GPT-5.4 mini consumes 30% of the GPT-5.4 quota. A practical multi-agent split is:

  • Use GPT-5.4 for planning and coordination.
  • Use GPT-5.4 mini for parallel, narrowly scoped subtasks.

GPT-5.4 mini API Capabilities

GPT-5.4 mini supports:

  • Text and image inputs
  • Tool use and function calling
  • Structured outputs for agentic workflows
  • Web search
  • File search over uploaded documents
  • Computer use
  • Skills for composable task modules

The model runs more than 2x faster than GPT-5 mini and approaches GPT-5.4 performance on benchmarks including SWE-Bench Pro and OSWorld-Verified.

Use this model ID in API requests:

gpt-5.4-mini
Enter fullscreen mode Exit fullscreen mode

How to Use GPT-5.4 mini API with Apidog

Apidog provides a GUI workflow for creating, sending, debugging, and testing API requests. Use it to validate your request format and response schema before wiring the API into application code.

Create the request

  1. Open Apidog and create a project, such as GPT-5.4 mini API Test.
  2. Create a new HTTP request with these settings:
Setting Value
Method POST
URL https://api.openai.com/v1/chat/completions
  1. Add these headers:
Key Value
Authorization Bearer YOUR_OPENAI_API_KEY
Content-Type application/json
  1. Under Body → JSON, add this request body:
{
  "model": "gpt-5.4-mini",
  "messages": [
    {
      "role": "user",
      "content": "Explain what a unit test is in one sentence."
    }
  ],
  "temperature": 0.7,
  "max_tokens": 200
}
Enter fullscreen mode Exit fullscreen mode
  1. Click Send.

Apidog displays the full response, including token usage. Use the returned usage values to estimate request costs.

Example response:

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "gpt-5.4-mini",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "A unit test is an automated check that verifies a single function or component behaves as expected in isolation."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 28,
    "total_tokens": 46
  }
}
Enter fullscreen mode Exit fullscreen mode

Add response assertions in Apidog

Open the Tests tab and add assertions for the response status, model, content, and token usage:

// Verify HTTP status
pm.test("Status code is 200", function () {
  pm.response.to.have.status(200);
});

// Confirm the requested model was used
pm.test("GPT-5.4 mini API model is correct", function () {
  const json = pm.response.json();
  pm.expect(json.model).to.include("gpt-5.4-mini");
});

// Verify the response contains assistant content
pm.test("Response has assistant message", function () {
  const json = pm.response.json();
  pm.expect(json.choices[0].message.content)
    .to.be.a("string")
    .and.not.empty;
});

// Verify token usage is returned
pm.test("Token usage is present", function () {
  const json = pm.response.json();
  pm.expect(json.usage.total_tokens).to.be.above(0);
});
Enter fullscreen mode Exit fullscreen mode

These assertions validate the core integration contract:

  • The request succeeded.
  • The expected model handled the request.
  • The API returned assistant content.
  • Token usage is available for cost tracking.

Save the request in an Apidog test suite to run it through CI/CD using Apidog's CLI runner.

How to Use GPT-5.4 mini API with Python

For production code, install the OpenAI SDK and pytest:

pip install openai pytest
Enter fullscreen mode Exit fullscreen mode

Create a GPT-5.4 mini client

Create gpt54mini_client.py:

from openai import OpenAI

client = OpenAI()  # Reads OPENAI_API_KEY from the environment

def ask_gpt54_mini(prompt: str) -> dict:
    """Call GPT-5.4 mini and return content plus usage metadata."""
    response = client.chat.completions.create(
        model="gpt-5.4-mini",
        messages=[
            {"role": "user", "content": prompt}
        ],
        temperature=0.7,
        max_tokens=500
    )

    return {
        "content": response.choices[0].message.content,
        "model": response.model,
        "total_tokens": response.usage.total_tokens,
        "prompt_tokens": response.usage.prompt_tokens,
        "completion_tokens": response.usage.completion_tokens,
    }

if __name__ == "__main__":
    result = ask_gpt54_mini("What is a unit test?")
    print(result["content"])

    input_cost = (result["prompt_tokens"] / 1_000_000) * 0.75
    output_cost = (result["completion_tokens"] / 1_000_000) * 4.50

    print(f"Estimated cost: ${input_cost + output_cost:.6f}")
Enter fullscreen mode Exit fullscreen mode

Set your API key before running the script:

export OPENAI_API_KEY="your_api_key"
python gpt54mini_client.py
Enter fullscreen mode Exit fullscreen mode

Unit test the integration without calling the API

Mock the client so CI does not consume tokens. Create test_gpt54mini_client.py:

import pytest
from unittest.mock import MagicMock, patch

from gpt54mini_client import ask_gpt54_mini

@pytest.fixture
def mock_openai_response():
    """Mock a GPT-5.4 mini API response."""
    mock_response = MagicMock()
    mock_response.choices[0].message.content = (
        "A unit test verifies a single function in isolation."
    )
    mock_response.model = "gpt-5.4-mini"
    mock_response.usage.total_tokens = 46
    mock_response.usage.prompt_tokens = 18
    mock_response.usage.completion_tokens = 28
    return mock_response

@patch("gpt54mini_client.client.chat.completions.create")
def test_returns_content(mock_create, mock_openai_response):
    """GPT-5.4 mini returns non-empty content."""
    mock_create.return_value = mock_openai_response

    result = ask_gpt54_mini("What is a unit test?")

    assert isinstance(result["content"], str)
    assert len(result["content"]) > 0

@patch("gpt54mini_client.client.chat.completions.create")
def test_correct_model(mock_create, mock_openai_response):
    """The response identifies GPT-5.4 mini."""
    mock_create.return_value = mock_openai_response

    result = ask_gpt54_mini("Hello")

    assert result["model"] == "gpt-5.4-mini"

@patch("gpt54mini_client.client.chat.completions.create")
def test_token_usage_reported(mock_create, mock_openai_response):
    """Token usage is available for pricing calculations."""
    mock_create.return_value = mock_openai_response

    result = ask_gpt54_mini("Hello")

    assert result["total_tokens"] > 0
    assert result["prompt_tokens"] + result["completion_tokens"] == result["total_tokens"]
Enter fullscreen mode Exit fullscreen mode

Run the tests:

pytest test_gpt54mini_client.py -v
Enter fullscreen mode Exit fullscreen mode

Expected output:

test_gpt54mini_client.py::test_returns_content      PASSED
test_gpt54mini_client.py::test_correct_model        PASSED
test_gpt54mini_client.py::test_token_usage_reported PASSED

3 passed in 0.31s
Enter fullscreen mode Exit fullscreen mode

Mocking API calls keeps test suites fast and prevents token usage during CI runs.

GPT-5.4 mini API Best Practices

1. Track input and output tokens

Log prompt_tokens and completion_tokens for every request. Input tokens cost $0.75 per 1M tokens, while output tokens cost $4.50 per 1M tokens.

Keep prompts and system instructions focused, especially for high-volume workloads.

2. Prototype requests before writing integration code

Use Apidog to verify:

  • Request headers
  • JSON payload structure
  • Response shape
  • Token usage fields
  • Error responses

This helps catch request issues before they reach application code.

3. Mock API calls in unit tests

Do not call the live API in standard unit tests. Mock the API client and test your own behavior around:

  • Parsing assistant content
  • Handling response metadata
  • Tracking token counts
  • Propagating errors

Use live calls separately for integration or smoke tests.

4. Use the 400k context window selectively

GPT-5.4 mini supports 400k tokens of context, but all processed tokens affect cost. In RAG pipelines, retrieve only the most relevant chunks instead of sending every available document.

5. Use regional endpoints only when necessary

Regional processing adds a 10% uplift. Use data residency endpoints when compliance requirements require them.

6. Delegate focused agent tasks to GPT-5.4 mini

For multi-agent workflows, reserve GPT-5.4 for planning and coordination. Route parallel, high-frequency subtasks to GPT-5.4 mini.

Conclusion

GPT-5.4 mini costs $0.75 per 1M input tokens and $4.50 per 1M output tokens, with a 400k-token context window. It supports multimodal inputs, function calling, web search, file search, computer use, and skills.

Start by validating requests in Apidog, including response assertions and token usage checks. Then move to a Python integration with mocked unit tests so your CI pipeline stays fast and does not consume API tokens.

FAQ

What is GPT-5.4 mini pricing?

GPT-5.4 mini costs $0.75 per 1M input tokens and $4.50 per 1M output tokens. Regional processing endpoints add a 10% uplift.

What is the GPT-5.4 mini API model ID?

Use gpt-5.4-mini as the model parameter.

How do I test GPT-5.4 mini without writing code?

Use Apidog to create a POST request to:

https://api.openai.com/v1/chat/completions
Enter fullscreen mode Exit fullscreen mode

Set the model to gpt-5.4-mini, send the request, and add assertions in the Tests tab.

How do I write a unit test for GPT-5.4 mini?

In Python, mock the OpenAI client with unittest.mock and assert against the response data your code returns. In Apidog, add JavaScript assertions in the Tests tab.

How does GPT-5.4 mini compare with GPT-5.4 nano?

GPT-5.4 nano costs $0.20 per 1M input tokens and $1.25 per 1M output tokens. GPT-5.4 mini costs more but provides stronger capability for coding and reasoning tasks.

Can I use GPT-5.4 mini in Codex?

Yes. GPT-5.4 mini is available in Codex and consumes 30% of the GPT-5.4 quota.

Is GPT-5.4 mini available in ChatGPT?

Yes. GPT-5.4 mini is available through the OpenAI API, Codex, and ChatGPT.

Top comments (0)