APIs, model versions & pricing
How to read an AI pricing page, why input and output tokens cost different, and the habits that keep your bill predictable.
What an API actually is
An API (Application Programming Interface) is a contract: you send structured data (a prompt, some context), you get structured data back (a completion, a classification, a JSON object). No chat window, no UI โ just a request and a response over HTTP.
The simplest possible call looks like this:
curl https://api.example.com/v1/chat \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "Summarize this in one sentence: [text]"}
]
}'
That’s it. Every AI tool you’ve ever used โ ChatGPT, Copilot, your app’s AI feature โ is doing some version of this under the hood.
Why input and output cost different
Most AI APIs charge per million tokens, with two rates:
| Rate | Why | |
|---|---|---|
| Input tokens (your prompt) | Cheaper | The model reads these โ lower compute |
| Output tokens (the answer) | 2โ5ร more expensive | The model generates these one by one โ sequential, slower, more compute |
A typical pricing page:
Input: $3 per 1M tokens Output: $15 per 1M tokens
That 5ร difference is normal and reflects the real cost asymmetry of generation vs. reading.
A worked example
Let’s say you build a tool that:
- Sends a 2,000-token prompt (document + question)
- Gets back a 500-token answer
- Runs 1,000 times a day
Input: 2,000 ร 1,000 = 2,000,000 tokens โ $3.00
Output: 500 ร 1,000 = 500,000 tokens โ $7.50
Total per day: โ $10.50
Total per month: โ $315
That’s a real, usable number for a solo dev. Scale it by 10ร and you’re in “we need to optimize” territory.
The three billing surprises
- The system prompt is charged every time. If your app has a 2,000-token system prompt, that’s 2,000 input tokens on every single call. At high volume, the system prompt is often the biggest line item.
- Cached input is cheaper โ if you use it. Many providers charge less for input tokens they’ve seen before (prompt caching). If your prompts are repetitive, check whether caching is on.
- Free tiers have ceilings. “Free” often means “free up to 50 requests/day” or “free for 30 days”. Know the ceiling before you build on it.
Habits that keep the bill predictable
- Pin your model version. Models get deprecated; your code should fail loudly, not silently route to a new (possibly more expensive) model.
- Set a monthly budget in the provider’s dashboard, with alerts at 50% and 80%.
- Use a smaller model for high-volume tasks. A 10ร cheaper model is usually good enough for classification, extraction, and routing. Save the expensive one for the hard 20%.
- Log token counts per request. You can’t optimize what you don’t measure.