← All articles
Guides

Understanding the costs of AI APIs

From tokens to caching and batch processing: understanding your AI bill, comparing providers and calculating the cost of a task that actually worked.

Ricardo Sargo·5 min read
CommentWhatsAppLinkedIn

A cheap request can hide an expensive workflow

Imagine two tools performing the same task. The first costs less per request but takes three attempts to produce an acceptable answer. The second is more expensive per request but gets it right the first time. Which would you choose?

It is a hypothetical situation, yet the question resembles many investment decisions: looking only at unit prices can produce misleading conclusions. With AI, I prefer to start with the cost of achieving the desired result. To get there, we need to understand what we are paying for.

What goes into an API bill

An API lets one program send requests to another system. In an AI API, input generally includes instructions and information for the model to process; output is the material it generates. Many services quote prices per million tokens, distinguishing input, output and reused input.

When comparing OpenAI and Google pricing, also check processing mode, model and caching conditions. External tools, storage and specialized features can introduce separate charges. Do not assume every line of a pricing table applies to every model. Pay attention to currency conversion too.

A basic calculation multiplies each token category by its applicable rate, using the correct units, then adds other applicable charges. You do not need to memorize the prices. Use the provider's official pricing page.

Let's put numbers into an example

For illustration only, suppose a hypothetical API charges $2 per million input tokens, $10 per million output tokens and $0.20 per million reused input tokens. These are not actual commercial rates. Imagine a task with 80,000 uncached input tokens and 20,000 output tokens.

Input would cost $0.16 and output $0.20, for $0.36 before other costs. If 60,000 of the input tokens were charged at the reused-input rate, uncached input would cost $0.04, cached input $0.012 and output $0.20. The total would be $0.252. The token count remains unchanged, but this part of the bill would be 30% lower.

This is deliberately simplified. It does not include cache creation, storage, taxes or external calls. It illustrates why reducing tokens and reducing spending are not equivalent.

Caching, batching and the value of time

OpenAI documents prompt caching as a way to reuse processing for repeated inputs. The Gemini API also offers caching options whose conditions vary by model and interface. If a workflow repeatedly consults the same information, investigate available mechanisms before deciding how to organize it.

Batch processing is another interesting option. OpenAI and Google offer processing modes that can be more economical when work does not require an immediate response. Think of classifying thousands of documents overnight. There may be little reason to pay for the same priority a live customer conversation requires.

Time has value too. A less expensive mode might not meet the needs of an operation that must respond in seconds. The goal is to balance deadline, cost and quality rather than choose the lowest rate every time.

The most expensive model is not always the most economical

An agent may need deep reasoning to diagnose a delicate problem. Extracting standardized fields from documents might be handled by a smaller model, provided its quality is verified. Applying one configuration to every task can make costs harder to manage.

I would segment activities by risk, difficulty and time sensitivity, then test alternatives on representative examples. Record failures and additional attempts too. A convincing answer that gets important details wrong can create expenses that do not appear in the pricing table.

That is why at Dorothy, we think of Dorothy Merge as a platform focused on operational efficiency, not simply reducing one metric. Different tasks deserve suitable approaches within the project's quality and control requirements.

Build a measurement that fits your situation

Sample common activities. For each, record token categories, additional resources, model settings and the cost reported by the API. Then count how many tasks passed validation without correction. Divide total cost by the number of accepted tasks to estimate cost per successful outcome.

If you are using a subscription, do not apply API pricing directly to subscription usage. You may produce a comparative estimate, but it is not an actual charge. Separate the amount paid, usage allowance and estimated consumption, particularly when comparing different services.

Finally, establish spending limits and alerts appropriate to your workflow. Check whether the controls actually stop usage or merely notify you. A notification is not necessarily an enforced budget cap.

What does it cost to complete something worthwhile?

Pricing changes with new model generations. OpenAI's pricing page distinguishes processing speeds and caching; Google's describes processing conditions. Comparing an old screenshot of a pricing table is a recipe for outdated decisions.

I recommend revisiting these conditions whenever you change models, increase volume or add a tool. The best bill is not necessarily the smallest dollar amount. It is the one that enables reliable results at a cost you understand and can manage. That is how technology starts to make sense as an investment.

Sources and further reading

References checked on November 27, 2026.

Conversation with the author

Share your experience, ask a question or leave your thoughts on the article.

Loading interactions…

Keep exploring