Guide · 5 min read

AI API Pricing Explained: Tokens, Images & Hidden Costs

Understand common AI API billing units, token pricing, image costs, and how to estimate spend before production.

In this guideWhat a token is, why input and output cost different amounts, how images are priced, the costs people miss, and a worked example for estimating a monthly bill.

The billing unit: tokens

Language models don't count words or characters. They split text into tokens, which are common chunks of letters. Short words are usually one token; longer or rarer words are several. In English, 1,000 tokens is roughly 750 words, or about a page and a half. Code, numbers and languages other than English tend to use more tokens for the same amount of text.

Prices are quoted per one million tokens. To price a request, you need two numbers: how many tokens you sent and how many came back.

Input and output are priced separately

Nearly every API has two prices for each model:

The output price is usually several times the input price, because generating text takes much more computation than reading it. The formula for one request is:

cost = (input tokens × input price + output tokens × output price) ÷ 1,000,000

A worked example

Say a model costs $1.00 per million input tokens and $5.00 per million output tokens. A request sends 4,000 tokens and gets 500 back:

input:   4,000 × $1.00 ÷ 1,000,000 = $0.0040
output:    500 × $5.00 ÷ 1,000,000 = $0.0025
total:                               $0.0065

Notice that the output was only 11% of the tokens but 38% of the cost. That ratio is why the shape of your traffic matters as much as its size.

Know your mix

Kind of workTypical mixWhat drives the cost
Classification, extraction, routingAlmost all inputInput price, and how much context you send
Coding agentsUsually more than 90% inputHistory resent on every step
Chat assistantsMostly input, growing over the conversationLength of the conversation
SummariesMostly inputSize of the source text
Long-form writingMostly outputOutput price

If you don't know your mix, measure it. Any decent provider shows input and output tokens for each request. A week of real numbers is worth more than any estimate.

How images are priced

Images work in two directions, and they are billed differently:

The costs people miss

Resent history

The model does not remember the conversation. Your app sends it again with every message. The tenth message in a chat pays for the first nine again. Long-running agents are the extreme case: each step can resend everything read and written so far.

System prompts and tool definitions

A 2,000-token system prompt is billed on every single request. So is the description of every tool you make available. A long list of tools can cost more than the user's actual question.

Reasoning tokens

Models that reason before answering produce tokens you never see, and they are billed as output. A short visible answer can hide a much larger charge. Most APIs let you choose how much effort the model spends.

Retries

Every retry of a billed request is paid for again. Find out whether your provider charges for failed requests. CheapTokens does not.

Estimated usage

If a stream is cut off before the model reports its usage, a provider has to estimate. Check how that is handled and whether such requests are marked. On CheapTokens they are labelled "Estimated" in your history.

Prepaid and postpaid

With postpaid billing you get an invoice for whatever was used, which is convenient until a bug or a leaked key runs up a large amount. With prepaid billing you top up a balance and requests stop when it runs out. That caps your risk at the balance, at the price of having to top up.

Prepaid gateways often work with a hold: when a request starts, an estimate of its cost is set aside; when it finishes, the exact amount is charged and the rest is released. You may see your available balance dip briefly during a long request and then recover.

Estimating a monthly bill

  1. Count requests. For example, 2,000 users sending 10 messages a day is 600,000 requests a month.
  2. Measure an average request. Use real traffic if you can. Say 3,000 input tokens and 400 output tokens.
  3. Multiply. That is 1.8 billion input tokens and 240 million output tokens a month.
  4. Apply the prices. At $1.00 and $5.00 per million: $1,800 for input and $1,200 for output, $3,000 in total.
  5. Add a margin. Allow 20 to 30% for retries, long conversations and growth.

Then ask what would change the result most. In this example, halving the average input by trimming history saves $900 a month. Moving simple requests to a model that costs a quarter as much could save far more.

Keeping it under control

On CheapTokens, the dashboard shows every request with its input tokens, output tokens and exact charge, and each API key can carry its own spend limit. See the current prices or the billing section of the docs.

Create a CheapTokens account ↗

Related guides