Guide
Calculate the API cost of an AI call, step by step
Input tokens times the input price, plus output tokens times the output price, divided by a million. That one line becomes a repeatable method with a worked example and the traps that quietly inflate the bill.

The API cost of an AI call comes down to one line. You multiply the input tokens by the input price, add the output tokens multiplied by the output price and divide the whole thing by a million. Nothing else goes into it. The formula turns into a repeatable method in three moves (count your tokens, find the prices, apply), with a full example that runs from the first cent to the monthly budget.
The stakes go beyond curiosity. Knowing how to price a call before you send it lets you size a project, compare two models on YOUR content and read your statement without surprises. Ten minutes of method buys years of accurate estimates. Get your calculator out, because everything else is provided, from dated official prices to calculation templates ready to copy.
01Key takeaways
- The formula is cost = (input tokens × input price + output tokens × output price) ÷ 1,000,000, since prices are shown per million tokens.
- To count, allow about 4 characters per token in English and 3 in French. The official tokenizers give the exact count.
- Output costs two to six times more than input. It's the output that makes the bill in creative work.
- The key example is a 1,000-word article, which costs less than one cent on a mid-range model and around three cents on a high-end one.
- Three traps are worth knowing in advance. They are invisible reasoning tokens, conversation context sent again at every turn and images billed separately.
02The one-line formula worth framing
The cost of a call equals (input tokens × input price + output tokens × output price) ÷ 1,000,000. Both prices are on the provider's official price list, stated per million tokens. Both token counts are measured or estimated with the ratios from step 1. That's the entire billing mechanism of the APIs for text, with no hidden exception, at every provider on the market.
This arithmetic transparency is the whole point of the main hub on pay-per-use AI. When you can recalculate a price by hand, you can check it, compare it and negotiate with yourself. No subscription offers that exercise. The formula gives you budget independence in a single line.
03Step 1, count your tokens
Three counting points are enough. The quick rule comes first, with about 4 characters per token in English and 3 in French, spaces included. In words, that means three quarters of an English word and a little more than half a French word per token. For a specific text, the providers' online tokenizers give the exact count once you paste it in. For the full background on the unit, the illustrated definition of a token is a ten-minute read worth doing first.
Remember that input counts EVERYTHING you send. That covers the instruction, the brief, the examples, the attached document and the conversation history where there is one. It's the line people underestimate most often. The habit to trim your instructions without losing quality pays off directly in the formula.
04Step 2, find the model's price
| Model | Input | Output |
|---|---|---|
| DeepSeek V4.1-Flash (peak hours) | $0.30 | $1.20 |
| GPT-5.4-mini | $0.75 | $4.50 |
| Claude Haiku 4.5 | $1 | $5 |
| GPT-5.4 | $2.50 | $15 |
| Claude Sonnet 4.6 | $3 | $15 |
Two readings help before you calculate. Output costs two to six times the input on these price lists, a gap explained in why output costs more. The gaps between models reach a factor of more than twelve in this table and a hundred across the whole market, which is why it pays to route each task to the right model. The full market tour, flagship models included, is in the provider price comparison.
05Step 3, apply it with a worked example
The goal is a 1,000-word article written from a careful brief. The brief, with its instructions and context, weighs about 800 input tokens. The article, 1,000 words of French, comes to about 1,700 output tokens. On GPT-5.4-mini that gives (800 × 0.75 + 1,700 × 4.50) ÷ 1,000,000 = $0.0083. That's eight tenths of a cent, brief included.
The same calculation on Claude Sonnet 4.6 gives (800 × 3 + 1,700 × 15) ÷ 1,000,000 = $0.0279, so less than three cents for high-end quality. Double everything for a full extra iteration and you stay under six cents. That's the entire method. You can redo it in thirty seconds for any volume and any model, with the official price list in front of you and nothing more than a multiplication. This arithmetic plainness is why the topic gets so little coverage, since there's nothing to sell around a rule of three.
06From the unit cost to the monthly budget
The rest is just multiplication. Ten articles a month with one iteration each make twenty generations, about $0.17 on the mid-range model from the example and $0.56 on the high-end one. Add the extras (rewrites, titles, meta descriptions), counted generously at 50% more. The full month then comes to between $0.25 and $0.85. Budgets observed on real profiles, from the blogger to the agency, are lined up in the real budgets observed.
One tip on method. Do this calculation properly ONCE, write down your assumptions (volumes, model, iterations), then hold it up against the statement for the first month. The gap between estimate and reality rarely exceeds 30% when the assumptions are honest. That gap is what calibrates all your future estimates.
07Three ready-to-copy calculations
Start with the weekly newsletter, 600 words of output for about 1,000 tokens, plus a 400-token brief. On the mid-range model from the example, (400 × 0.75 + 1,000 × 4.50) ÷ 1,000,000 = $0.0048 per issue, so about two cents a month. A whole year of newsletters stays under thirty cents of API. Keep that figure handy for the next discussion about what AI costs.
Next comes the product page, with 250 words of output (450 tokens) and a short 200-token brief. On the same price list it costs $0.0022 per page, a fifth of a cent. A catalog of 500 pages therefore comes to a little over one dollar. That explains why online stores adopted pay-per-use before everyone else, since volume holds no fear when the unit costs this little and the formula proves it in advance, page by page.
Last comes the customer FAQ reply, 120 words or about 200 tokens, on top of 600 tokens of history as context. The calculation gives $0.0014 per reply, so a thousand replies a month from an assistant stay under a dollar and a half. Three calculation templates give three orders of magnitude. You build your own on the same mold by swapping the numbers, then file them in a corner of a spreadsheet so each new project starts from them.
08The reverse calculation, what five dollars buys
Turning the formula around tells you more than you'd expect. Five dollars of credit on the mid-range model from the example covers about 600 articles of 1,000 words, brief included. On the high-end model it covers nearly 180. In weekly newsletters it covers decades of issues. In product pages it covers more than two thousand.
This reverse calculation is the best antidote to the fear of pay-per-use billing. A five-dollar bill, the size of a typical first top-up, covers volumes that a solo creator simply never reaches. The scarce resource is your time for proofreading and editing, never the budget. The formula shows it in thirty seconds and puts the budget talk back where it belongs, on the human cost of work done well.
09What pushes the bill up, known in advance
Reasoning tokens
Reasoning models think before they answer and that thinking is billed as output tokens, often invisible in the answer shown. On a complex task that hidden line can multiply the cost several times. Keep these models for problems that deserve them, because everyday writing almost never needs them. The formula stays accurate as long as you stick to classic models, the ones used in the examples.
Conversation context sent again
In a conversation, each turn sends the history back as input, so the tenth exchange pays for the nine before it. That's the mechanism that inflates long-running chat use. It has no equivalent in content generation, where each call starts again close to zero. If your uses are conversational, include the history in your input count.
Images and audio, billed separately
The formula covers text. Image generation is billed per image and audio by duration, on separate price lists from the same provider. The orders of magnitude stay gentle, a few cents per image, but they add to the calculation rather than fitting inside it. An illustrated article is therefore priced in two lines, the text through the formula and the visuals per piece.
10Classic estimation mistakes to avoid
The first mistake is confusing words and tokens. A 1,000-word article in French comes to about 1,700 tokens, far from 1,000. Forgetting that skews every estimate by a good third, always in the direction of a bad surprise. The ratios from step 1 settle the point for good.
The second mistake is forgetting the input. The brief, the examples and the reference document sometimes weigh more than the expected output, especially in analysis tasks where you send twenty pages to get back a summary. Count both directions every time. The formula separates them for exactly that reason and the provider's statement lists them apart too.
The third mistake is estimating in dollars and paying in another currency without thinking about it. Price lists are shown in dollars, while conversion and any VAT are added when you load credit, depending on your status. The order of magnitude doesn't suffer, but the bookkeeping of a registered business does. Note the exchange rate on the day you top up in your accounts and the provider's statement will handle the rest.
11Caching bills repeats at a tenth of the price
The last refinement pays off the most. The major providers bill input tokens they've seen recently at a fraction of the price, up to ten times less on today's price lists. Your templates, fixed instructions and reference documents, sent with every call, fall into that category from the second use. Most recent providers apply it with no action on your part.
In the formula, this means splitting the input into two lines, new input at full price and repeated input at the cache rate. On heavy templates or large reference documents, the saving shows up on the statement right away. The full mechanism, conditions and settings included, is covered in paying ten times less for repeats.
12Pricing a big project such as a migration, redesign or catalog
The method scales up too. Take the rewrite of the 200 pages of a site, at 800 words on average. Output comes to 200 × 1,400 tokens = 280,000 tokens. Input, with the briefs and the original texts sent for rewriting, comes to about 400,000 tokens. On the mid-range model that gives (400,000 × 0.75 + 280,000 × 4.50) ÷ 1,000,000 = $1.56. The whole project costs less than two dollars of API.
Add the 50% iteration margin and the high-end model for the 20 strategic pages. The internal quote still stays under five dollars. Present it next to the real cost of the project, which is your time for proofreading and sign-off. That ratio between machine cost and human cost, recalculated on your own figures, is the strongest argument on the whole topic. It gets demonstrated rather than asserted.
13The pocket calculation sheet to copy
- Line 1. Expected output words × 1.7 = output tokens.
- Line 2. Tokens in the brief and attached documents = input tokens (tokenizer or the 3-character rule).
- Line 3. Note the model's input and output prices from today's official price list.
- Line 4. Apply the formula, then multiply by the planned monthly volume.
- Line 5. Add 30 to 50% for iterations, then compare with the real statement the following month.
Five lines in any spreadsheet give you the estimating tool that credit-based platforms never provide. It takes you straight from planned work to planned cost. Afterward you can check it line by line against the provider's statement, which is the whole value of doing the math yourself.
14Tools that do the math for you
Once you understand the manual method, hand it off. Provider dashboards count every call to the token, the official tokenizers price a text before you send it and good BYOK tools show usage as you go. For tracking over time, monitoring your usage continuously reviews the options.
Add the safeguard that makes everything else calm. Setting a safety cap with the provider turns any calculation error into an alert instead of a bill. It's one minute of setup, done once. After that the formula becomes a control check more than a necessity, since the net makes the trapeze act calm. Many users stop recalculating anything after the first quarter, because they know their orders of magnitude, the cap stands guard and the statement confirms.
15What this calculation changes in your decisions
Choosing a model becomes rational. Three cents against eight tenths of a cent is no longer an opinion but a line of arithmetic. You know exactly what demanding quality costs on each type of content and you buy it where it shows, on strategic pages, introductions and brand copy.
Quotes also become more professional. A freelancer who prices their AI share to the cent in their cost base sets margins with full knowledge. An agency that shows its client the detailed calculation gains a transparency that flat-fee competitors simply can't copy, since they don't know their own unit costs. The formula becomes a sales tool as well as an accounting one.
Fears dissolve as well. Half the hesitation around pay-per-use billing comes from not knowing the amount. Thirty seconds of formula replace the unknown with a number, almost always smaller than you imagined and sometimes by two orders of magnitude. In our experience, that's the step that gets people to act, far more reliably than any general argument.
16From calculation to practice
The best exercise is still the real thing. Create a key, if need be by choosing to practice on a free key, generate three real pieces of content and compare the statement with your estimate. The gap will teach you more than ten theoretical articles. The total cost of the experiment is measured in cents and what you learn applies to every provider at once.
OpenTahr adds nothing to that formula. The account is free and the tools work with your key at the provider's cost price. The API cost of each generation stays the one on your price list, with no in-house credit or margin added in between. For the key itself, getting your key, provider by provider gives every route, five minutes each.
17Frequently asked questions
What is the formula for the cost of an API call?
Cost = (input tokens × input price + output tokens × output price) ÷ 1,000,000, with prices published per million tokens on the provider's official price list. That's the exact billing mechanism for text. There are no hidden fees to add on top of it when you work out the API cost of a call.
How do I count my tokens before calling the API?
Use the quick rule of about 3 characters per token in French and 4 in English. Otherwise, the provider's online tokenizer gives the exact count for a given text. Serious BYOK tools also show an estimate before sending. The API statement settles it afterward, down to the token.
Why does output cost more than input?
Generating text takes more computing than reading it, because each token produced requires a full pass through the model. Today's price lists show a ratio of two to six depending on the model. The dedicated article on the input and output gap details the practical consequences.
Do reasoning models change the calculation?
They do. Their internal thinking is billed as output tokens, often without appearing in the answer, which can multiply the cost several times on complex tasks. The formula stays valid and only the output count swells. Keep these models for problems that justify them.
How do I estimate the cost of a whole project?
Break it down into typical calls, price each one with the formula, multiply by the planned volumes and add a 30 to 50% margin for iterations. Then compare with the statement for the first real month. That gap will calibrate all your later estimates better than any simulator. The pocket calculation sheet gives the exercise a structure in five reusable lines.
Transparency note. Prices were recorded on October 16, 2026 from the official price lists cited in the sources. The counting ratios and the multipliers for reasoning and caching are observed orders of magnitude that vary with models and uses. The examples can be recalculated by hand, which is the whole idea. None of the providers named here pays us.
18Sources
- OpenAI, official API price list (tokens, cache, batches)
- Anthropic, official Claude API price list
- DeepSeek, official API price list (peak and off-peak rates)
Want to try these AI models on your own questions, with your own key?
Explore the OpenTahr tools