Estimate LLM API cost from input and output token counts and per-million USD pricing ā no network calls to providers.
Formula
inputCost = (inputTokens / 1,000,000) Ć inputPricePerMillion and the same for output tokens. Total cost is the sum, rounded to six decimal places for display.
When to use it
Budget batch jobs, compare model tariffs, or quote client work before running large embedding or completion pipelines. Enter list prices from provider documentation.
Limitations
Ignores batch discounts, cached-token pricing, tiered volume rates, and currency conversion. Assumes a single request ā not a multi-turn conversation with growing context. Prices change; verify on the vendor site before purchasing.
Example
One million input tokens at $3/M and five hundred thousand output tokens at $15/M yields $3.00 input + $7.50 output = $10.50 total.