The API is the same models without the chat app. You pay for tokens, nothing else: no monthly fee, no usage cap beyond rate limits, no Projects or memory unless you build them. That makes it the cheapest option for moderate programmatic use and the most expensive option for someone who wants a chat window.
Token maths in 60 seconds
Prices are quoted per million tokens. At the time of writing our catalogue lists GPT-5.4 mini at $0.75 input and $4.50 output per 1M. A call with 2,000 input tokens and 500 output tokens therefore costs 0.002 × 0.75 + 0.0005 × 4.50, about $0.0038. A thousand such calls is under $4. The same thousand calls on GPT-5.5 ($5 in, $30 out) would be about $25.
In a multi-turn conversation, the whole history is re-sent as input on every turn. That is why long chats get expensive and why starting a fresh conversation for a new topic is a cost decision, not just a tidiness one.
Your first call
Create an API key at platform.openai.com/api-keys, add a small prepaid balance, and set it as an environment variable. The Responses API is OpenAI's current primary endpoint; the older Chat Completions endpoint still works but the examples below use Responses.
export OPENAI_API_KEY="sk-..."
curl https://api.openai.com/v1/responses \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4-mini",
"input": "Rewrite this in one sentence: The meeting that was scheduled for Tuesday has been moved to Thursday at the same time."
}'from openai import OpenAI
client = OpenAI() # reads OPENAI_API_KEY from the environment
response = client.responses.create(
model="gpt-5.4-mini",
input="Rewrite this in one sentence: The meeting that was scheduled for Tuesday has been moved to Thursday at the same time.",
)
print(response.output_text)
print(response.usage) # input_tokens, output_tokens, cached tokensThe usage object on every response tells you exactly what you were billed for. Log it from day one. The full reference is at platform.openai.com/docs/api-reference/responses, and current prices are at platform.openai.com/docs/pricing.
Prompt caching
Caching is why the order of your prompt matters. Put the long, unchanging content first (instructions, a policy document, a code file) and the user's question last. Anything before the first change can be cached; anything after it cannot. The mechanics and the current discount are documented at platform.openai.com/docs/guides/prompt-caching.
Batch API
If you do not need the answer now, the Batch API runs jobs asynchronously within a window at a discounted rate. Our catalogue lists batch variants of the main models at half the standard per-token price at the time of writing, for example GPT-5.4 at $1.25 in and $7.50 out per 1M versus $2.50 and $15 standard. The workflow is: upload a JSONL file of requests, submit the batch, download the results. Details at platform.openai.com/docs/guides/batch.
Knowledge check
Which change reduces API cost for an app that sends the same 5,000-token policy document with every user question?