How to estimate AI API costs, with a worked example
AI APIs charge per token, not per message. Learn how input and output tokens are priced and estimate your bill with a worked example you can check.
By Hassan Mamoon · · 5 min read
AI chatbots feel free, or cost one flat fee a month. Build AI into an app, a website or an automation and the pricing changes: you pay for each token that goes in and comes out. That makes the bill easy to underestimate, because it depends on things that are not obvious at the start, like how long your prompts are and how much of a conversation is sent again with every message. This guide shows how to estimate it properly before you build.
Prices, plan names and limits change often, so check your provider's pricing page for current figures. Every price in this article is a made-up example, not a quote.
Which kind of AI pricing are you looking at?
| Type | How you pay | Who it is for |
|---|---|---|
| Free plan | Nothing, with usage limits | Anyone trying a chatbot |
| Chat subscription | A flat monthly fee for higher limits and extra features | People who use a chatbot every day |
| Team or business plan | A monthly fee per user | Companies that want shared admin and data controls |
| API | A charge per token used, billed to a developer account | Anyone building AI into an app or automation |
A chat subscription and API access are usually billed separately, so paying for one does not normally give you credit for the other. This guide is about the last row.
How API pricing works
An API call has two parts, and each is priced per million tokens:
- Input tokens are everything you send: your instructions, the user's message, any documents and the earlier messages in the conversation.
- Output tokens are what the model writes back. They usually cost more per token than input tokens.
The cost of one request is:
- Cost per request = (input tokens × input price + output tokens × output price) ÷ 1,000,000
Different models from the same provider can be priced very differently, with the larger models costing a lot more per token than the smaller ones. Picking the right model for the job is often the biggest saving. If tokens are new to you, start with What is a token in AI?.
Estimate your bill in five steps
- Describe one typical request. What goes in (instructions, user message, any documents) and what comes out (a short answer, a long draft)?
- Measure real examples. Paste 5 to 10 real prompts and answers into the Token Counter and average them. This is far more reliable than guessing.
- Add the hidden input. Your standing instructions and any retrieved text count on every request, and so does the earlier conversation if you send it again.
- Multiply by your volume. Work out requests per day, then multiply by 30 for a month.
- Add a safety margin. Real usage is rarely tidy, so budget for more than the estimate, for example 25 to 50% extra, until you have seen a few real bills.
A worked example: a shop's FAQ chatbot
A small online shop adds a chatbot that answers customer questions. Each conversation has 5 questions. The standing instructions are 400 tokens, each customer question is about 100 tokens, and each answer is about 200 tokens. The example prices are $2 per million input tokens and $10 per million output tokens.
The chatbot is sent the earlier messages again each time, so the input grows with every turn:
| Turn | Input tokens | Output tokens |
|---|---|---|
| 1 | 500 | 200 |
| 2 | 800 | 200 |
| 3 | 1,100 | 200 |
| 4 | 1,400 | 200 |
| 5 | 1,700 | 200 |
| Total | 5,500 | 1,000 |
Turn 2 is 400 (instructions) + 300 (the first question and answer) + 100 (the new question) = 800. Each turn adds another 300 tokens of history.
The cost of one conversation:
- Input: 5,500 × $2 ÷ 1,000,000 = $0.011
- Output: 1,000 × $10 ÷ 1,000,000 = $0.010
- Total: $0.021
With 500 conversations a day, that is $10.50 a day and $315 for a 30-day month.
Now see what happens if you forget the conversation history and assume every request is just the instructions plus one question (500 input and 200 output tokens). That gives $0.003 a request, $0.015 a conversation and $225 a month. The real bill is 40% higher than that estimate.
You can check the real figure in the AI Cost Calculator. Enter 1,100 input tokens and 200 output tokens (the averages per request), 2,500 requests a day (500 conversations × 5), and the two example prices. It shows $10.50 per day and $315 per month.
What makes the bill grow
- Long conversations. The longer the chat, the more history is sent on every turn.
- Long answers. Output tokens usually cost more than input tokens.
- Big pasted documents. A large document on every request adds up quickly.
- A bigger model than you need. Many tasks work well on a smaller, cheaper model.
- Retries and loops. An automation that retries on every error, or an AI agent that loops, can use many requests before anyone notices.
- Extras. Images, audio, web search and tool calls may be priced separately.
Keep the bill under control
- Pick the smallest model that does the job. Test a smaller one on 20 real examples before you assume you need the biggest.
- Cap the answer length. Ask for a limit in the prompt, and set a maximum output length in the API settings.
- Trim the history. Send the last few messages plus a short summary instead of the whole conversation.
- Check for caching and batch options. Some providers charge less for repeated input or for work that can wait. Read your provider's pricing page.
- Set a spending limit. Many providers let you set a budget or an alert in the dashboard. Turn it on before you launch.
- Compare your estimate with real usage. Most APIs return the token counts with every response. Log them from day one and check them against your estimate after a week.
Where to go next
Use the Token Counter to measure your own requests, then run the numbers in the AI Cost Calculator. If any of the terms here are new, look them up in the AI Glossary, or see more tools worth trying in 10 free AI tools that save you hours every week.

