FRENES

Guide · Intermediate · 10 min

Understanding LLM API pricing: tokens, input and output, caching, batch processing, and budgeting

Understand LLM API pricing, from input and output tokens to caching and batch discounts. Estimate a realistic application budget and track actual spending.

By ·

A taxi meter with two dials, stacked coins and a cache drawer

LLM API costs depend mainly on the tokens you send to the model and the tokens it generates, with separate rates for input and output. Caching, batch processing, and additional services affect the calculation: to estimate a budget, measure the cost of a complete task, then multiply it by your expected volume.

Reading a price: unit, model, and provider

A rate quoted per million tokens is a unit price, not a package you have to buy. You pay for the corresponding usage: a short call does not require purchasing a million tokens. Input and output are separate charges, and other billing units may apply alongside them.

Before comparing prices, record the exact model, provider, currency, processing mode, and date. Check the conditions attached to the rate, including context length, modality, execution region, or commercial commitment. A single line in a pricing table may not describe how your application will be billed.

The language model profiles provide a reference for reviewing these characteristics. The benchmark comparison tool adds another perspective: a model with a lower token price can cost more per acceptable result if it needs several attempts.

Also distinguish between a subscription to an interface, that service’s API billing, and fees charged by an intermediary platform. Do not infer what one includes from the price of another. For a business application, keep a copy of the pricing schedule that applies to your account, along with the date you checked it, as part of your estimate.

The official pricing and mechanisms cited in this guide were checked on October 24, 2026. Treat them as dated reference points. Calculations explicitly labeled as assumptions illustrate a budgeting method; they do not represent measured usage.

Counting tokens instead of words

A token is a unit the model uses to represent content. It can correspond to part of a word, a punctuation mark, or another segment of text. Character count alone therefore cannot give you an exact cost.

Tokenization depends on both the model and the content. French text, code, tables, and identifiers do not necessarily break down in the same way. Avoid using a universal conversion between words and tokens when preparing a budget. A token count obtained for one model should not be reused for another without checking it.

Count the complete request as well. It may include system instructions, previous messages, documents, tool descriptions, and schemas for the expected response. The text entered by the user may account for only a small share of that total.

As of October 24, 2026, Anthropic’s token-counting documentation states that its estimation feature accepts system instructions, tools, images, and PDFs, among other inputs, with restrictions depending on how they are submitted. It also distinguishes the estimate made before a call from the usage actually reported afterward.

For budgeting, prepare a representative sample covering short requests, long documents, conversations, and difficult cases. Count each request for the model you intend to use, then retain the actual usage figures during your pilot. This keeps an unusually simple example from becoming the basis for your entire forecast.

Separating input, output, and reasoning

Input is the content the model processes; output is the content it generates. The rates can differ substantially. A summarization application and a writing application should therefore not be compared solely on their combined token volumes.

Take Claude Sonnet 5.5: as of October 24, 2026, Anthropic lists $2 per million input tokens and $10 per million output tokens on its official pricing page. At those rates, an output token costs five times as much as an input token.

Assuming 4,000 input tokens and 800 output tokens per call:

  • Input: 4,000 × 2 ÷ 1,000,000 = $0.008.
  • Output: 800 × 10 ÷ 1,000,000 = $0.008.
  • Total: $0.016 per call, excluding other charges.

Output accounts for half the cost here, despite its volume being five times smaller. These quantities are illustrative assumptions, not measurements of the model.

The visible response does not always account for all generated tokens. Google’s pricing table explicitly includes thinking tokens in certain output pricing categories, according to the offerings documented on October 24, 2026. Check what your usage counter includes before calculating the charge.

An output limit helps contain usage, but setting it too low can cut off an otherwise useful response. Test length, quality, and retry rates together: saving money on an interrupted call may leave you paying for a second one.

Checking context tiers and modalities

An advertised rate may apply only within certain length limits. Check the threshold, the token categories affected, and whether a higher rate applies to the whole request or only part of it. Never assume that every additional token has the same price.

For an official example dated October 24, 2026, Claude Haiku 5.5 is listed at $0.10 per million input tokens and $0.50 per million output tokens for prompts up to 100,000 tokens. Beyond that threshold, the same Anthropic pricing page lists rates of $0.50 and $2.50, respectively.

This distinction means an overall monthly average is not enough. Two applications with the same total token usage may distribute their requests differently across pricing tiers. Retain the length of each call so you can reconstruct its cost accurately.

