AI Agents and Coding Assistants
Estimating Usage Costs Before You Build on a Paid AI Service
Estimate a monthly AI bill with simple arithmetic: tokens per request, request volume, hidden extras, scenarios and spending caps.
Key takeaways
- Cost per request is input tokens times the input rate, plus output tokens times the output rate.
- Measure token counts on realistic samples, since long instructions, documents and chat history often dominate the input.
- Estimate low, expected and high scenarios, and include retries, testing and your heaviest users.
- Set hard limits in your own app as well as with the provider, and compare the estimate with real usage soon after launch.
To estimate the bill for an AI feature, work out what one typical request costs, multiply by how many requests you expect in a month, then add room for the things that make real usage larger than your sketch. The arithmetic is simple enough for a spreadsheet. The hard part is being honest about the inputs.
Doing this before you build can change the design. A feature that looks cheap in a demonstration with one user may be costly with thousands, and a small decision about what you send with each request can matter more than which provider you choose.
What you are billed for
Many AI text services charge by the token, a small chunk of text. In English, a token averages somewhat less than a word, though the ratio varies by model, language and content. Code, numbers and some languages can use noticeably more tokens for the same meaning. The basics are in what tokens are.
Input tokens are everything you send. Output tokens are what the model writes back, and they often carry a higher rate. Some models also generate internal reasoning text before answering, which may be billed as output even if you never see it.
Images, audio and video are usually measured differently. Other services charge per seat, per call or by computing time. How AI pricing models work compares these. Rates and units change often, so take current figures from the provider's own pricing page.
The cost of one request
Here is a worked example with invented rates, chosen to make the math easy. Assume input costs 2 dollars per million tokens and output costs 8 dollars per million tokens. Your feature answers a customer question using some reference text.
| Part of the request | Tokens (example) |
|---|---|
| Standing instructions | 500 |
| Customer question | 300 |
| Reference passages | 1,200 |
| Total input | 2,000 |
| Reply (output) | 400 |
input cost = 2,000 × 2 ÷ 1,000,000 = 0.0040 dollars
output cost = 400 × 8 ÷ 1,000,000 = 0.0032 dollars
per request = 0.0040 + 0.0032 = 0.0072 dollars That is less than one cent. Notice that the reference passages are the largest input item, and that the short reply costs nearly as much as all the input because of its higher rate.
To get your own token counts, run twenty or so realistic samples through the service and read the usage figures it returns. Include long cases, because averages from short test messages mislead.
Multiply by realistic volume
Volume is usually users × requests per user per day × days. Suppose you expect 200 active users, each making 5 requests a day for 30 days.
requests per month = 200 × 5 × 30 = 30,000
monthly cost = 30,000 × 0.0072 = 216 dollars
cost per user = 216 ÷ 200 = 1.08 dollars If one action in your app triggers several model calls, count calls, not button presses. A feature that classifies a message, searches, drafts a reply and then checks the draft may make three or four calls for one visible result. Agents that loop through many steps can make far more, and the number differs from run to run.
Conversations grow with every turn
Chat features have a catch. To keep context, apps commonly resend earlier messages with each new one, so input grows as the conversation goes on.
Say the standing instructions are 500 tokens, each user message is 100 and each reply is 300. The first turn sends 600 input tokens. Each later turn adds the previous message and reply, 400 more tokens. By the tenth turn the input is 600 + 9 × 400 = 4,200 tokens.
total input over 10 turns = 10 × (600 + 4,200) ÷ 2 = 24,000 tokens
total output = 10 × 300 = 3,000 tokens
cost = 24,000 × 2 ÷ 1,000,000 + 3,000 × 8 ÷ 1,000,000
= 0.048 + 0.024 = 0.072 dollars Ten separate first turns would cost 10 × 0.0036 = 0.036 dollars. The ten-turn conversation costs twice as much, and the gap widens as chats lengthen. Trimming old turns, summarizing them or starting a fresh thread limits the growth.
Build three scenarios
A single number suggests more certainty than you have. Estimate a quiet month, an expected month and a heavy one. The heavy case below assumes more users, more requests each and longer content: 4,000 input tokens and 600 output tokens, which comes to 0.0128 dollars per request.
| Scenario | Users × requests a day | Requests a month | Cost per request | Monthly total |
|---|---|---|---|---|
| Quiet | 100 × 3 | 9,000 | 0.0072 | 64.80 dollars |
| Expected | 200 × 5 | 30,000 | 0.0072 | 216 dollars |
| Heavy | 500 × 10 | 150,000 | 0.0128 | 1,920 dollars |
Hypothetical example: the numbers are made up to show the method, not a quote or an average.
The heavy month is nearly nine times the expected one, because several inputs rose together. Ask whether you could pay it, and what your app would do if you could not.
Add what the sketch leaves out
Real bills include items that a first calculation misses.
- Retries and rejected outputs. If 10 percent of the 30,000 expected requests are repeated, you pay for 33,000, about 237.60 dollars.
- Development and testing. Rerunning a test set after every prompt change uses tokens too.
- Heavy users. One person making 50 requests a day costs 50 × 30 × 0.0072 = 10.80 dollars a month, ten times the average above.
- Abuse. An open form can be hit by automated scripts.
- Supporting services. Document search, storage, logging and hosting have their own charges.
- People. Time spent reviewing outputs may exceed the model bill.
The larger picture is covered in the hidden costs of an AI project.
Compare designs before choosing one
The estimate is most useful when you run it for two or three ways of building the same feature. Say your product manual is 30,000 tokens long, and one design sends the whole manual with every question while another sends only 1,200 tokens of relevant passages.
whole manual: input = 500 + 300 + 30,000 = 30,800 tokens
cost per request = 30,800 × 2 ÷ 1,000,000 + 0.0032 = 0.0648 dollars
monthly at 30,000 requests = 1,944 dollars
selected passages: 30,000 × 0.0072 = 216 dollars Sending everything costs nine times as much in this example. Selecting passages needs extra work to build and can miss the right section, so compare answer quality too.
A second design uses two models. Suppose a cheaper one charges a tenth of the rates, 0.00072 dollars per request, and handles 70 percent of questions, with the rest going to the stronger one.
average per request = 0.7 × 0.00072 + 0.3 × 0.0072 = 0.002664 dollars
monthly at 30,000 requests = 79.92 dollars This leaves out the cost of deciding which questions go where, and the cost of sending a hard question to the wrong model. Both belong in your test.
Ways to bring the number down
Start with the largest line in your estimate.
Send less. Shorten repeated instructions, include only the passages that matter and cap reply length. Check that quality holds after each cut.
Match the model to the job. Simple sorting or extraction may work well on a cheaper one, with harder cases passed to a stronger one. See small and large models.
Avoid paying twice. Store answers to identical requests where that is appropriate and does not expose one user's data to another. Some providers discount repeated input that is cached, or work submitted in delayed batches. The terms vary.
Skip the model when ordinary code will do. Totaling numbers or checking a date format needs no AI.
Running an open-weight model yourself swaps per-token fees for hardware, power and maintenance, a trade explored in local or cloud AI.
Set limits and check against reality
An estimate is a forecast, so give it guardrails. Put a per-user daily limit and a length limit in your own code. Set the provider's budget alerts and spending caps where offered, and learn whether a cap stops requests or only sends a notice. The reasoning behind firm stops is discussed in spending limits and stop buttons.
Log the token counts for each request along with the feature that made it. After the first week, compare actual averages with your assumptions and update the spreadsheet. If you charge customers, check that your price covers an expensive user as well as an average one.
Turn the estimate into a decision
A monthly total means little until you set it beside what the feature is worth. For a paid product, subtract the model cost per user from what that user pays, then subtract hosting, support and payment fees. For an internal tool, compare the total, including review time, with the time or errors it is expected to save.
Then decide in advance what would change your plan. You might say that the feature ships if the heavy scenario stays affordable, that it gets a daily allowance per user if it does not, and that it waits if even the expected case loses money. Writing these thresholds down before launch makes them easier to honor.
Keep the spreadsheet short enough that someone else can check it: one row for each model call, with columns for input tokens, output tokens, rates, calls per month and total. Mark which numbers were measured and which were guessed.
Common questions
Is a free tier enough to estimate from?
It helps you collect token counts. Its limits, models and terms may differ from paid use, so base the estimate on the paid rates you expect to pay.
How much safety margin should I add?
There is no standard figure. The less you know about user behavior, the wider the gap between your expected and heavy cases should be. A small trial with real users narrows it faster than more guessing.
What if prices change after I build?
Keep rates in one place in your spreadsheet and your monitoring, so you can recalculate in minutes. Avoid designs that only make sense at one provider's present price, and know what you would switch to.