LLM Token Cost Calculator
Input and output token counts at each model's per-million price give the true cost of an LLM API call or workload — the number to budget an AI feature. Your own token counts.
What an LLM API call actually costs
The total cost of an LLM API call is calculated as: Cost = (Input_Tokens / 1,000,000) * Input_Price_Per_Million + (Output_Tokens / 1,000,000) * Output_Price_Per_Million. Here, Input_Tokens is the number of tokens in the prompt (including system and user messages), Output_Tokens is the number of tokens generated in the response, Input_Price_Per_Million is the model's cost per million input tokens (e.g., $3.00 for GPT-4o mini), and Output_Price_Per_Million is the cost per million output tokens (e.g., $12.00 for GPT-4o mini). The division by 1,000,000 converts the token count to millions, matching the pricing unit. This formula is necessary because LLM providers charge differently for input and output tokens due to the higher computational cost of generation (output) versus processing (input). The result is a monetary value (e.g., in USD) that represents the exact cost of that specific API call. For a workload, sum costs over all calls or multiply by call volume.
E-commerce Customer Support Chatbot
An e-commerce company uses GPT-4o mini to answer customer queries. A support conversation has a prompt of 2,500 input tokens (user question + previous messages) and generates a response of 150 output tokens. GPT-4o mini prices: $0.15 per million input tokens, $0.60 per million output tokens. Input cost = (2,500 / 1,000,000) * 0.15 = 0.0025 * 0.15 = $0.000375. Output cost = (150 / 1,000,000) * 0.60 = 0.00015 * 0.60 = $0.00009. Total cost = $0.000465 per query. For 10,000 queries per day, daily cost = $4.65.
Legal Document Summarization Service
A legal tech startup uses Claude 3.5 Sonnet to summarize contracts. A typical contract has 80,000 input tokens (the full document) and the summary is 1,000 output tokens. Claude 3.5 Sonnet prices: $3.00 per million input tokens, $15.00 per million output tokens. Input cost = (80,000 / 1,000,000) * 3.00 = 0.08 * 3.00 = $0.24. Output cost = (1,000 / 1,000,000) * 15.00 = 0.001 * 15.00 = $0.015. Total cost = $0.255 per summary. For 500 summaries per month, monthly cost = $127.50.
Real-Time Translation for a Travel App
A travel app uses Google Gemini 1.5 Pro for real-time translation of user text. Each translation request has 50 input tokens (short phrase) and 40 output tokens (translated phrase). Gemini 1.5 Pro prices: $0.0005 per million input tokens (free tier), $0.001 per million output tokens. Note: Prices are hypothetical for illustration; actual Google pricing varies. Input cost = (50 / 1,000,000) * 0.0005 = 0.00005 * 0.0005 = $0.000000025. Output cost = (40 / 1,000,000) * 0.001 = 0.00004 * 0.001 = $0.00000004. Total cost = $0.000000065 per translation. For 1 million translations per month, cost = $0.065.
A 'good' cost per call depends heavily on the use case. For consumer-facing apps like chatbots, a cost under $0.001 per call is often acceptable, while enterprise document processing might tolerate $0.10-$0.50 per call. The key principle is to compare cost against the value generated (e.g., revenue per conversion or time saved). Generally, input-heavy workloads (e.g., long prompts) are cheaper than output-heavy ones because output prices are typically 3-5x higher. For budgeting, model choice is critical: smaller models (e.g., GPT-4o mini) cost 10-100x less than flagship models (e.g., GPT-4o). Always account for token caching, batching discounts, or free tiers that providers may offer. There is no single 'good' number—it's about balancing accuracy, latency, and cost for your specific task.
A common mistake is forgetting that output tokens are often priced higher than input tokens, leading to underestimates of cost for generative tasks. Another error is using character counts instead of token counts—tokens are subword units (roughly 0.75 words per token for English), so assuming 1 token per word overestimates cost. Edge cases include very long prompts (e.g., 100k+ tokens) where costs become significant, or caching that reduces input cost but not output cost. Some users ignore the per-million unit and calculate directly (e.g., 1000 tokens * $0.15 = $150), which is off by a factor of 1000. Also, forgetting to account for system messages or tool call tokens in the input count leads to undercounting. Finally, not updating prices when providers change them (e.g., price drops) can lead to outdated budgets.
- Token
- A unit of text processed by an LLM, roughly corresponding to a word part or punctuation mark; English text averages about 1.3 tokens per word.
- Input Tokens
- The tokens in the prompt sent to the LLM, including system instructions, user messages, and any previous conversation history.
- Output Tokens
- The tokens generated by the LLM in response to the prompt, representing the completion or answer.
- Per-Million Token Price
- The cost charged by an LLM provider for processing one million tokens, typically split into separate input and output prices.
- API Call Cost
- The total monetary cost of a single request to an LLM API, calculated from the number of input and output tokens and their respective per-million prices.
How do I count tokens for a prompt?
Use the tokenizer tool provided by the LLM provider (e.g., OpenAI's tokenizer) or programmatically via their API's token counting method, as different models may tokenize differently.
Why are output tokens more expensive than input tokens?
Generating output requires more computational resources (e.g., memory bandwidth and sequential processing) than processing input, so providers charge a premium for it.
Does this calculator account for caching or discounts?
No, it uses standard per-million prices. For cached input tokens, some providers offer reduced rates; adjust the input price accordingly in the formula.
Can I use this for batch processing?
Yes, but batch costs are typically half the standard price for some providers; apply the batch price per million tokens instead.
What if my model has a different price for context windows?
Some models have tiered pricing based on context length (e.g., 128k vs 32k). Use the price corresponding to your actual context window size.
How accurate is this for non-English text?
Tokenization varies by language; non-English text may have more tokens per word, so use the provider's tokenizer for accurate counts.
Do I need to include system messages in input tokens?
Yes, all tokens in the prompt, including system, user, and assistant messages, count as input tokens.
What is the minimum cost I can expect?
For very short prompts and responses (e.g., 10 input tokens, 5 output tokens) with a cheap model, the cost can be as low as $0.000001 per call.
Building on AI? Apex AI staff are owned outright — no per-token bill that scales with every conversation.
Startup Cost Calculator
Add up what it really takes to launch — and what a bundle replaces.
Service Pricing Calculator
Price every job for profit, not guesswork.
Break-Even Calculator
The exact number of jobs that turns the lights green.
Revenue Goal Calculator
Reverse-engineer the leads behind your number.
Catalog ROI Calculator
The time and money the catalog hands back every year.