Build radar
Sources 33Updates always the freshest
0 Newsletter
Animated illustration for: Task cost in tokens: how to calculate your API bill step by step
TestLAB · Model & API pricing · Guide · 9 min read

Task cost in tokens: how to calculate your API bill step by step

A formula for the cost of one call, a worked example for two model classes and the things that change the bill: reasoning tokens, caching and batch processing.

In short
  • 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.

Cost of 1000 calls of 2000 input and 500 output tokens
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.

  1. 01
    MeasureCount input and output tokens on a sample.
  2. 02
    MultiplyBy prices from the official page.
  3. 03
    SumCost per call times the number of calls.
  4. 04
    AddReasoning, retries and errors.
  5. 05
    OptimizeShorter prompt, caching, batch.
  6. 06
    ControlSet 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.

Frequently asked questions

How many words is one token?
It depends on the language and the tokenizer, so there is no fixed conversion. Polish usually uses more tokens per word than English. The exact number comes from the maker's token counting tool.
Why does an answer cost more than a question?
Makers price output tokens higher than input tokens because generating is more expensive than reading. In the documentation's examples the ratio is usually several-fold.
Do thinking tokens cost too?
Yes. Google states plainly that the output price includes thinking tokens, so long reasoning increases the bill without a longer visible answer.
How can I lower cost without changing the model?
Shorten the constant parts of the prompt, use caching for repeated fragments, limit the length of answers and move non-urgent tasks to batch processing if the maker offers it.

Sources

Model & API pricing

Related