01Start with the shape of one API call
An LLM token cost calculator needs more than a monthly request count. Record the input tokens, visible output tokens and billed reasoning tokens for a representative call. Input includes instructions, conversation history and retrieved text. Cached reads and explicit cache writes belong in separate inputs because they can have different prices.
The calculator multiplies each token category by its own USD-per-million rate. Visible and reasoning output are added together for the output charge and for the modeled output-limit check. They remain separate in the breakdown so a visible answer estimate is not confused with hidden reasoning usage.
Use measured usage from representative provider responses when possible. A local plain-text token count does not include message wrappers, tool schemas, files, images or every provider-specific tokenizer rule.
- Input: uncached input plus cached reads; explicit cache writes are entered separately.
- Output: visible answer tokens plus billed reasoning tokens.
- Volume: completed tasks, API calls per task and a retry allowance are distinct quantities.
- Other charges: retrieval, tools, taxes or known account charges can be added as a monthly amount.
02Why completed tasks and API calls need different formulas
A user task may involve a router, several model calls, a validator and a retry. Counting only the final call understates the workload. Swiftly calculates billable API calls as completed tasks × calls per completed task × (1 + retry allowance). The retry allowance increases calls; it does not increase the number of completed tasks.
Token cost per API call excludes monthly storage and other entered charges. Total cost per completed task divides the full monthly estimate by completed tasks, so it includes those monthly amounts. Keeping these metrics separate prevents a deceptively low per-call figure from being presented as the unit cost of a finished feature interaction.
Example: 120,000 completed tasks, one call per task and a 6% retry allowance produce 127,200 billable calls. At GPT-6.1 Terra Standard base rates, 1,600 input and 450 visible output tokens per call produce an estimated $489.72 monthly token total before storage or other charges.
03Cached reads, cache writes and storage are not one discount
The cached-read share applies only to the entered input tokens. Uncached input remains at the standard input rate. Explicit cache-write tokens use the selected duration rate where a provider publishes one, and storage uses its own per-million-token-hour price where applicable. If a separate cached or write rate is not published for an entry, the engine uses the standard input rate and displays a warning rather than assuming the category is free.
The storage control represents one shared cached prefix held for the entered number of hours in a month. Its estimate is cached tokens ÷ 1,000,000 × storage rate × hours. Multiple independent caches can have a different token-hour total; add their measured storage charge under Other monthly charges instead of stretching the shared-prefix assumption.
- OpenAI cache writes have separate 30-minute and 12-hour multipliers in the sourced rate card.
- Claude cache writes have separate five-minute and one-hour multipliers; Batch and cache multipliers stack where published.
- Gemini cached-input and storage prices vary by model and, for some models, by the selected dated rate card.
- Cache-read savings in the result panel are shown before write and storage costs, never as net savings.
04Long-context pricing can reprice the whole call
A long-context threshold is not always a surcharge on only the tokens above the line. In the sourced OpenAI cards, crossing 272,000 prompt tokens applies the higher input, cached-input and output rates to the whole request. Claude Haiku 5.5 similarly moves to its higher published card above 100,000 prompt tokens. Prompt tokens include entered input and cache-write tokens before monthly volume is applied.
At GPT-6.1 Terra Standard rates, 272,000 input tokens with no output or caching cost $0.272. At 272,001 input tokens, the whole-call long-context card produces $0.544002. That sharp change is the published tier rule, not a rounding error. The calculator labels the active tier so a large estimate can be traced back to its cause.
Context and output checks are feasibility checks, not prices. If a workload exceeds a modeled limit, the arithmetic remains visible for diagnosis but is explicitly marked as not a feasible single API request.
05Batch, peak and dated rates require an explicit choice
Batch or asynchronous pricing is applied only when the selected rate card publishes it. The sourced OpenAI, Claude, Gemini and Mistral cards include Batch prices; the reviewed DeepSeek token-pricing page does not publish a Batch discount, so requesting Batch for DeepSeek leaves Standard pricing applied and shows a warning. Even where Batch is available, eligibility, completion windows and operational limits still need provider confirmation.
DeepSeek peak and off-peak cards are user-selected. The source defines weekday peak windows in UTC and treats weekends and Chinese public holidays as off-peak; the calculator does not infer a rate from a device clock. Gemini introductory and later list rates are also separate cards. Gemini 4 Argon shows its published rate through November 30, 2026 and the later card starting December 1; Gemini 3.8 Flash shows the introductory card through December 31 and the later card starting January 1, 2027.
- Use a later dated card when budgeting for that later period; do not describe it as a charge already in effect.
- Do not assume Batch always halves every category: the published Gemini 3.5 Flash-Lite cached Batch price is a specific exception.
- Provider account credits, free tiers, committed-use discounts and negotiated rates are outside the static public-price snapshot.
06Compare price without turning it into a quality score
The comparison table holds the workload constant across the catalog. The selected model keeps its chosen rate card; other rows use their default published card, and every row displays the card actually used. The cheapest-feasible label excludes rows that exceed a modeled context or output limit. Price efficiency is the cheapest feasible monthly total divided by the selected row’s total, expressed on a 0–100 scale.
That score says nothing about accuracy, reasoning ability, latency, availability, safety, context utilization or task success. A cheaper model that fails more often can cost more after retries and human review. Evaluate candidate models on the same representative task set, then combine measured quality with the token-cost estimate before routing production traffic.
A model switch is an experiment, not a guaranteed saving. Track successful completed tasks, evaluation scores, latency and actual provider usage alongside the forecast.
07Where the estimate stops
This is a text-token planning model, not an invoice and not a live price feed. It excludes image and audio tokenization, embeddings, web search, retrieval, tool calls, provisioned capacity, support plans and account-specific adjustments unless a known monthly amount is entered separately. The custom model option accepts user-supplied text rates, but those values are labeled unverified and are not checked against a provider.
For self-hosted or hosted open-weight endpoints, custom token prices can describe a vendor meter, but GPU rental, idle capacity, engineering, observability and reliability work require a separate total-cost analysis. Confirm current provider documentation before committing a budget, reconcile the forecast with actual usage responses, and include the billing categories your application really uses.
- No ranking, quality or latency recommendation is inferred from the cheapest row.
- No device clock switches a promotional, peak or future price automatically.
- No pasted prompt is exported; reports include token counts and assumptions, not the raw text.
- Daily cost is a 30-day average, while annual cost is the monthly estimate multiplied by 12.