AI, LLM & Machine Learning Engineering LLM Inference Cost & Serving Per-million-token billing convention

LLM API Token Cost Calculator

Large-language-model APIs bill per million tokens, with output tokens costing several times more than input tokens and cached input costing a fraction of either. That asymmetry is what makes per-request cost hard to guess: a request with a 20,000-token prompt and a 200-token answer can cost less than one with a 500-token prompt and a 4,000-token answer. Enter your token counts, your provider's three prices and your request volume, and this calculator returns cost per request, per thousand requests, per month and per year, together with the share of the bill each side is responsible for.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Input tokens per requestSystem prompt, retrieved context, conversation history and user message combined; roughly words × 1.33 or characters ÷ 4 for English.1500 tok
Output tokens per requestTokens the model generates in reply, including any reasoning tokens the provider bills as output.500 tok
Input price per 1M tokensTake the current figure from your provider's pricing page — model prices change often and vary by tier.3 $
Output price per 1M tokensUsually three to five times the input price, because generation is far more compute-intensive than reading a prompt.15 $
Cached input price per 1MPrice for prompt-cache reads, where offered; commonly a tenth of the standard input price.0.3 $
Share of input served from cachePercentage of input tokens that are an unchanged prefix hitting the prompt cache; leave at 0 if you do not use caching.0 %
Requests per dayAverage daily call volume at the scale you are budgeting for.5000
Billing days per monthUse 30 for a continuous consumer product, or about 22 for an internal tool used on working days only.30 d

It returns

  • Cost per request — Input plus output, with any cached share priced at the cache rate.
  • Cost per 1,000 requests
  • Monthly spend
  • Annual spend
  • Output share of the cost
  • Monthly effect of prompt caching
  • Tokens per month

The formula

C=TinPin106+ToutPout106
M=CRd

In plain text: cost = (fresh_in ÷ 10⁶ × P_in) + (cached_in ÷ 10⁶ × P_cache) + (out ÷ 10⁶ × P_out)

  • T_inInput tokens per request, split into fresh and cached (tokens)
  • T_outOutput tokens generated per request (tokens)
  • P_inPrice per million input tokens ($/1M)
  • P_outPrice per million output tokens ($/1M)
  • P_cachePrice per million cached input tokens read ($/1M)
  • CCost of one request ($)

Prices are quoted per million tokens, so dividing the token count by 10^6 before multiplying keeps the units straight. Monthly spend is this figure times requests per day times billing days.

Updated Category LLM Inference Cost & Serving Verified against published test cases Reading time 11 min

What a token is, and why input and output have different prices

A token is a chunk of text the model treats as one unit — usually a common word, a word fragment, or a piece of punctuation. English averages roughly four characters per token, which works out at about 1.33 tokens per word. Code, non-Latin scripts and unusual proper nouns tokenise less efficiently, so a page of JSON costs more tokens than a page of prose of the same length. Those figures are rules of thumb for estimating; the only exact count comes from running your text through the provider's own tokeniser.

Billing separates the two directions because the compute differs. Reading a prompt is a single forward pass over the whole sequence and parallelises well. Generating a reply produces one token at a time, each pass attending to everything written so far, and cannot be parallelised across the sequence. That is why output typically costs three to five times what input costs on the same model.

Two consequences follow, and they are the reason this calculator separates the two lines. First, a long prompt is cheaper than it feels: 10,000 input tokens at $3 per million is 3 cents. Second, a long answer is more expensive than it feels: 2,000 output tokens at $15 per million is 3 cents as well, from a fifth of the text. If you want to reduce spend, find out which side dominates before you start editing anything.

Prompt caching adds a third price. Where a request begins with a long, unchanging prefix — a system prompt, a tool schema, a document being asked about repeatedly — providers can retain the computed state and charge a heavily reduced rate for re-reading it, commonly around a tenth of the standard input price. The saving applies only to the unchanged prefix and only while the cache entry lives, which is typically minutes rather than hours.

Working the arithmetic in units that do not trip you up

Prices are quoted per million tokens, and token counts are quoted in hundreds or thousands, so the safest habit is to divide the token count by 106 first and then multiply by the price. A 1,500-token prompt at $3 per million is 1,500 ÷ 1,000,000 × 3 = $0.0045. A 500-token reply at $15 per million is 500 ÷ 1,000,000 × 15 = $0.0075. Total $0.012 a request.

Multiplying up is where the number becomes a budget. At 5,000 requests a day for 30 days that is 150,000 requests, so $0.012 × 150,000 = $1,800 a month and $21,600 a year. The per-request figure looked negligible; the annual figure is a hiring decision. That gap is why per-request cost should never be the only number you look at.

