How to estimate AI API costs from input and output tokens

Compare hosted model costs in TinyToolbox using rough text estimates or exact token counts, then reconcile the estimate with provider billing.

Open the tool

A short prompt can lead to an expensive workload if the response is long or the request runs thousands of times. A model can also have different rates for input and output, so the combined token count does not tell you the full cost. Estimate the two counts separately and decide how many requests the estimate represents.

TinyToolbox AI Token and Pricing Calculator compares supported hosted model offerings using input tokens, output tokens, and a request count. You can paste text for a rough estimate or enter exact counts from your own measurements. The displayed figures are estimates based on the rates shown in the tool. Check the provider and model ID before comparing them with an actual invoice.

Define what one request contains

Start with a representative request. Its input can include the user prompt, instructions supplied by your application, earlier messages, and material attached as text. A small prompt may travel with a larger body of context. Estimate the full input your integration will actually send if the provider meters those tokens.

Then pick an expected output length for the same kind of request. For a workload that varies widely, make separate scenarios rather than assuming every answer is the same size. A question that calls for a single label can produce a much shorter answer than one that asks for a detailed explanation. Compare a short and a long case so you can see the cost of the difference.

Finally, choose what period or job the request count covers. If you expect 50 requests per day over 20 working days, an estimate of 1,000 requests represents that period. Include repeated calls if they are part of your workload. A feature that makes two billed model requests for one user action needs an estimate for both calls, even if the user only sees one response.

Use a rough text estimate or exact counts

Open AI Token and Pricing Calculator. Paste representative input and output text into the corresponding fields if you only need an approximate count. The browser counts the UTF-8 bytes and rounds the result of dividing by four up to a whole token. It marks nonzero estimates with an approximation sign. That rule gives a planning figure and does not use the model’s tokenizer.

Tokenization can differ for code, punctuation, different writing systems, and strings with many distinct characters. The same text can also tokenize differently across models. A rough estimate is useful early in a comparison, when you may not have access to measured usage. Once you have actual counts for your integration, enter them under Exact input tokens per request and Exact output tokens per request. Each exact field overrides the estimate for that side. An explicit zero also overrides pasted text.

You can combine the two kinds of input. For example, if your system knows the exact input length but has yet to measure typical responses, use exact input tokens and paste a representative output. Label the assumptions before sharing the estimate. When the output has been measured, replace that estimate rather than changing both figures and losing track of what caused the difference.

Read the pricing rows

Set Requests to the number of times the representative request will run. The table updates as you edit. Its rates are in US dollars per one million tokens. Each row calculates the input cost and output cost at its own rates, adds those costs, and multiplies by the request count. The rows also identify the provider and model, with links to the API documentation and pricing pages.

For an arithmetic example, suppose a hypothetical plan charges $0.20 per million input tokens and $0.80 per million output tokens. A request uses 2,000 input tokens and 500 output tokens. Its input costs $0.0004, and its output also costs $0.0004. The combined cost is $0.0008 per request. At 1,000 requests, the estimated total is $0.80. The example rates illustrate the arithmetic and are independent of the provider rates listed in the tool.

The table can show several decimal places for small totals. Look at an aggregate workload if you want a result that is easier to compare. An estimate of less than a cent per request can still matter at a high request count. Multiplying the number of requests doubles the modeled cost when the counts and rates stay the same.

Compare models and rate conditions carefully

A model name and a provider’s model ID can differ. Read the row that matches the service endpoint and model ID you actually intend to use. Two providers can serve models with similar names while applying different rates or conditions. Use the provider links in the table to verify the current rates and availability when you plan a real deployment. Groq model catalog · Together AI pricing · DeepSeek pricing

The Use DeepSeek off-peak rates setting switches the rows that have an off-peak rate in the calculator. It does not check the time of your requests or establish that they qualify. Turn it on only for a scenario where you intend to apply those rates, and verify the current conditions with the provider. For a workload split between standard and discounted conditions, estimate each portion separately and add the resulting costs.

The comparison applies one input and one output rate per row. Actual billing can distinguish cached input or other usage categories, and a provider can change its rates. Check the official terms and compare a real measured call before treating a planning estimate as a forecast. The calculator does not make API requests or ask you to enter API credentials.

Reconcile the estimate with measured usage

