LLM Token Cost Calculator

By · Last updated:

LLM Token Cost Calculator tokens / 106 × price

Estimate the tokens in a prompt, then price a workload: cost per request, per 1,000 requests, per day and per month. Type the per-million-token prices from your provider’s pricing page. No vendor prices are built in; every preset below uses made-up numbers.

Examples (made-up prices):

A. Estimate tokens from text

Characters
–
Words
–
Characters / 4
–
Words / 0.75
–
Estimated tokens (average of the two)
–

This is an estimate from two rules of thumb for English, not a count. The exact number depends on the model’s tokenizer; providers publish a tokenizer or a token-counting endpoint for that.

B. Cost

Compare: Option B (optional, same workload)

Next step: If the monthly figure is high enough that running an open model on your own hardware looks attractive, work out the GPU memory that model would need. If your requests are not all the same size, average the cost over small, typical and large requests and budget with that figure.

An LLM token cost calculator is a tool that converts the token counts of a request and your provider’s per-million-token prices into money. Enter input tokens, output tokens, the two prices and your request volume, and this one returns the cost per request, per 1,000 requests, per day and per month, with an optional cached-input rate and a second price point to compare.

How does LLM API billing work?

Hosted language models are billed by the token, and almost always with two meters. Input tokens are everything you send: the system prompt, any retrieved documents, the conversation so far and the new user message. Output tokens are what the model writes back. Each side has its own price, quoted per 1 million tokens, and the output price is usually the higher of the two.

Three consequences follow. A long system prompt is paid for again on every single request. A chat application pays for the whole conversation history on every turn, because the model keeps no memory between calls. And a short answer to a long prompt can still be dominated by input cost, so you need both numbers before you can say which side to optimise.

This page deliberately holds no vendor prices, context limits or tokenizer ratios. They change, and a stale number would mislead you. Copy the current figures from your provider’s pricing page into the tool.

What is the formula for LLM token cost?

\[ \text{cost per request} = \frac{T_{in}\,(1-c)}{10^6}\,p_{in} + \frac{T_{in}\,c}{10^6}\,p_{cache} + \frac{T_{out}}{10^6}\,p_{out} \]
\[ \text{daily} = \text{cost per request}\times R \qquad \text{monthly} = \text{daily}\times D \]
  • \(T_{in}\) and \(T_{out}\): input and output tokens in one request.
  • \(p_{in}\), \(p_{out}\): price per 1 million input and output tokens.
  • \(c\): the fraction of input tokens served from a prompt cache (0 when you do not use caching), and \(p_{cache}\): the price per 1 million cached input tokens.
  • \(R\): requests per day. \(D\): days per month, 30 by default; use about 22 for a tool that only runs on working days.

Worked example

The default input is an invented chat feature. The prices are made up for illustration and belong to no real model: USD 0.50 per million input tokens and USD 1.50 per million output tokens. Each request sends 500 tokens and receives 200, and there are 10,000 requests a day.

  • Input: 500 / 1,000,000 × 0.50 = USD 0.00025
  • Output: 200 / 1,000,000 × 1.50 = USD 0.00030
  • Cost per request: 0.00025 + 0.00030 = USD 0.00055
  • Per day: 0.00055 × 10,000 = USD 5.50. Per month: 5.50 × 30 = USD 165.00

The output is 200 of the 700 tokens, about 29% of the volume, yet it is 54.55% of the bill. Option B in the default input is a second made-up price point, USD 0.30 and USD 0.90 per million. The same workload then costs USD 0.00033 per request and USD 99.00 a month, a difference of USD 66.00, which is a 40% saving.

How does the cost scale from 1,000 to 1,000,000 requests a month?

Token billing is linear, so ten times the traffic is ten times the bill. The table uses the same made-up workload and prices as the worked example (500 input and 200 output tokens per request).

Requests per monthInput tokensOutput tokensInput costOutput costTotal
1,000500,000200,000USD 0.25USD 0.30USD 0.55
10,0005,000,0002,000,000USD 2.50USD 3.00USD 5.50
100,00050,000,00020,000,000USD 25.00USD 30.00USD 55.00
1,000,000500,000,000200,000,000USD 250.00USD 300.00USD 550.00

Because nothing here is fixed, the cost per request is the number to watch. Halving it halves every row.

What is a token, and why is the text estimate only approximate?

A token is the unit of text a language model reads and writes: a short word, a fragment of a longer word, a punctuation mark or a digit group, as cut up by that model’s tokenizer. The model produces its reply one token at a time, picking each from a probability distribution over its vocabulary that comes out of a softmax over the final-layer scores.

The estimator in section A uses two common rules of thumb for English prose: one token per 4 characters, and one token per 0.75 words. A 4,000-character text gives 4,000 / 4 = 1,000 tokens by the first rule; a 1,500-word text gives 1,500 / 0.75 = 2,000 tokens by the second. The tool shows both and uses their average.