With caching, split the input before pricing it. If 60% of a 1,500-token prompt is a cached prefix, that is 900 cached tokens at the cache rate and 600 fresh tokens at the standard rate. At $3 and $0.30 per million the input cost falls from $0.0045 to 600 ÷ 106 × 3 + 900 ÷ 106 × 0.30 = $0.0018 + $0.00027 = $0.00207, a 54% reduction on the input line. Note the sign convention this calculator uses: the caching figure it reports is the difference against pricing all input at the standard rate, so it is positive when the cache rate is below the input rate and negative in the unusual case where you have entered a cache write price by mistake.

Reasoning tokens deserve a mention because they break naive estimates. Models that produce an internal chain of thought bill those tokens as output even when they are not shown to the user, so measured output can be several times the visible answer length. If your provider exposes a reasoning-token count in its usage response, add it to the output figure here rather than counting the characters you received.

Worked example: a support assistant at 5,000 requests a day

A customer-support assistant sends a 1,200-token system prompt plus roughly 300 tokens of user message and retrieved context, and produces a 500-token reply. Prices are $3 per million input, $15 per million output and $0.30 per million cached. Volume is 5,000 requests a day, 30 days a month.

  1. Input tokens. 1,200 + 300 = 1,500 per request.
  2. Input cost with no caching. 1,500 ÷ 106 × $3 = $0.0045.
  3. Output cost. 500 ÷ 106 × $15 = $0.0075.
  4. Cost per request. 0.0045 + 0.0075 = $0.012.
  5. Output share. 0.0075 ÷ 0.012 = 62.5%. Output is the larger line despite being a third of the tokens.
  6. Requests per month. 5,000 × 30 = 150,000.
  7. Monthly spend. $0.012 × 150,000 = $1,800, and $21,600 a year.
  8. Now cache the system prompt. 1,200 of the 1,500 input tokens are a fixed prefix, so the hit rate is 80%. Input cost becomes 300 ÷ 106 × $3 + 1,200 ÷ 106 × $0.30 = $0.0009 + $0.00036 = $0.00126.
  9. New cost per request. 0.00126 + 0.0075 = $0.00876, a 27% reduction, taking monthly spend to $1,314 and saving $486 a month.
  10. Compare against shortening the reply. Capping the answer at 300 tokens instead of 500 changes output cost to 300 ÷ 106 × $15 = $0.0045, which with the cached input gives $0.00576 per request — $864 a month, saving $936 against the original.

Steps 9 and 10 are the point of the exercise. Caching the entire system prompt saves $486 a month; asking for shorter answers saves $936, because output is priced five times higher. Both are worth doing, but if you only have time for one change, the arithmetic tells you which.

How to read the result

Start with the output share. Above about 70% the bill is a generation-length problem: cap max_tokens, ask for structured or terse output, and stop the model summarising what it just did. Below about 30% it is a prompt-length problem: trim the system prompt, retrieve fewer chunks, and enable caching for whatever prefix is stable.

Cost per request is the wrong number for a decision on its own. Multiply it by realistic volume before you conclude anything, and remember that volume for a successful product grows faster than token counts fall.

The monthly figure is a floor. Retries, failed parses that trigger a second call, evaluation runs, and development traffic all add requests that no usage estimate contains. A 20–30% allowance over the calculated figure is a reasonable planning margin, and your provider's usage dashboard will tell you the real ratio within a week of launch.

Compare models on cost per completed task, not cost per token. A model at four times the token price that succeeds first time beats a cheaper one that needs two attempts and a repair prompt. Build a small evaluation set, measure success rate and mean tokens per task for each candidate, and multiply.

Watch for tiering. Some providers charge a higher rate above a context-length threshold, offer batch endpoints at a discount for latency-tolerant work, and price cache writes above the standard input rate. All three change the arithmetic and none of them appear in a single headline price.

Token counts for familiar amounts of text

English prose at the standard planning ratio of about 1.33 tokens per word, or four characters per token. Code and non-Latin scripts run higher.
ContentApproximate wordsApproximate tokensInput cost at $3/1M
One tweet-length message4053$0.00016
A paragraph100133$0.0004
One page of prose500665$0.002
A detailed system prompt9001,200$0.0036
A ten-page document5,0006,650$0.020
A 50-page report25,00033,250$0.100
A 150-page book section75,000100,000$0.300
A 300-page book150,000200,000$0.600

Tokens = words × 1.33, rounded. Cost = tokens ÷ 10^6 × price. Output at $15 per million costs five times these figures for the same token count.

Where prompt caching actually pays

Caching rewards a long, byte-identical prefix that is re-sent often. A fixed system prompt with tool definitions, a document being interrogated repeatedly in one session, or a few-shot example block all qualify. It does not help when the prefix changes between calls — putting a timestamp or a user name at the top of the system prompt invalidates everything after it, because the cache matches on an exact prefix. Cache entries also expire after a short idle period, so a low-traffic endpoint may pay the write cost repeatedly and read the cache rarely. Order your prompt with the most stable content first and the variable content last, and measure the realised hit rate from your provider's usage response rather than assuming it.