Multimodal inputs also require a separate reading of the pricing terms. For a document, image, or recording, identify the unit specified by the provider: tokens, duration, images, or another contractual unit. Do not apply a text-based estimate to a file without checking how the service processes it.

A large context window describes a technical capacity, not a recommended spending level. Sending an entire collection of documents can increase costs and make the information harder to use effectively. Measure the effect of selecting relevant documents before deciding how much content to send.

Understanding caching and its break-even point

Prompt caching lets a model reuse an input prefix it has already processed. It is particularly useful for stable instructions or documents shared across several requests. It does not mean the service returns the previous response unchanged.

Its value depends on the cache reads you actually obtain. A changed prefix, calls spaced too far apart, or a request that is too short can prevent the reuse you expected. Put stable content before variable information, then check the usage counters.

As of October 24, 2026, Anthropic’s official prompt-caching documentation lists Sonnet 5.5 rates, per million tokens, of $2.50 for a five-minute cache write and $0.10 for a cache read, compared with $2 for ordinary input.

Assume a 10,000-token prefix is used ten times, with one cache write followed by nine valid reads:

  • Without caching: 100,000 × 2 ÷ 1,000,000 = $0.20.
  • With caching: 10,000 × 2.50 ÷ 1,000,000 + 90,000 × 0.10 ÷ 1,000,000 = $0.034.

This calculation excludes the variable portions of the requests and their output. For a single use, writing the cache would cost more than processing ordinary input.

The general calculation is straightforward: compare the cost of processing every use as ordinary input with the write cost plus subsequent reads. If the prefix expires and has to be cached again, repeat the calculation. An advertised discount on cache reads therefore does not represent the reduction in your entire bill.

Distinguishing automatic and explicit caching

Automatic caching looks for opportunities to reuse content without necessarily requiring you to manage each item. Explicit caching requires dedicated configuration or management. The conditions vary by model and API.

Google’s caching documentation, updated on October 23, 2026, states that implicit caching is enabled by default for supported models. It also states that explicit caching is unavailable in the Interactions API and for Gemini 4 Argon and later models.

These differences mean you cannot carry a configuration from one offering to another without reviewing the documentation. Check the minimum length, required content stability, expiration rules, and available usage counters. If the pricing schedule charges for retaining cached content over time, include that storage charge in your calculation.

Focus on the share of tokens served from cache. Counting only requests with at least one cache read can be misleading: reusing a small portion does little to reduce the cost of a long, mostly variable input.

For an initial forecast, build a scenario without caching and another based on measured reuse. Use the first as a conservative baseline until the pilot confirms actual cache reads. This makes it clear how much your budget depends on requests repeating in practice.

Using batch processing for tasks that can wait

Batch processing means submitting requests for asynchronous processing. It suits work whose results can arrive later, such as document classification, periodic extraction, or an evaluation run.

As of October 24, 2026, Anthropic’s Message Batches documentation advertises a 50% discount and states that unprocessed requests expire after 24 hours. That time window should not be mistaken for a promise of an immediate response.

CriterionInteractive callBatch processing
Main requirementRespond during the interactionProcess work that can wait
Receiving resultsDuring the API callThrough later retrieval
Applicable pricingInteractive pricing scheduleThe offering’s batch pricing schedule
Error handlingRetry during the user flowTrack individual request statuses
SchedulingImmediate availability expectedQueue and completion deadline

Batch processing does not mean combining all your data into a single enormous prompt. Keep requests identifiable and independent so you can check the results and retry only the items that need it.

Do not automatically stack caching and batch discounts in your spreadsheet. Check whether they can be combined and what conditions govern reuse during processing. A cache that works well for closely spaced interactive calls may be less predictable in an asynchronous queue.

Moving from cost per call to a monthly budget

Build the budget around a useful unit of work: a case processed, a document validated, or a request resolved. Then measure every call needed to complete that unit. The LLM pricing calculator helps convert usage volumes into costs, but the quality of your assumptions remains decisive.

For each category, multiply the number of tokens by its rate and divide by a million when that is the pricing unit. Separate ordinary input, cache writes, cache reads, and output. Before adding usage counters together, check whether any already include another category.

Return to the earlier assumption: 4,000 input tokens and 800 output tokens, priced at $2 and $10 per million. For 20,000 monthly tasks, each requiring one call, the generation cost would be:

20,000 × 0.016 = $320 per month.

If you then assume that 10% of tasks need one additional identical call, that adds 2,000 calls, costing $32. The total becomes $352, excluding tools, infrastructure, and applicable taxes. These volumes and the retry rate are assumptions used for the simulation.

