Tools

AI API Token Cost Calculator: Estimate Input and Output Costs

AI API Token Cost Calculator: Estimate Input and Output Costs

Estimate AI API spending from input and output tokens, request volume and model rates, with practical examples and ways to reduce costs.

Estimate the cost of an AI API before deploying it

Enter the rates published by your provider. Cached tokens, free tiers, batch discounts and taxes are excluded.

An AI model's advertised price is usually expressed per million input tokens and per million output tokens. Those rates can differ substantially, so the cost of an API request depends on both how much context you send and how much text the model generates.

Use the calculator above to estimate a daily or monthly budget. Replace the example rates with the current prices published by your chosen provider and model. The calculator does not fetch live pricing.

Step by step: calculate your API budget

  1. Measure input tokens. Include the system instructions, user message, conversation history, retrieved documents and any other text submitted to the model.
  2. Measure output tokens. Use the actual output token count from your API responses, or estimate it from a representative test.
  3. Enter requests per day. Start with observed usage or a realistic forecast, not an optimistic maximum.
  4. Enter the provider's prices per million tokens. Input and output prices must be entered separately, in USD for the calculator's current display.
  5. Compare the estimate with your budget. Repeat with a higher request count and longer prompts to understand possible growth.

The basic formula is:

Cost per request = (input tokens ÷ 1,000,000 × input rate) + (output tokens ÷ 1,000,000 × output rate).

Multiply the result by the number of requests to estimate total usage costs.

Worked example: an AI assistant for customer support

Assume a support assistant uses 2,000 input tokens and 500 output tokens per request. For illustration only, suppose the rates are $1 per million input tokens and $4 per million output tokens.

Item Calculation Cost
Input per request 2,000 ÷ 1,000,000 × $1 $0.002
Output per request 500 ÷ 1,000,000 × $4 $0.002
Total per request $0.002 + $0.002 $0.004
100 requests per day 100 × $0.004 $0.40/day
30-day estimate $0.40 × 30 $12.00

These prices are hypothetical, not quotations for any particular model. If your users send longer messages, or your application retains a growing conversation history, the input-token count can increase.

Illustration of the article's main concept

Worked example: generating articles with an API

Suppose a publishing workflow submits a long brief and reference material totaling 12,000 input tokens, then receives 3,000 output tokens. Using the same illustrative rates:

  • Input: 12,000 ÷ 1,000,000 × $1 = $0.012.
  • Output: 3,000 ÷ 1,000,000 × $4 = $0.012.
  • One generation: $0.024.
  • 50 generations: $1.20.

That estimate covers only these model calls. Research requests, rewrites, translation calls, retries, image generation and other services add to the total.

How to measure tokens instead of guessing

Most AI API responses expose usage information such as input and output token counts. Record those counts from a representative set of real requests, then calculate the average or a high-percentile value. For example, log the model name, operation type, input tokens, output tokens and whether the request succeeded. Avoid logging private prompt content unnecessarily.

A tokenizer can help you estimate prompt length before sending it, but the API's usage report is generally the better source for actual billing units. Token counts are not identical to word counts, and the ratio changes with language, formatting and code.

Why your invoice may differ

Cause What to check
Cached input tokens Whether the provider charges cached tokens at a different rate
Batch processing Whether an asynchronous batch discount applies
Retries and failed requests Whether they consumed billable tokens
Long conversation history Whether the entire history is resent on each turn
Tool calls or multimodal inputs Whether additional token types or separate fees apply
Model changes Whether the deployed model has different input/output rates
Taxes, credits and free tiers Whether they affect the amount actually invoiced

Important: the calculator uses a simple input/output pricing model. It does not separately model cached tokens, reasoning-token billing, audio, image or video charges, or provider-specific minimum fees.

How to reduce API costs without losing quality

Trim repeated context. Send the instructions and documents needed for the current task, rather than automatically attaching every earlier exchange.

Set sensible output limits. A concise extraction task rarely needs the same output allowance as a long report. Validate that the response still contains all required information.

Technical workflow illustration

Use the right model for each step. Classification, summarization and complex reasoning can have different quality and cost requirements. Benchmark on your own examples before switching models.

Cache reusable information when supported. Check the provider's rules for prompt caching and measure the real discount rather than assuming every request qualifies.

Monitor usage in production. Track tokens and cost per feature, user or job. Set alerts for sudden spikes and review loops that retry excessively.

FAQ

Does the calculator show live model prices?

No. Enter the latest input and output rates from your provider's pricing documentation. The default values are examples.

What if my provider charges in another currency?

The current calculator displays USD. Convert rates yourself using a clearly documented exchange rate if needed; the calculator does not perform currency conversion.

Can I estimate monthly cost from daily requests?

Yes. Multiply the daily estimate by the number of days you expect the application to run. A 30-day month is a useful planning convention, not a guarantee of actual usage.

Why are output tokens often more expensive?

Providers may set separate rates for generating tokens and processing input. Always check the specific model's current pricing instead of assuming one shared rate.

The worked examples are illustrative. Confirm billing units, current model prices and any discounts directly with the API provider before committing to a budget.