These are approximations, not counts. Source code, JSON, long numbers, URLs and most non-English text break into more tokens per word than plain English, and different models split the same text differently. For a figure you will be invoiced on, use the tokenizer or the token-counting endpoint your provider publishes, or read the usage numbers returned with each API response.

How do caching and batching change the bill?

Many providers offer prompt caching: a prefix that repeats across requests, such as a long system prompt, is billed at a lower cached-input rate after the first use. Take 1,000 input tokens of which 80% are cached, with made-up prices of USD 3.00 per million for normal input and USD 0.30 for cached input. The input side costs 200 / 1,000,000 × 3.00 + 800 / 1,000,000 × 0.30 = USD 0.00084, against USD 0.00300 with no caching, which is 72% less.

Two caveats. Some providers charge extra to write an entry into the cache, and cached entries expire; this calculator models only the discounted read price, so treat the result as the steady-state cost. Batch or asynchronous processing, where it is offered, trades slower turnaround for a lower rate. Model it by typing the batch prices into Option B.

How do you budget an LLM feature before building it?

  1. Write a realistic prompt, including the system prompt and any retrieved context, and estimate its tokens in section A.
  2. Decide a maximum output length. Output is the expensive side, so a cap is the simplest cost control.
  3. Estimate requests per day from expected users and calls per user, then read the monthly figure.
  4. Stress the estimate. Request sizes vary, so weight small, typical and large requests by how often they occur with the expected value calculator, and once you have logs, size the worst case from the 95th percentile of token counts using the percentile calculator.
  5. Compare a cheaper price point in Option B and check whether quality holds up on your own test set.

The same arithmetic prices one-off jobs: an evaluation run over 5,000 test examples costs 5,000 times the cost per request, and so does generating 5,000 synthetic training examples. If the monthly total approaches the cost of renting a GPU, the alternative is to host an open model yourself; the LLM VRAM calculator estimates the memory that needs. More tools of this kind are listed on the deep learning calculators page.

Common mistakes

  • Forgetting output tokens. Pricing only the prompt understates the worked example by more than half.
  • Forgetting that history is resent. With a 400-token system prompt, 100-token user messages and 200-token replies, turn 1 sends 500 input tokens but turn 10 sends 3,200. Ten turns total 18,500 input tokens, not 10 × 500 = 5,000.
  • Mixing per-thousand and per-million prices. A price of 0.002 per 1,000 tokens is 2 per million. Entering 0.002 in a per-million field makes the result 1,000 times too small.
  • Ignoring the system prompt. A 1,500-token system prompt at 10,000 requests a day is 450,000,000 input tokens a month, which is USD 225.00 at the made-up USD 0.50 rate, before any user text.
  • Treating the text estimate as exact. It is a planning figure; confirm with the provider’s tokenizer.

LLM cost formula in Python

The formula needs no vendor SDK or numerical library, only plain Python. This reproduces the worked example, the Option B comparison and the caching example.

def llm_cost(input_tokens, output_tokens, price_in, price_out,
             cached_share=0.0, price_cached=0.0):
    """Cost of one request. Prices are per 1 million tokens."""
    cached = input_tokens * cached_share
    uncached = input_tokens - cached
    return (uncached / 1e6 * price_in
            + cached / 1e6 * price_cached
            + output_tokens / 1e6 * price_out)

# Made-up example prices, not any provider's rates
per_request = llm_cost(500, 200, 0.50, 1.50)
daily = per_request * 10_000
monthly = daily * 30
print(round(per_request, 6), round(daily, 2), round(monthly, 2))
# 0.00055 5.5 165.0

option_b = llm_cost(500, 200, 0.30, 0.90) * 10_000 * 30
print(round(option_b, 2), round(100 * (monthly - option_b) / monthly, 1))
# 99.0 40.0

print(round(llm_cost(1000, 0, 3.0, 0.0, cached_share=0.8, price_cached=0.3), 6))
# 0.00084

Frequently asked questions

How do I calculate the cost of an LLM API call?

Divide the input tokens by one million and multiply by the input price, do the same for the output tokens with the output price, and add the two. With 500 input tokens at USD 0.50 per million and 200 output tokens at USD 1.50 per million, one request costs USD 0.00055.

How many tokens are in 1,000 words?

For ordinary English prose the words rule of thumb gives about 1,000 / 0.75 = 1,333 tokens. That is an estimate only: the exact count depends on the tokenizer of the model you call, and code, numbers and non-English text usually produce more tokens per word.

Why are output tokens usually more expensive than input tokens?

Generating text is the more compute-heavy side. The model reads the whole input in one parallel pass but writes the output one token at a time, running the network again for each new token. Providers usually reflect that with a higher output price; check the pricing page for the actual ratio.

Does this calculator include current prices for specific models?

No. It holds no vendor prices on purpose, because prices change and differ by model. Type the per-million-token prices from the pricing page of your provider; every preset and example on this page uses made-up numbers.

Related calculators

Token cost is one part of sizing a model. These tools cover the neighbouring questions: