Calculate the dollar cost of an LLM completion based on output tokens and pricing.
LLM providers charge per token for generated output, typically at a higher rate than input tokens. This calculator multiplies the number of output tokens by the per-million-token pricing to determine the cost of a single completion.
Cost
cost = (output_tokens / 1,000,000) × price_per_million
Generation requires sequential autoregressive decoding which is computationally more expensive per token than processing input tokens in parallel during the prefill phase.
Use shorter max_tokens limits, request concise responses in your prompt, use a smaller/cheaper model for simple tasks, or batch requests during off-peak hours.