How to estimate monthly AI agent API cost from a pilot

Use actual API charges from a multi-step agent pilot to estimate monthly spend and cost per accepted task. Includes three matched charges and a calculator.

Two mechanical tally counters. One shows three check marks and the other shows one orange check mark.

To estimate an AI agent’s monthly API cost, add the settled charges for every attempt, then scale by how many tasks arrive each month. Divide the resulting spend by the number of tasks that pass your acceptance check to get the cost per accepted result. Keep those two numbers together. A workflow that stops earlier can spend less overall while costing more for each usable result.

In an Ofox test on December 3, 2026, two model calls produced one accepted order draft. A third call returned HTTP 200 but failed our output check. The charge for the accepted draft was $0.00009755. The rejected call added $0.00004700, bringing API spend for the two-case pilot to $0.00014455. Below, we use those measured amounts to build two illustrative monthly budgets.

What the three requests actually cost

We sent three POST /v1/chat/completions requests on the same key with model z-ai/glm-5.3-flash and max_tokens: 256. The inputs were synthetic and the program produced text only. We matched the model, time and exact input and output token counts to three rows in Ofox Activity. Times are UTC+8 and all charges are in USD.

Task and stepTimeInput / output tokensActual response and checkMatched charge
A · Extract SKU and quantity13:50:4545 / 95BX-27,6 matched the required pair$0.00005425
A · Format the validated pair13:50:5342 / 74HOLD 6 x BX-27 matched the draft template$0.00004330
B · Extract with an older output format13:50:5950 / 79KT-91:3 failed the required comma format$0.00004700

Task A passed after both steps. To repeat the fixture, ask the model to extract a SKU and quantity from “Please hold six units of SKU BX-27.” Require exactly BX-27,6. Pass that result to a second call and ask it to return exactly the template HOLD <quantity> x <SKU>. Check it against HOLD 6 x BX-27. For the negative control, supply “Please hold three units of SKU KT-91.” Ask for the old SKU:quantity format while the validator still requires KT-91,3. The model followed that old format as instructed. The application rejected the output and stopped before the formatting step. All three calls returned HTTP 200. No retry or inventory write ran.

This gives us one accepted path and one deliberately rejected path. The pilot illustrates how to account for charges. Use a representative batch to measure how often your own workflow follows each path.

Calculate monthly API spend and cost per accepted task

For a first forecast, group your measured jobs by path. Multiply the average API charge of each path by the number of incoming tasks you expect to take that path, then add the results. Track the expected number of accepted tasks separately. If you have a budget based on required deliveries instead of incoming volume, estimate arrivals as required accepted tasks divided by the expected acceptance rate. Round arrivals up for a whole-task estimate.

Here is the observed cost of each path applied to 12,000 projected arrivals per month. The success percentages are assumptions for the calculation. They are independent of the two-case pilot.

Illustrative monthly mixAccepted / rejected tasksProjected API spendAPI cost per accepted task
90% accepted and 10% rejected at extraction10,800 / 1,200$1.10994$0.00010277
70% accepted and 30% rejected at extraction8,400 / 3,600$0.98862$0.00011769

In the second forecast, more tasks stop after one call, so the total API bill falls. Cost per accepted task rises because fewer tasks pass. The projections apply the pilot’s observed charges to hypothetical workloads. They exclude infrastructure, human review and external tools. Any paid actions or additional model calls in your workflow belong in their corresponding cost buckets.

This calculator uses Python’s standard library. Change the task counts and replace the two amounts with measured path averages. It prints projected API spend first, then the cost per accepted result. When zero tasks pass, that second metric is undefined.

from decimal import Decimal

accepted_charge = Decimal("0.00009755")
rejected_charge = Decimal("0.00004700")

def estimate(accepted, rejected):
    total = accepted * accepted_charge + rejected * rejected_charge
    per_accepted = total / accepted if accepted else None
    return f"{total:.5f}", f"{per_accepted:.8f}" if per_accepted is not None else None

print(estimate(10_800, 1_200))  # ('1.10994', '0.00010277')
print(estimate(8_400, 3_600))   # ('0.98862', '0.00011769')

Replace the fixture with your agent’s own data

  1. Define acceptance before you run. Give the same business task a stable ID across calls and retries. A task passes when the final deliverable satisfies a check your application can apply, such as conserved totals or an expected record shape. For a task that changes external state, also verify the result from the system that performs the change.
  2. Log calls as they happen. Keep the task ID, step, attempt, request reference, model, time and output of the acceptance check. Keep a timeout in the log until you know its billing status. Your client giving up and the provider finishing processing can happen at different times. Check the API retry guidance and the 429 troubleshooting guide before you turn on automatic retries.
  3. Match the real charges. Use a shared request reference when both sides expose one. If you must match by timestamp, model and tokens, require a unique match, as we did for this serial run. Add each separately settled attempt once, even when a retry shares the task ID. Keep ambiguous or pending charges open and reconcile them when the ledger settles. The key and model reconciliation guide walks through the Activity comparison.
  4. Forecast complete paths. Run a sample that includes different input sizes and foreseeable failures. Measure how often you accept on the first attempt, recover after a paid retry, or stop without a deliverable. For a recovered task, include every settled call made on that task, then count the accepted deliverable once. Use the observed average charge per path and low, expected and high volume forecasts. After launch, compare predicted spend and acceptance with the first complete billing window.

For a fuller operating budget, add monthly fixed costs and variable items, such as tool calls, storage or paid review. Keep their source and scope visible in your worksheet. If you need a spending cap while collecting the sample, use a separate staging key budget and verify which scope can block the requests.

Frequently Asked Questions

Can I use token estimates before I have settled API charges?
Yes. Make an initial estimate from model-specific usage and current billing units. Label it as a forecast, then replace it with matched charges from a representative pilot.
How do I handle an agent that produces two deliverables in a single run?
Choose the counting unit before the pilot. If both outputs form one customer job, count one accepted job. If you sell them individually, count accepted deliverables and assign the shared run cost once.