LLM API Cost Calculator
Estimate what a feature built on a large language model API will cost. Enter the per-million-token prices, how many requests you expect, and the average tokens in and out. Prices are per token, charged separately for the prompt and the reply.
Presets fill in reference prices, but LLM pricing changes often — copy the current rates from your provider's pricing page into the price fields.
How token pricing works
Text is split into tokens — chunks roughly three to four characters long. You pay for the tokens you send (the prompt, including any system instructions and attached context) and the tokens you get back (the reply). Output is generated one token at a time and costs more: typically three to five times the input rate. Both are usually quoted per million tokens.
The levers that move the bill
- Model choice. A smaller, cheaper model for easy calls — classification, short answers, routing — and a larger one only where it earns its keep.
- Output length. Cap the maximum reply length. A prompt that produces a 2,000-token essay when 200 would do is paying 10× on the expensive half.
- Prompt caching. If every request resends the same big system prompt or document, caching re-reads it at around a tenth of the price. Set the cache share above to see the effect.
- Trim the prompt. Long, unchanging preambles add up across millions of calls. Shorter instructions and only the context you need.
- Batch what is not urgent. Many providers run non-real-time work asynchronously at around half price.
Why the real bill is usually higher
This calculator assumes one clean request per call. In production you also pay for retries and failures, multi-step tool-calling where each step is a full request, extended-thinking tokens billed as output, and any images or audio in the input. Start from this estimate and add a margin.
Frequently asked questions
How is LLM API cost calculated?
You are charged per token, with separate rates for input (your prompt) and output (the model's reply), usually quoted per million tokens. Cost per request = (input tokens ÷ 1,000,000 × input price) + (output tokens ÷ 1,000,000 × output price). Multiply by your request volume for daily, monthly and yearly totals.
How many tokens is my text?
A rough guide for English is 1,000 tokens ≈ 750 words ≈ 4,000 characters. Code, other languages and lots of punctuation use more tokens per word. For a real number, use the provider's tokenizer or token-counting endpoint.
Why is output more expensive than input?
Generating text is more compute-intensive than reading it, so output rates are typically three to five times the input rate. Long, chatty responses cost far more than the prompt that triggered them — capping output length is one of the easiest savings.
What is prompt caching and how much does it save?
If the same large chunk of context (a system prompt, a document, instructions) is sent on many requests, providers can cache it and re-read it cheaply on later calls — often around 10% of the normal input price. For chat and agent apps that resend a big prompt every turn, this can cut the input bill sharply. Exact discounts and any one-off write cost vary by provider.
Are these prices current?
Treat every preset as a reference point, not a live quote. LLM pricing changes often and new models appear frequently. Copy the current per-million-token rates from your provider's pricing page into the price fields.
What does this calculator leave out?
Retries, failed requests, tool-call round trips, extended-thinking tokens (billed as output), image or audio inputs, and volume discounts. Add a margin — many teams budget 20–50% above the naive estimate.