Total API Cost Calculator
Calculate the full cost of LLM API usage from prompt tokens, completion tokens, model pricing, and request volume.
Inputs
Total Cost
$20.00
Cost per Request
$0.020000
Total Prompt Cost
$8.00
Total Completion Cost
$12.00
Step by step
Cost per request: (prompt tokens × input price) + (completion tokens × output price)
(800 × $0.00001000) + (400 × $0.00003000)
= $0.020000
Total cost: cost per request × number of requests
$0.020000 × 1000
= $20.00
How it works
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
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.