L;DR
GPT-5.4 mini costs $0.75 per 1M input tokens and $4.50 per 1M output tokens, supports a 400k context window, and delivers 2x the speed of GPT-5 mini. You can access the GPT-5.4 mini API with the model ID gpt-5.4-mini via OpenAI's API and test it visually with Apidog or programmatically with Python, including unit tests to validate integration.
Introduction
OpenAI launched GPT-5.4 mini in March 2026 as its most capable small model, offering near-flagship performance at a lower cost. If you're assessing GPT-5.4 mini Pricing for production or want to integrate the GPT-5.4 mini API into your application, this guide covers actionable steps: pricing breakdown, API features, and hands-on integration with both a GUI workflow (Apidog) and a Python code approach—including unit testing.
💡 Tip: Before calling the GPT-5.4 mini API, download Apidog for free. With Apidog, you can test prompts, inspect responses, add unit test assertions, and track token usage visually—no code or tokens needed.
GPT-5.4 mini Pricing Breakdown
GPT-5.4 mini Pricing is designed for scalable, high-volume production. Here’s what you need to know before using the GPT-5.4 mini API:
GPT-5.4 mini Input and Output Token Costs
- Input tokens: $0.75 per 1M tokens
- Output tokens: $4.50 per 1M tokens
- Context window: 400,000 tokens
For regional endpoints (data residency), OpenAI applies a 10% uplift: input tokens are $0.825/1M, output tokens $4.95/1M.
GPT-5.4 mini vs GPT-5.4 nano Pricing Comparison
| 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 lowest cost, but GPT-5.4 mini balances price and performance, especially for coding, reasoning, and multimodal workloads.
GPT-5.4 mini Pricing in Codex
When running GPT-5.4 mini API in OpenAI’s Codex environment, it consumes 30% of the GPT-5.4 quota. This is ideal for multi-agent setups: use GPT-5.4 for planning and GPT-5.4 mini for parallel subtasks at one-third the quota.
GPT-5.4 mini API Capabilities
The GPT-5.4 mini API supports:
- Text and image inputs (multimodal)
- Tool use and function calling (structured outputs)
- Web search (live data grounding)
- File search (query uploaded docs)
- Computer use (desktop automation)
- Skills (task modules)
It runs 2x faster than GPT-5 mini and approaches GPT-5.4 performance on SWE-Bench Pro and OSWorld-Verified benchmarks. Available via OpenAI API, Codex, and ChatGPT.
Model ID:
gpt-5.4-mini
How to Use GPT-5.4 mini API with Apidog
Apidog is a GUI API development platform for designing, debugging, testing, and documenting APIs—no code required. Use it to call the GPT-5.4 mini API and run unit tests on responses.
Download Apidog for free and follow these steps:
Setting Up the GPT-5.4 mini API Request in Apidog
Open Apidog and create a new project (e.g.,
GPT-5.4 mini API Test).-
Create a new HTTP request:
- Method:
POST - URL:
https://api.openai.com/v1/chat/completions
- Method:
Add headers under the Headers tab:
| Key | Value |
|---|---|
| Authorization | Bearer YOUR_OPENAI_API_KEY |
| Content-Type | application/json |
- Set the request body (Body → JSON):
{
"model": "gpt-5.4-mini",
"messages": [
{
"role": "user",
"content": "Explain what a unit test is in one sentence."
}
],
"temperature": 0.7,
"max_tokens": 200
}
- Click Send. Apidog will display the response, including token usage, so you can estimate real-time costs.
Sample 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
}
}
Writing Unit Tests for GPT-5.4 mini API in Apidog
After sending your request, use the Tests tab to add assertions:
// Unit test 1: Verify HTTP status is 200
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
// Unit test 2: Confirm the correct 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");
});
// Unit test 3: Response contains a message
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;
});
// Unit test 4: Token usage is reported
pm.test("Token usage is present", function () {
const json = pm.response.json();
pm.expect(json.usage.total_tokens).to.be.above(0);
});
These assertions cover status, model identity, response content, and token usage. Apidog will run these tests automatically on each request. Save the request as part of an Apidog test suite for CI/CD with the CLI runner.
How to Use GPT-5.4 mini API with Python
For code-based integrations, here’s a complete Python example using openai and pytest.
Installation
pip install openai pytest
Basic GPT-5.4 mini API Call
# gpt54mini_client.py
from openai import OpenAI
client = OpenAI() # reads OPENAI_API_KEY from environment
def ask_gpt54_mini(prompt: str) -> dict:
"""Call the GPT-5.4 mini API and return the full response."""
response = client.chat.completions.create(
model="gpt-5.4-mini", # GPT-5.4 mini API model ID
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"])
# Estimate cost based on GPT-5.4 mini Pricing
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}")
Unit Test for GPT-5.4 mini API
# test_gpt54mini_client.py
import pytest
from unittest.mock import patch, MagicMock
from gpt54mini_client import ask_gpt54_mini
@pytest.fixture
def mock_openai_response():
"""Mock the GPT-5.4 mini API response for unit testing."""
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):
"""Unit test: GPT-5.4 mini API 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):
"""Unit test: confirms gpt-5.4-mini model ID is used."""
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):
"""Unit test: token usage is present for GPT-5.4 mini Pricing tracking."""
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"]
Run the unit tests:
pytest test_gpt54mini_client.py -v
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
Mocking the GPT-5.4 mini API in your unit tests keeps your CI pipeline fast and avoids token costs.
GPT-5.4 mini API Best Practices
-
Track token usage: Log
prompt_tokensandcompletion_tokensper request. Costs can grow quickly with verbose prompts. - Use Apidog for prototyping: Test prompts and response structures visually before coding to save time and avoid waste.
-
Write unit tests early: Mock the API for testing. Use Apidog’s test scripts or
pytestwithunittest.mock. - Leverage the 400k context window wisely: Only pass relevant context to control costs.
- Avoid regional endpoints unless required: They add a 10% pricing uplift; only use if compliance demands it.
- Delegate to GPT-5.4 mini in multi-agent systems: Use GPT-5.4 for planning and GPT-5.4 mini for parallel tasks.
Conclusion
GPT-5.4 mini Pricing ($0.75/1M input, $4.50/1M output) offers cost-effective, high-performance AI. The GPT-5.4 mini API supports multimodal inputs, tool use, web search, and more—at double the speed of the previous mini version.
For implementation:
- Start with Apidog for visual exploration.
- Move to code for production using Python.
- Set up unit tests to validate and control costs.
Try Apidog free—no credit card required.
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 endpoints add 10%.
What is the GPT-5.4 mini API model ID?
Use gpt-5.4-mini as the model parameter.
How do I test the GPT-5.4 mini API without writing code?
Use Apidog. Create a POST request to https://api.openai.com/v1/chat/completions with your API key and model ID. Add unit test assertions in the UI.
How do I write a unit test for the GPT-5.4 mini API?
Mock the API using unittest.mock in Python and assert on the response. In Apidog, use the Tests tab for JavaScript-based assertions.
How does GPT-5.4 mini Pricing compare to GPT-5.4 nano?
GPT-5.4 nano is cheaper ($0.20/1M input, $1.25/1M output), but GPT-5.4 mini delivers better performance on coding and reasoning tasks.
Can I use the GPT-5.4 mini API in Codex?
Yes—GPT-5.4 mini API is available in Codex and consumes 30% of the GPT-5.4 quota.
Is GPT-5.4 mini available in ChatGPT?
Yes—available via OpenAI API, Codex, and ChatGPT.
Top comments (0)