The maths behind an AI bill isn't hard. It's just easy to fumble: tokens aren't words, output is usually priced differently from input, and a training run often comes down to "how many GPU-hours will this take?"
I build Calculator.now, so I'm biased. Still, these are five pages I use for a quick sanity check before I approve a spend, with a worked example for each. I checked every number below in Python. Some pages ship with built-in price lists that are out of date, so every cost example uses clearly labelled example rates. Paste in today's official prices before you trust the dollar figure.
1. API spend from tokens and a rate you type in
Most API bills are a short formula:
cost = (input tokens × input rate + output tokens × output rate) / 1,000,000 Rates are usually quoted per million tokens; output often costs more.
Worked example: 4,000 input tokens and 1,200 output tokens, 250 times a day, 22 days a month. I'll use example rates of $3.00 per 1M input tokens and $15.00 per 1M output tokens, not a current market quote.
- Cost per request: (4,000 × 3 + 1,200 × 15) / 1,000,000 = $0.03
- Per day: $0.03 × 250 = $7.50
- Per month: $7.50 × 22 = $165.00
per_request = (4000 * 3.00 + 1200 * 15.00) / 1_000_000 # example $ per 1M tokens print(per_request, per_request * 250 * 22) # 0.03 165.0 The AI token calculator has a Cost Estimator for this. Choose Custom Pricing, type the two rates, and fill in tokens per request, requests per day and days per month.
It can also estimate tokens from prose by counting words and multiplying by a ratio (1.3 for the GPT-style and Custom options). "The API returned a 429, so we backed off and retried the batch." is 13 words, so ceil(13 × 1.3) = 17 tokens. That's a rule of thumb, not an official tokenizer.
2. A second estimate, and why both are only estimates
When I want a second opinion on length, I use the dedicated token counter. It doesn't run tiktoken or any vendor library. For English general text with the TikToken setting, it averages a character estimate and a word estimate:
tokens ≈ round( (ceil(chars ÷ 4) + ceil(words ÷ 0.75)) / 2 ) Worked example: Estimate tokens before you send the prompt, not after the bill arrives.
- 71 characters, 12 words
-
ceil(71 / 4) = 18,ceil(12 / 0.75) = 16 - Average, rounded: 17 tokens
import math text = "Estimate tokens before you send the prompt, not after the bill arrives." c, w = len(text), len(text.split()) print(c, w, round((math.ceil(c / 4) + math.ceil(w / 0.75)) / 2)) # 71 12 17 Other languages and content types apply extra factors before the average. The page says this outright: for production, use the official tokenizer libraries. I treat both tools as a napkin check, not something to reconcile an invoice against.
3. Training cost from hours you already have
The AI model training cost calculator starts from a GPU hourly rate, a GPU count and a duration you type in, then adds rough storage and network costs from the model and dataset size, plus overhead of 5% of compute + storage + network. The page's disclaimer is the right one: the built-in AWS / GCP / Azure table is public pricing as of March 2025, and actual costs vary by region and discounts. Use the Custom tab and today's official rates, then click Apply Custom Pricing.
Worked example: a 1B-parameter LLM, 1T training tokens, 8 GPUs, 72 hours, on-demand (uncheck "Use Spot/Preemptible Instances" — it's on by default and multiplies the hourly rate by 0.4). Example rates: $4.00 per GPU-hour, $0.08 per GB-month of storage, $0.10 per GB of network.
- Storage: 4 GB model + 20 GB for five checkpoints + 2,000 GB of data at 2 bytes/token = 2,024 GB, pro-rated over 72 of 720 hours in a 30-day month → $16.19 (shown as $16)
- Network: 3,200 GB inter-node plus 20 GB of downloads → $322
- Compute: $4.00 × 8 × 72 = $2,304
- Overhead: 5% of $2,642.19 = $132.11 (shown as $132)
- Total: $2,774
params, tokens, gpus, hours, rate = 1e9, 1e12, 8, 72, 4.00 # example $/GPU-hour storage = (params*4/1e9*6 + tokens*2/1e9) * 0.08 * (hours/720) network = (params*4/1e9*100*gpus + params*4/1e9*5) * 0.10 compute = rate * gpus * hours total = (compute + storage + network) * 1.05 print(round(compute), round(storage), round(network), round(total-compute-storage-network), round(total)) # 2304 16 322 132 2774 Utilisation, precision, optimizer and parallelism do not change the dollar figure; the duration is whatever you typed. Totals like $25,920 that you may see before clicking Calculate are placeholders, not a result of the default inputs.
4. How the compute scales: FLOPS ≈ 6 × parameters × tokens
When I'm asking whether this is a weekend job or a month-long one, I care less about a cloud SKU and more about the work. A common training estimate, and the one this page actually uses, is FLOPS ≈ 6 × parameters × tokens (the 6 stands in for a forward plus a backward pass). The AI scaling cost calculator starts there.
Worked example: a 7B-parameter model trained on 20B tokens.
params, tokens = 7e9, 20e9 print(f"{6 * params * tokens:.1e}") # 8.4e+20 That's 8.4 × 10²⁰ floating-point operations, which the page reports as 840,000.00 "PetaFLOPS" — it means 840,000 petaFLOP of work, not a rate.
To turn that into time and money, the page divides by GPU count × a built-in peak-FLOPS figure × utilisation × a parallelism efficiency factor. For data parallelism, efficiency is 0.95 × (1 − log₁₀(GPU count) × 0.05), floored at 0.5. With the page's A100 FP16 peak of 0.312 PFLOPS, 8 GPUs, 80% utilisation, an example $4.00 per GPU-hour and the default 20% overhead, I get 5.37 days and $4,946.71. Treat the time as an order-of-magnitude check: that peak is baked into the page, not a benchmark from your cluster.
I wouldn't quote a memory number here: the documented formula doesn't match the script (activation memory is divided by a fudge factor of 100). The validation and pre-training checkboxes are unused. The page copy's "Performance ~ parameters^0.076" line is not something the calculator computes, and I wouldn't hang a plan on it.
5. Image generation: API, subscription or self-hosted
The AI image generation cost calculator compares three ways to pay. Same job throughout: 2,000 images at 1024×1024, no upscaling, and storage unchecked (it's on by default). Prompt length is collected but unused.
- Pay-per-call API, example $0.040 per image at 1024×1024: 2,000 × 0.04 = $80.00. The same rate at 2048×2048 is 4×, or $320, because the page scales by megapixels. Time is estimated at 5 seconds per 1024×1024 image (about 2.78 hours).
- Subscription, example $40 a month including 2,000 images: $40.00 total, $0.02 per image if you use the full allowance. Stay inside the included count — overage uses a built-in per-image table I wouldn't treat as current.
- Self-hosted, example $1.50 per GPU-hour, using the page's A100 + Stable Diffusion figure of 180 images/hour at 1024×1024 and 25 steps, batch of 4. Batching is modelled as
1 + log₁₀(batch size) × 0.2, so about 201.67 images/hour, 9.92 hours, and $14.88.
import math api, sub = 2000 * 0.04, 40.00 # example API $/image and monthly plan hours = 2000 / (180 * (1 + math.log10(4) * 0.2)) # page's img/hour estimate print(api, sub, round(hours * 1.50, 2)) # 80.0 40.0 14.88 Which option wins depends on volume, your rates, and whether you already have a GPU. Overwrite the dropdown prices; treat the throughput table as an estimate.
Wrapping up
None of this replaces a quote from your provider. What I want from a napkin check is to catch a missing factor of a thousand — or to see that a "cheap" subscription is only cheap if you use the allowance. If there's an AI costing question you keep redoing by hand, tell me in the comments. I'd like to know what to build next.
Chris Yau, founder of Calculator.now. I'm biased, but every snippet above is plain Python, so you can check the numbers without the site.

