AI Cost Calculator
What does each AI API call actually cost you?
Enter your token counts and the model's pricing to see exactly what each AI API call costs. Works with any provider that charges per token — OpenAI, Anthropic, Google, and others.
—
Send feedback
💡 Share your idea or report a problem
✓ Thanks! We'll take a look.
Learn more
How It Works
The formula, explained simply
Think of token pricing like a photocopier that charges differently for the pages you feed in versus the copies it prints out. Every AI provider that sells API access separates the cost of reading your prompt from the cost of writing the response. Those two numbers — input price and output price — multiplied by how many tokens you use, determine the exact bill for every call.
A token is not a word and not a character. It is the smallest chunk the model processes — roughly four characters of English text, which works out to about ~750 words per 1,000 tokens. Code, JSON, and non-Latin scripts tokenize differently, often producing more tokens per character. The token count you see in an API response is the authoritative figure; estimated counts from word counts are useful for budgeting but should not substitute for real usage data in production monitoring.
The separation of input and output pricing matters because the model treats them asymmetrically. Input tokens are processed in one parallelized pass; output tokens are generated one at a time in sequence. Providers price them separately to reflect that operational reality. When you are evaluating models or designing workflows, the ratio of input tokens to output tokens in your typical request is therefore a first-class variable — not just the per-token price.
When To Use This
Right tool, right situation
Use this calculator any time you need to predict, verify, or compare the cost of an AI API call. It is directly useful when evaluating whether a new workflow is financially viable, comparing two models with different pricing tiers, setting per-request cost budgets for a production application, or auditing a bill that came in higher than expected.
It is also well suited for back-of-envelope projections. If you know your average token counts from a few test requests, multiply the result by expected daily or monthly call volume to get a cost estimate you can put in front of a finance team or include in a project proposal.
This calculator is not appropriate for workloads that involve volume discounts, prepaid credit packs, enterprise agreements, or caching credits — these change the effective per-token price and require a model that accounts for those adjustments. Batch API pricing, which some providers offer at a steep discount for asynchronous jobs, also falls outside what a straight per-token calculation captures. For those cases, treat this tool's output as the list-price ceiling and adjust downward based on your actual contract terms.
Common Mistakes
Why results sometimes look wrong
Confusing tokens with words or characters. The most common budgeting error is estimating token counts from word counts alone. Code files, JSON payloads, and structured data can tokenize at two to three times the rate of plain English prose. A developer who budgets for a ~2,000-token code review and gets a ~5,000-token bill has made this mistake. Always measure real token counts from a few representative requests before projecting costs at scale.
Forgetting that conversation history is re-sent on every turn. In a multi-turn chat application, the full message history is included in each API request. A session that feels like a short conversation can accumulate thousands of input tokens because every prior turn is re-tokenized and priced on each call. Building a chatbot without accounting for context accumulation is the fastest path to a surprise invoice.
Using input pricing for both input and output. Some developers find a single headline price on a provider's landing page and apply it uniformly. Output tokens are almost always priced higher. Using the wrong rate understates output-heavy workloads — like creative writing, code generation, or long-form analysis — by a factor of two or more. Always look up both rates on the provider's dedicated pricing page before calculating.
The Math
Worked examples and deeper derivation
The calculation involves two multiplications and one addition. Start with input cost: divide your input token count by 1000, then multiply by the input price per 1000 tokens. That gives the dollar cost of sending your prompt. Do the same for output: divide output tokens by 1000, multiply by output price per 1000 tokens. Add the two components together for total cost.
Using the example values: input cost = (1,500 ÷ 1000) × $0.003 = $0.0045. Output cost = (800 ÷ 1000) × $0.006 = $0.0048. Total = $0.0093. The division by 1000 converts the token count into the same unit as the pricing (which is stated per thousand), making the multiplication produce a dollar figure directly.
Because the formula is linear, cost scales exactly with token count. Doubling input tokens doubles input cost with no compounding or threshold effects. This linearity also means you can estimate monthly spend by multiplying per-call cost by expected call volume — a straightforward unit analysis that many practitioners find useful when setting API budget alerts.
Expert Unlock
The thing most explanations skip
The linear pricing model this calculator uses assumes every token costs the same regardless of position in the context window. In practice, several providers have introduced tiered or positional pricing for very long contexts — tokens beyond a certain position may cost more or less than tokens at the start of a prompt. If your prompts routinely approach or exceed ~32,000 tokens, verify whether your provider uses flat or positional pricing before treating this calculator's output as authoritative.
The formula also assumes input and output tokens are billed identically whether they appear in a single call or across batched calls. Batch APIs, when available, typically cut costs significantly by deferring execution to off-peak capacity. The per-token math is identical but the rates are not — always use the batch-specific pricing when modeling asynchronous pipelines.
What drives my AI API costs higher than expected?
Need something this doesn't cover?
Suggest a tool — we'll build it →