Skip to main content
EEason
Back to Insights
PublishedAI Engineering6 min read

How to Estimate LLM API Calling Costs

Reproduce a 50,000-task monthly estimate in the calculator, separating regular input, cache reads, and output.

TL;DR · Summary

Reproduce the calculator default: 50,000 monthly tasks at one call each cost $302.50. With a zero cache hit rate and all other inputs unchanged, the estimate rises to $362.50.

When budgeting for an LLM application, I start with three questions: How many tasks do we handle per month, how many model calls does each task require, and how many tokens does each call actually use? The rate card tells us what a million tokens cost. These three questions tell us how many we will buy.

The worked example below separates a single call into three charges before scaling it up to a monthly budget. You can reproduce it online.

Run the first estimate in the calculator

Suppose a knowledge Q&A endpoint handles 50,000 tasks a month and makes one model call per task. Each call averages 3,200 input tokens and 650 output tokens. The calculator defaults to Balanced Studio, an illustrative tier.

ParameterValue
Monthly tasks50,000
Model calls per task1
Average input / output3,200 / 650 tokens
Prefix cache hit rate40%
Regular input rate$1.25 / million tokens
Output rate$5.00 / million tokens
Cache read rate25% of regular input, or $0.3125 / million tokens

Open the link, keep USD and 1× calls selected, and leave custom pricing off. The estimate should be $302.50/month. All prices are demonstration values chosen to make the example reproducible.

Open the prefilled AI Cost Calculator

Work through a single call by hand

In this simplified model, a 40% cache hit rate means 40% of input tokens are billed at the cache read rate. An average request has 1,280 cached input tokens and 1,920 regular input tokens. Output is priced separately.

ChargeCalculationCost per call
Regular input1,920 × $1.25 ÷ 1,000,000$0.00240
Cache read1,280 × $0.3125 ÷ 1,000,000$0.00040
Output650 × $5.00 ÷ 1,000,000$0.00325
Total$0.00605

Monthly cost = $0.00605 × 50,000 = $302.50

Keep full precision until the monthly total, then round to cents. Rounding the per-call price first magnifies the error when it is multiplied by request volume.

Change one variable at a time

Reset the calculator to its defaults before each of these three tests.

Change only this inputMonthly costVersus baseline
Cache hit rate from 40% to 0%$362.50+$60.00
Cache hit rate from 40% to 65%$265.00−$37.50
Monthly tasks from 50,000 to 100,000$605.00+$302.50

Under these inputs, output accounts for about 54% of each call. Increasing average output from 650 to 850 tokens adds $50 a month, all else equal. Find the largest cost driver before choosing among cache improvements, shorter responses, and changes to the calling workflow.

Move from a demo budget to a real bill

Count the input tokens actually sent to the provider. The user question is only part of the input. System instructions, chat history, tool descriptions, and retrieved context may all be included. For sampling, start with the usage returned by the model API, separating regular input, cache reads, and output. Record cache writes separately if the provider bills for them.

Track business tasks and model calls separately. Start a single-turn Q&A flow at 1×. Agent loops, fallback models, and retries add calls. The calculator’s multi-turn setting is useful for scenarios where each call costs the same. Estimate each call separately when later turns carry more history or a fallback uses a different model.

Reconcile by feature after launch. I start by recording feature name, model, input, cache reads, and output tokens, then compare weekly task volume with actual spend. If costs exceed the budget, establish whether traffic grew, each task triggered more calls, or requests got longer. Each cause suggests a different fix. LiteLLM and Langfuse offer open-source references for cost computation and usage tracking.

This method gives you a model-call budget that you can explain and reproduce. For procurement or launch estimates, replace demo rates with actual provider rates, account for retrieval, storage, and tool calls, and reconcile against real usage and invoices after launch.

Current Share & Citation URL

https://imeason.com/en/insights/estimate-llm-api-costs

Companion Lab Tool

AI Cost Calculator

Real-time client-side estimator comparing token budgets, prompt cache savings, and monthly LLM spend across tiers.

Related Architecture

Prism · Model Routing & Cost Accounting Blueprint

Layered gateway reference for multi-model routing, prompt cache accounting, and transparent per-feature token budgeting.