Level : Advanced

AI API pricing: how the bill works and how to cut it without losing quality

By The Info Agent IA editorial team ·

A desk seen from above with a calculator, coins and a stream of small glowing cubes suggesting billed tokens.

AI API pricing is calculated per million tokens, with one rate for the text the model reads and a higher rate for the text it writes. To lower the bill, you first need to know what you actually send on each call, then match the model to the task and switch on the discounts providers already offer.

How an AI API bills you

When you plug a model into an app, a website or an automation, you go through its API, a technical entry point. You no longer pay a flat subscription but for usage, measured in tokens: chunks of text a few characters long. Since a single token costs a fraction of a cent, providers quote a price per million tokens.

Almost every price list has two rates:

  • input: everything the model reads (instructions, history, documents, the question);
  • output: everything it writes, including, for providers that say so, its hidden reasoning tokens.

The formula fits on one line:

cost = input tokens × input price ÷ 1,000,000 + output tokens × output price ÷ 1,000,000

Two details matter a lot. First, the same text does not produce the same number of tokens on every model, because each tokenizer splits text its own way. Second, output costs several times more than input with most providers, so a chatty answer quickly outweighs a long document. To see how many tokens your own text represents, paste it into our token estimator.

Model prices as of October 22, 2026

Prices change often, which is why the date of the snapshot matters. The table below shows public list prices compiled by models.dev, collected on October 22, 2026, for a selection of recent models, from flagship to lightweight.

ModelDeveloperReleaseContext (tokens)Input ($/M tokens)Output ($/M tokens)Open weights
Claude Opus 5.5 AnthropicSeptember 22, 20261 M $4$20No
GPT-6 Astra OpenAISeptember 4, 20261.05 M $10$50No
Gemini 4 Argon Google DeepMindOctober 13, 20261.05 M $2$10No
Claude Sonnet 5.5 AnthropicSeptember 28, 20261 M $2$10No
Mistral Large 4 Mistral AIOctober 6, 20261.05 M $1.36$4.18No
DeepSeek V4.1 Flash 1017 DeepSeekOctober 17, 20261.05 M $0.15$0.60Yes
Claude Haiku 5.5 AnthropicOctober 7, 20261 M $0.10$0.50No
GPT-6 Luna OpenAISeptember 22, 20261.05 M $0.10$0.50No
Qwen3.7 Flash Alibaba Cloud (Qwen)July 15, 20261 M $0.03$0.13No
Source: models.dev (median provider price when the developer does not publish its own), data as of October 22, 2026 · method.

The next chart shows the output price of the same models. The gap between the most expensive and the lightest runs into tens of times, which makes model choice your biggest lever.

Output price ($ per million tokens)

Source: models.dev (median provider price when the developer does not publish its own), data as of October 22, 2026 · method.

A worked example: same workload, two models

Take a fictional but realistic case: a customer support assistant for an online store that handles 1,000 conversations a day. Each conversation sends about 1,500 tokens (instructions, history, question) and receives 500. That adds up to 1.5 million input tokens and 0.5 million output tokens per day.

Using models.dev prices from October 22, 2026:

ModelInput per dayOutput per dayTotal per dayOver 30 days
Claude Haiku 5.51.5 × 0.10 = $0.150.5 × 0.50 = $0.25$0.40about $12
Claude Opus 5.51.5 × 4 = $60.5 × 20 = $10$16about $480

The same service costs 40 times more on the flagship model. Notice too that in both cases output, though three times smaller in volume, weighs more than input. This math does not tell you which model serves your customers better: it tells you how much the quality gap is worth to you. To rerun it with your own volumes and other models, use our agent cost calculator.

What inflates the bill without warning

Overruns rarely come from the listed price. They come from the real token volume, which people tend to underestimate.

  • Conversation history. An API remembers nothing: to keep context, the whole conversation is sent again with every message. By the twentieth turn, you are paying to reread the previous nineteen.
  • System prompt and attached files. Standing instructions and documents placed at the start of a request are reread, and billed, on every call.
  • Reasoning. A reasoning model produces thinking tokens billed as output. A three-line answer can cost as much as a full page.
  • Agent loops. An agent that plans, calls a tool, reads the result and tries again makes several calls for a single task, each with its own context. Our guide on how to build an AI agent, from no-code to code explains how these loops work.
  • Retries. An error, a malformed output or hitting a rate limit triggers a new call, which is billed again.