Run a small representative sample through your own application and record the provider’s reported input and output counts. Replace the guessed counts with those measurements. If prompts vary greatly, estimate several classes separately. For example, you can account for 900 short requests and 100 long ones with two runs rather than charging the same token count to all 1,000.

When an invoice differs, start by checking the dates, model IDs, and actual call count. Then compare the token categories and rates. If the amount matches your estimate for a single request but the batch is wrong, the issue may be the number of calls or how the workload was grouped. Keep the rate date, token counts, request count, and pricing assumptions with your estimate so you can repeat the comparison when a model or workload changes.

Estimate a workload with short and long requests

Imagine a service that drafts a short label for most incoming support messages and produces a longer explanation for cases a reviewer escalates. You expect 900 label requests and 100 explanation requests in a month. A test of the full integration reports about 800 input tokens and 100 output tokens for a label. The explanation uses about 2,400 input tokens and 800 output tokens. These counts describe what the API meters, including application instructions and attached excerpts.

Enter 800 exact input tokens, 100 exact output tokens, and 900 requests in TinyToolbox. Record the total for the provider and model row you are comparing. Then enter 2,400 input tokens, 800 output tokens, and 100 requests. Record that total and add it to the first. Repeat both runs for any other row you are considering. This makes it easier to see whether a rate difference matters mostly for short responses, long responses, or both.

Using the fictional rates of $0.20 and $0.80 per million from the earlier example, the 900 label requests use 720,000 input tokens and 90,000 output tokens. That gives $0.144 in input cost and $0.072 in output cost, for $0.216 total. The 100 explanations use 240,000 input tokens and 80,000 output tokens. Those cost $0.048 and $0.064 respectively, bringing that group to $0.112. Add the two groups for an estimated $0.328. Keep the intermediate totals available so a colleague can reproduce the estimate even if the interface rounds the displayed value.

You could enter weighted averages of 960 input tokens and 170 output tokens for all 1,000 requests and get the same total at these fixed rates. Keeping the groups separate makes it easier to reason about a change. If reviewers escalate 200 cases in a month with the same 1,000 total requests, you can set the label group to 800 and the explanation group to 200 without recomputing both average lengths. Use separate estimates when the groups use different models or when you want to see how each contributes to the total.

Count model calls that happen behind one action

Consider a document workflow where the application uses one model call to choose sections and a second call to draft an answer from them. Both calls can carry their own instructions, context, and output. Put them into separate calculator runs if their lengths or models differ. For 250 documents, a stage that always runs gets 250 requests. A follow-up that only runs for 40 documents gets 40. This works even when the application has a single button for processing a document.

Check whether the second call includes text from the first call. A generated outline can count as output when the first call produces it and as input when the next call receives it. Keep the stage boundaries clear in your notes. If instead the app only stores a short identifier and sends different context to the second stage, use that request’s actual usage counts.

Retries can also affect totals. Compare the number of completed operations with the provider’s reported calls. A retry that reached the model may have usage even if the application ultimately discarded the response. Use the billed usage records to determine which attempts count. If a test reveals 20 additional billed calls for 1,000 completed jobs, add that retry group using its observed token lengths. Keep it separate if retries carry a different prompt or produce shorter responses.

Test which assumption drives the estimate

Change one number at a time and record the difference. First, leave input tokens and request count constant and double the output count. For the example explanation, increasing output from 800 to 1,600 tokens adds 800 output tokens per request. Across 100 requests that is 80,000 additional output tokens, worth $0.064 at the fictional output rate. You can check that number by subtracting the original explanation total from the revised total in the matching pricing scenario.

Next, restore the output count and change the input length to reflect a longer attachment. Compare a request that includes two paragraphs with one that includes excerpts from several pages. If you have yet to measure the exact counts, use representative test text and mark the results as approximate. Replace that assumption after you record the provider’s usage. When only one field is uncertain, keep the other fields fixed so the difference remains attributable to that uncertainty.

Before sending a comparison to someone else, include the workload period, the model and provider IDs, the pricing date, the counts used, and how you obtained them. A line such as “100 explanations per month, 2,400 measured input tokens and 800 estimated output tokens each” gives a reader enough information to challenge a specific assumption. Keep any discount, cache, or rate-tier assumptions with the estimate. That record makes it easier to compare a later invoice or update the forecast without starting over.