- The cost of a call is input tokens times the input price plus output tokens times the output price, divided by a million.
- The output price may include reasoning tokens, so long thinking raises the bill.
- Prompt caching and batch processing can lower the cost, but they have their own rules.
An API bill looks mysterious only until you calculate it once. Then it turns out to consist of two numbers multiplied by two prices. This text shows the formula, gives an example with data from makers’ pages and lists the things that most often cause surprises. More about the concept of price is in the glossary entry on the price per million tokens, and about the number of tokens in the entry on the token.
The formula for one call
Makers give prices per million tokens, separately for input and output. The cost of one call is the number of input tokens divided by a million and multiplied by the input price, plus the number of output tokens divided by a million and multiplied by the output price. Input counts everything you send: the system instruction, conversation history, pasted documents and the question. Output counts everything the model generates. At makers who also bill reasoning, thinking tokens are added to the output.
A good habit is counting tokens with the maker’s tool instead of guessing from words. Anthropic’s documentation has a page on token counting, and other providers have analogous tools. The number of tokens depends on the tokenizer, so the same text yields different values in different models, and Polish text usually uses more of them than English.
An example with numbers
Take a typical task: classifying a ticket, where the input is 2000 tokens (the instruction plus the content) and the output is 500 tokens. The prices come from makers’ pages of 20 October 2026 and serve only to illustrate the method.
| Fast class ($0.10 / $0.50) | Balanced class ($2 / $10) | Flagship class ($10 / $50) | |
|---|---|---|---|
| Cost of one call | $0.00045 | $0.009 | $0.045 |
| Cost of 1000 calls | $0.45 | $9 | $45 |
| Cost of a million calls | $450 | $9,000 | $45,000 |
The calculation for the balanced class: 2000 divided by a million gives 0.002, times $2 is $0.004 for input, and 500 divided by a million is 0.0005, times $10 is $0.005 for output. In total $0.009 per call, that is $9 per thousand. The difference between classes is a hundredfold, so matching the class to the task is the biggest cost lever. I write about how to do that in the article How to choose a model for the task.
What changes the bill
The first thing is reasoning. Google’s pricing page states that the output price includes thinking tokens, so longer reasoning raises the cost although the visible answer is the same. The second is prompt caching: in its Contextual Retrieval write-up Anthropic notes that caching frequently used prompts between calls can cut latency by more than 2x and cost by up to 90%, and Google’s pricing has a separate, lower price for cached tokens. The third is batch processing: Google describes a Batch API with a 50% cost reduction for tasks that do not need an immediate answer. The fourth is long context: the more you paste into each call, the higher the bill, so make sure you do not send the whole history when a summary of it is enough.
- 01MeasureCount input and output tokens on a sample.
- 02MultiplyBy prices from the official page.
- 03SumCost per call times the number of calls.
- 04AddReasoning, retries and errors.
- 05OptimizeShorter prompt, caching, batch.
- 06ControlSet spending limits and bill alerts.
How to plan a budget
When planning, do not count one call but a monthly scenario: how many tasks a day, how many calls per task (an agent can make a dozen) and what share ends in a retry or an error. Add a margin for reasoning and for price changes, because price lists are sometimes scheduled; in the text on comparing model prices I show an example of a price that is set to rise from a given day. Set spending limits with the provider and alerts, so that a bug in a loop cannot burn the budget overnight. Once a month compare the bill with the assumption and correct the cost model. It is also good to log in the application the number of tokens of every call from the API response, because makers return it with the result. That way you will see which product features generate the largest cost and know where optimization gives the most.
Last checked: 20 October 2026. Prices come from makers’ pages of that day; check the current ones before you buy.

