AI Token Cost Calculator
Work out what an AI API call actually costs from your token counts and the price per million tokens.
Last updated · View algorithm, constants and default inputs (JSON)
About this calculator
Every hosted language model bills by the token, and it bills input and output at different rates — output tokens are usually several times the price of input, because generating text is the expensive direction. So the cost of one request is the input tokens times the input rate plus the output tokens times the output rate. Enter the current rates from your provider and you get the real per-request and total cost rather than an estimate that silently went stale.
Worked example
calculated with the default values below
Input tokens per request 1,500 · Output tokens per request 500 · Input price per 1M tokens 3 $ · Output price per 1M tokens 15 $ · Number of requests 1,000 Cost per request 0.012000 $ · Total cost 12.0000 $ · Total tokens processed 2,000,000
General background references
Disclaimer
These calculators give general date results. Public holidays, working-day conventions and time-zone rules are set locally and change, so confirm against the official calendar for anything legally or contractually binding.
Implementation source
This record describes the implementation used by this page. It is not independent validation. External references, when available, support only the stated formula or definition; estimates and custom rules retain their own assumptions.
Formula and variables
C = (t_i × p_i + t_o × p_o) ÷ 1000000 × n
- C
- total cost
- t_i
- input tokens
- p_i
- input price per 1M tokens
- t_o
- output tokens
- p_o
- output price per 1M tokens
- n
- number of requests
Prices are quoted per 1,000,000 tokens; n is floored to whole requests.
Frequently asked questions
Why might my actual API bill differ from this estimate?
The calculator multiplies your input and output token counts by the prices you enter, divides by one million, then multiplies by the number of requests. It does not model cached-token discounts, batch pricing, tier changes, taxes, or additional billable features. Use the price and token categories from your provider’s current billing terms when comparing the result with an invoice.