Include a range of usage scenarios:

Hypothetical scenarioMonthly tasksAverage calls per taskCalculated generation cost
Lower volume10,0001$160
Baseline with retries20,0001.1$352
Higher volume with retries30,0001.1$528

These scenarios keep the length of each call unchanged. If additional requests are longer, calculate their cost separately instead of applying the same multiplier across all calls.

Adding costs beyond the model

Token calculations do not necessarily cover the whole application. External searches, code execution, document storage, and indexing can create additional charges. Record the billing units and conditions set out in the relevant agreements.

A service can also trigger several successive charges: an external call, retrieved content sent to the model, and then response generation. Identify these stages so you neither omit a cost nor count the same one twice.

For a usable budget, distinguish between:

  • Generation and retries.
  • Tools and services called.
  • Hosting, storage, and logs.
  • Licenses and platform fees.
  • Time spent on human review.

Cost per accepted result connects spending to usefulness. Divide spending within your chosen scope by the number of results that meet your acceptance criteria. Always specify that scope: a measure limited to tokens cannot be compared directly with one that includes human review.

The article How much does an AI agent really cost per month? extends this analysis to operating expenses. When comparing two solutions, use the same expected quality level and the same cost categories.

Controlling loops, retries, and spending limits

An agent may make several calls to handle a single request. Each step can add content, including observations, tool results, and previous messages. Usage therefore depends on both the number of steps and the size of the context at each step.

For a purely arithmetic example without caching, assume an initial call with 2,000 input tokens, followed by nine calls whose input grows by 1,000 tokens each time. The total reaches 65,000 input tokens, even before counting output. Ten calls do not simply mean ten times the initial input.

Set limits per task for the number of steps, output volume, elapsed time, and permitted retries. A repeated error should trigger an explicit stop or intervention, rather than another attempt without diagnosing the problem.

Also distinguish between an alert and a hard limit. A spending notification does not impose a technical cap. When several calls run in parallel, some of the budget may already be committed before usage figures come back.

Allow for calls already in progress and enforce controls within the application. The guide Reducing the cost of an AI agent explains the tradeoffs between context size, routing, and execution limits.

Tracking spending and comparing at consistent quality

During the pilot, associate each usage record with a task and an outcome. Retain the provider, exact model, processing mode, token categories, tool calls, and reasons for retries. Store only the data needed for monitoring.

Examine the average, but also how widely usage varies. A small number of long tasks can account for a substantial share of the bill. Separate request types so you can distinguish increased traffic from a change in usage patterns or a configuration problem.

Periodically reconcile your estimates with the provider’s reported usage. A difference may come from caching, an incorrectly applied rate, an overlooked token category, or calls made outside the workflow you are tracking. Document the cause before changing your assumptions.

When considering a different model, compare identical tasks and measure accepted results, completion time, and retries. The guide Choosing a language model develops this approach further. Token pricing then becomes one of several factors that determine the cost of delivering a useful result.

Key takeaways

  • Count the complete request and separate input, output, caching, and additional services.
  • Date your pricing references and check the conditions for context length, modalities, and processing mode.
  • Budget for a complete task, including retries, then build several volume scenarios.
  • Measure caching and batch savings against your actual workload.
  • Track cost per accepted result and put application-level limits in place before scaling up.

Related pages

Frequently asked questions

How much does a million tokens cost?

There is no single price: it depends on the model, provider, and token category. Compare input, output, and cache reads separately, then check any conditions tied to context length or processing mode.

Does an AI assistant subscription include API access?

Check the access rights and credits explicitly included in your agreement before assuming it does. When budgeting for an application, separate user licenses, any included credits, and usage billed by the API provider.

Can you know the exact cost before making an API call?

You can estimate input usage and calculate a spending allowance using an output limit. The final charge still depends on the tokens actually generated, cache usage, and any additional services. Compare your estimate with the reported usage afterward.

Does caching make responses free?

Prompt caching reuses input content that has already been processed; the model still has to generate a response. An application can also store a complete response and serve it without another API call, but it must manage the response's validity and access permissions.

How much should you budget for an AI agent?

Start with the number of tasks and measure every call needed to complete each one, including retries. Add tools, hosting, and oversight. A price per message does not adequately represent a task that involves several steps.

Other guides

Neutrality. No affiliate links. No vendor pays to be reviewed, rated or ranked. Reviews are directed by François Chollet, neutral and factual, and every data point is dated and sourced. How we score