Token cost calculation

· 3 min read

Token cost calculation is the way you work out what a call to an LLM API costs: you count the input tokens and output tokens, multiply each by the model's price for that kind of token, and add the two. Prices are quoted per million tokens, and output tokens usually cost more than input.

The formula

The basic formula is Total = input tokens × input price + output tokens × output price. Divide each token count by one million first when the price is per million tokens.

Two adjustments matter in practice:

How many tokens is my text?

A token is a piece of a word. As a rough guide, 1 token is about 4 characters of English, and 1,000 tokens is about 750 words. Short common words are often one token: "hello" is 1 token, while "ChatGPT" is about 2 tokens.

Language changes the count. Non-English text needs 20-30% more tokens for the same meaning, so the same feature can cost more for users who write in other languages. For an exact count, use the tokenizer for your model or read the token counts the API returns with each response.

Example prices per million tokens

These are list prices from one price tracker. Check the provider's own pricing page before you budget, because prices change.

ModelInputCached inputOutput
GPT-6 Astra$10.00$1.00$50.00
Claude Opus 5.5$4.00$0.20$20.00
Grok 4.7$2.00Not stated$6.00
Gemini 3.8 Flash$0.75$0.075$3.75
DeepSeek Flash V4.1$0.15 (cache miss)$0.003 (cache hit)$0.60

Across the market, input prices ran from $0.15 to $5.00 per million and output from $0.60 to $25.00 per million as of January 2026. Output typically costs 3-5x input.

Why the calculated cost and the bill differ

The formula gives the cost of one call. The bill is the sum of every call, including the ones that did not help anyone:

  • a request re-sent after a timeout, paid twice
  • an agent that repeats the same step, resending its whole history each time
  • a prompt sent many times a day that never hits the cache
  • a streamed answer the user closed early, still billed for what was generated
  • an answer cut off at the token limit and asked for again

Each of these is priced with the same formula, so per call math looks fine while the monthly total grows. To find them you need a record of each call, grouped by the task or agent run it belonged to. Zexl keeps that record from token counts and timing only and prices these patterns, without storing prompt text.

FAQ

How is token cost calculated?

Multiply input tokens by the input price and output tokens by the output price, then add them. Price cached input at its own lower rate if the provider has one.

How much do 500,000 tokens cost?

It depends on the model and on how the tokens split between input and output. Use the formula above with your model's prices: divide each token count by one million and multiply by the price per million.

How many words are 10,000 tokens?

At about 750 words per 1,000 tokens, scale that rate up for English text. Other languages give fewer words for the same number of tokens.

What does 1,000 tokens cost?

Take the price per million tokens and divide it by one thousand. Do it separately for input and output, since output usually costs more.

See where your own AI spend goes

One import in a Python app, or five environment variables for Claude Code. Prompts never leave your servers.