Total API Cost Calculator
Combine prompt and completion costs to estimate the total cost of an LLM API call.
About Total API Cost Calculator
The total cost of running an LLM in production combines both input (prompt) and output (completion) token pricing, multiplied by request volume: total = (prompt_tokens × input_price + completion_tokens × output_price) × requests. Output tokens are typically priced 2-5x higher than input tokens because generation is more compute-intensive than reading context. Use this to budget monthly or annual LLM spend for a given workload.
Formula
total_cost = (prompt_tokens * input_price + completion_tokens * output_price) * requests
- prompt_tokens
- Input tokens per request
- completion_tokens
- Output tokens per request
- input_price
- Cost per input token (price_per_million / 1e6)
- output_price
- Cost per output token (price_per_million / 1e6)
- requests
- Number of API requests
Worked example
With the default values below, Total API Cost Calculator returns Total Cost of $20.00. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Prompt Tokens per Requestaccepts 0–10,000,000 tokens
- 800 tokens
- Completion Tokens per Requestaccepts 0–10,000,000 tokens
- 400 tokens
- Modelone of GPT-4 (8K), GPT-4 Turbo, GPT-3.5 Turbo, Claude 3 Opus, Claude 3 Sonnet, Claude 3 Haiku
- GPT-4 Turbo
- Number of Requestsaccepts 1–100,000,000 requests
- 1,000 requests
Results
- Total Cost
- $20.00
- Cost per Request
- $0.020000
- Total Prompt Cost
- $8.00
- Total Completion Cost
- $12.00
Step by step
- 1Cost per request: (prompt tokens × input price) + (completion tokens × output price)= $0.020000
- 2Total cost: cost per request × number of requests= $20.00
Assumptions and limits
- The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 6 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
Why is completion pricing higher than prompt pricing?
Generating tokens (autoregressive decoding) requires a full forward pass per token, while processing prompt tokens can be batched and parallelized, making input tokens cheaper to serve.
How do I estimate tokens per request?
Use the Token Calculator to estimate tokens from sample prompts and expected response lengths, then plug those averages in here.
Does this include embedding or fine-tuning costs?
No, this covers only standard chat/completion API calls. Embeddings, fine-tuning, and image/audio modalities have separate pricing.
How can I reduce total API cost?
Shorten prompts, cache repeated context, use a smaller/cheaper model where acceptable, and cap completion length with a max_tokens setting.
