The formula, complete
cost = (fresh_input_tokens / 1e6) * input_rate
+ (cached_input_tokens / 1e6) * cached_rate
+ (output_tokens / 1e6) * output_rate
[+ (cache_write_tokens / 1e6) * cache_write_rate] // Anthropic onlyWorked example on claude-sonnet-4-6 ($3 input, $15 output, $0.30 cached read): 8,000 input tokens of which 6,000 cached, 1,200 output:
fresh: 2000 / 1e6 * 3.00 = $0.0060
cached: 6000 / 1e6 * 0.30 = $0.0018
output: 1200 / 1e6 * 15.0 = $0.0180
total = $0.0258 per callNote where the money is: output is 70 percent of this call at 13 percent of the tokens. Output rates run five to six times input on current models, which is why max_tokens is the cheapest cost control that exists.
The units trap: per token, per 1K, per 1M
- Per million (current provider convention): gpt-5.4-mini input is $0.75 per 1M tokens.
- Per 1K (older convention, still around): the same rate reads $0.00075 per 1K. Divide per million by 1,000.
- Per single token: $0.00000075. You will meet stray figures like $0.000075 in docs and forums; that one is $0.075 per million, a cached input rate on a cheap model.
Sanity rule: current model rates per million run from cents to tens of dollars. If your computed rate is outside that band, you crossed conventions somewhere.
Tokens per word, and why counts differ by provider
English text runs about four characters per token, three quarters of a word, so 1,000 words is roughly 1,300 tokens. Code, JSON, and non English text tokenize worse. And each provider tokenizes differently: the same document can differ 10 to 25 percent in token count between OpenAI and Anthropic, which is one of the two reasons per token price tables mispredict real bills, the case made with measured data in the AI cost per user benchmark and the task cost benchmark. Always prefer the usage object’s real counts over estimates when you have them.
Current rates, without hardcoding
Rates move; a table in your code is wrong within months, occasionally within days, per LLM price history. Fetch useweckr.com/pricing.json for live rates, or use the helpers in @weckr/sdk:
import { calculateCost } from '@weckr/sdk';
const { costUsd } = calculateCost('claude-sonnet-4-6', 8000, 1200);And once you can price one call, the question that actually matters is the sum per customer: that arithmetic, run continuously against what each user pays, is exactly what Weckr automates.
FAQ
How do I convert LLM tokens to dollars?
Divide the token count by one million, multiply by the per million rate, once for input and once for output, then add them. A call with 2,000 input tokens and 500 output tokens on a $3 input, $15 output model costs 2000/1e6*3 + 500/1e6*15 = $0.0135. Cached prompt tokens use the cached rate instead of the input rate.
Is the price per token, per 1K tokens, or per million tokens?
All three conventions exist in the wild, which causes most conversion mistakes. Providers now quote per million tokens. Older docs and some tools quote per 1,000 tokens: divide a per million rate by 1,000 to compare. A raw per token figure like $0.000075 is the per million rate divided by one million, that example being $0.075 per million, a cached input rate. When a number looks a thousand times off, it is almost always a units mismatch.
How many tokens is a word or a page?
For English text, one token is roughly four characters or about three quarters of a word. So 1,000 words is roughly 1,300 tokens, and a dense single spaced page around 500 words is roughly 650 tokens. Code and non English languages tokenize less efficiently, and each provider uses its own tokenizer, so counts differ 10 to 25 percent across providers for identical text.
Why does the same prompt cost different amounts on different providers?
Two reasons stacked: different per million rates, and different tokenizers producing different counts for the same text. Cost comparisons should therefore compare real usage objects times real rates, not word counts times assumed rates. Our task cost benchmark exists precisely because per token price tables do not predict real bills well.
Where do I get current per million rates without hardcoding them?
Fetch useweckr.com/pricing.json, a free live JSON feed of input, output, and cached rates for OpenAI, Anthropic, Gemini, and Kimi models, generated from the table Weckr bills with and watched weekly for provider changes. Or in code, the @weckr/sdk package exports the same table with resolvePricing and calculateCost helpers that handle dated model ids.
Keep reading
One call is arithmetic. A thousand users is a system.
This page prices a call. Weckr prices all of them, per user, per feature, against each user’s plan, with the rates kept current automatically. Two lines of integration, free for 50,000 requests a month. See it on the live demo, or continue with the AI cost and margin guide.