What this calculator does not price

  • Cache write costs. Some providers charge a premium above the standard input rate to create a cache entry. On a low-hit-rate endpoint that premium can exceed the read saving.
  • Reasoning tokens. Where a model produces hidden intermediate reasoning, those tokens are billed as output. Read them from the usage field and add them to the output count here.
  • Embeddings, image and audio tokens. These are priced on separate schedules, often per image, per second of audio, or per million embedding tokens at a much lower rate.
  • Batch and off-peak discounts. Latency-tolerant workloads submitted through a batch endpoint typically attract a substantial discount that this calculation ignores.
  • Retries and evaluation traffic. Failed calls, schema-repair retries and regression suites all consume tokens that a usage forecast built from user actions will miss.
  • Rate limits. Cost is not the only constraint. Tokens-per-minute and requests-per-minute limits shape architecture at least as much, and hitting them produces retries that cost money.

Fitting model spend into the rest of the bill

Token cost is rarely the whole cost of an AI feature. Retrieval-augmented generation adds an embedding call per document chunk at ingestion and per query at runtime, plus a vector database that is billed by stored dimension count and query volume. Those lines are usually small next to generation, but they scale with corpus size rather than with traffic, so they behave differently in a forecast.

The infrastructure around the model is priced like any other cloud workload: application servers, queues, storage for conversation history and egress for the responses. The cloud VM monthly cost calculator handles that side, and it is worth running both before you present a total, because a feature whose model spend is $1,800 a month can easily carry $600 of surrounding infrastructure.

Two structural choices move token spend more than any per-token negotiation. The first is routing: send the easy majority of requests to a small cheap model and escalate only the hard ones, which on a typical support workload cuts spend by more than half without a measurable quality change — provided you measure. The second is context discipline: retrieving three relevant chunks instead of twenty is both cheaper and usually more accurate, because irrelevant context degrades answers as well as costing money.

Finally, budget for growth in requests rather than in prices. Per-token prices have generally fallen as models improve, but successful features grow their call volume faster than prices fall. Model the volume curve you expect, run it through the table above, and check the annual figure at the volume you are hoping for rather than the volume you have — the same discipline the bandwidth requirement calculator applies to circuits, and for the same reason.

Frequently asked questions

How many tokens is 1,000 words?

About 1,330 tokens for English prose, using the standard planning ratio of 1.33 tokens per word, or equivalently four characters per token. Code, JSON, and languages that do not use Latin script tokenise less efficiently and can run 50% higher or more. For an exact figure, run the text through your provider's tokeniser — the estimate is only a budgeting aid.

Why do output tokens cost more than input tokens?

Because generating text is sequential and reading it is not. A prompt is processed in a single parallelised forward pass, whereas each output token requires its own pass attending to everything generated so far. That difference in compute is why output typically costs three to five times input on the same model, and why capping response length saves more than trimming the prompt.

How do I estimate my monthly LLM bill before launch?

Multiply cost per request by expected requests per day by billing days. Get the token counts from a handful of real calls rather than guessing — log the usage field the API returns. Then add 20–30% for retries, evaluation runs and development traffic. Re-check after the first week of production, because measured token counts almost always differ from designed ones.

How much does prompt caching save?

It reduces the price of the cached portion of the input, commonly to about a tenth of the standard rate. If 80% of a 1,500-token prompt is a fixed prefix, input cost falls by roughly 72% — but input may only be a third of the request cost, so the effect on the total is smaller. Work it through on this page with your own numbers before committing to a prompt restructure.

Should I cut the prompt or cut the response?

Look at the output-share figure. Because output is priced several times higher, most conversational and drafting workloads are output-dominated, and capping max_tokens or requesting terser answers moves the bill most. Retrieval-heavy workloads that stuff many documents into context are input-dominated, and there the levers are fewer retrieved chunks and prompt caching.

Do reasoning tokens count as output?

Yes, on providers that offer extended reasoning: the internal chain of thought is billed at the output rate even when it is not returned to you. This can make measured output several times the visible answer length. Read the reasoning-token count from the usage field of your API response and add it to the output figure here, or your estimate will be badly low.

Is a cheaper model always cheaper overall?

No. Compare cost per completed task rather than cost per token. A cheaper model that needs two attempts, a longer prompt with more examples, or a repair call afterwards can cost more than a stronger model that succeeds first time — and it also costs latency and engineering effort. Build a small evaluation set, measure success rate and mean tokens per task, then multiply.

What is a realistic cost per request?

For a typical assistant with a 1,500-token prompt and a 500-token reply at $3 and $15 per million, about $0.012. Short classification calls with a 200-token prompt and a 10-token answer land near $0.0007. Long-document analysis with a 50,000-token prompt runs to $0.15 or more before the answer is generated. Volume decides whether any of those matter.

References