Check yourself Your agent costs twice what you planned, yet the number of users has not changed. What should you check first?

The average number of tokens per task, with input and output tracked separately. A jump usually comes from growing history, a document added to the system prompt, a higher reasoning setting or an agent taking more steps. Request logs in the provider’s console or an observability tool will show it call by call.

Seven ways to cut the bill

Here are the most effective levers, from the simplest to the most technical. None of them requires giving up quality, as long as you measure before and after.

LeverWhat it doesEffort
1. Pick the model per taskKeep flagship models for hard tasks onlyLow
2. Shorter outputsAsk for a brief format, set a maximum lengthLow
3. Prompt cachingPay less for a repeated request prefixLow to medium
4. Batch processingGroup tasks that are not urgentMedium
5. Leaner contextSummarize history, send only useful passagesMedium
6. Tune reasoningLower thinking effort for simple tasksLow
7. Cap agent loopsLimit an agent’s steps and retriesMedium

1. The right model for each task. Sorting an email, pulling out a date or rephrasing a sentence does not need the most powerful model. A common setup routes triage and simple work to a light model and only calls the flagship for hard cases. In the support example above, if the light model handled most conversations and only the trickiest ones were escalated, the monthly bill would land much closer to the low figure than the high one. The exact saving depends on your escalation rate, so measure it on real traffic. Our model comparison tool helps you spot cheaper candidates with similar capabilities.

2. Shorter outputs. Since output is the expensive part, ask explicitly for a concise format, a list instead of a paragraph, or structured output in JSON when software reads the answer. The techniques in our prompt engineering guide help here too.

3. Prompt caching. Prompt caching reuses the processing of a request prefix that stays identical from one call to the next. According to Anthropic’s documentation, cited in our glossary, writing to the cache costs 1.25 times the normal input price and reading from it 0.1 times that price. Put stable content first and the user’s question last.

4. Batch processing. For work that can wait (summarizing an archive, tagging thousands of records), several providers offer a cheaper delayed queue. Anthropic states a 50% discount on both input and output, according to its documentation as summarized in our glossary.

5. Leaner context. Instead of sending an entire manual with every question, pass only the relevant passages: that is the idea behind RAG, which lets an AI use your documents without rereading everything each time. Summarizing a long history from time to time has the same effect.

6. Reasoning on demand. Many recent models let you set the reasoning effort. Keep it low by default and raise it only for tasks that need it.

7. Guardrails on agents. Set a maximum number of steps and retries, and stop the agent if it goes in circles. This is a safety issue as well as a money issue.

Open weights and local AI: really free?

Open-weight models can be downloaded and run on your own hardware. There is no per-token bill anymore, but the cost moves elsewhere: hardware, electricity, maintenance and your time. For personal use or sensitive data, it is a serious option, covered in our tutorial on how to run AI locally. For a high-traffic service, it takes real math, because a well-sized server is expensive even when idle.

Many open-weight models are also offered through hosting providers’ APIs, often at low prices: the table above includes one example.

Monitor and cap your spending

Before you put a service into production, take three simple precautions.

  • A cap and alerts. The major providers’ consoles let you set a spending limit or get notified at a threshold. Set them on day one.
  • One API key per project. You will know which service uses what, and a leaked key will not drain your whole budget. Never put it in public code.
  • Regular reviews. Check cost per task and average tokens every week. Drift shows up early, well before the monthly invoice.

If you work for a company, loop in whoever handles purchasing early on. Pay-as-you-go spending is easy to start on a personal card and hard to track later, so check whether your provider offers an organization account with separate projects, roles and billing.

Frequently asked questions

Why is my API bill higher than I expected?

Usually because you are paying for more tokens than you think. The system prompt, the conversation history, attached documents and the model's internal reasoning are billed on every call. An agent that runs several steps multiplies those reads.

Does a chatbot subscription include API access?

Generally not. Consumer subscriptions are flat plans with usage limits, while the API is pay as you go on a separate developer account. Check the provider's pricing page, because the rules differ.

Which model is the cheapest?

The cheapest model per million tokens is not always the cheapest in practice. A low-cost model that fails often, writes too much or needs retries can end up costing more. Compare on your own tasks with a small test set.

How do I avoid a nasty surprise on the bill?

Set a spending cap and alerts in the provider's console, use one API key per project and review usage every week. For an agent, also limit the number of steps and retries it is allowed to make.

Go further