An agent run has no fixed price: its cost is the number of model calls times their size, plus any tool charges. Estimating it before the run starts is simple arithmetic once you know the shape of the run: how many steps, how many tool calls per step, and roughly how many tokens each call carries. Anthropic’s tool-use pricing shows the pieces to count: input tokens, output tokens, the tool definitions themselves, and the tool result blocks that come back. Write the estimate down before the run, compare it with the actual cost after, and use the gap to make the next estimate better.
What you need
- The expected shape of the run: steps, tool calls per step, rough token sizes
- The per-model prices for the model the agent uses
- One earlier run with a known actual cost, to calibrate against
Step 1: Count the expected calls and their sizes
List the steps the run will take and the tool calls in each, with a rough token count per call: prompt, tool definitions, and expected tool results. A run with an unknown shape cannot be estimated; break it down first.
Step 2: Multiply by the model prices and write the estimate down
Turn the token counts into a cost using the model’s per-token prices, and write the total next to the run plan. An estimate nobody writes down cannot be checked later.
Step 3: Compare the estimate with the actual cost after the run
After the run, read the actual token usage from the log and compare it with the estimate. If the actual cost is far higher, find the step that overshot and fix the estimate for next time.
Worked example: synthetic cost estimate
The table below is a synthetic example. It shows the expected result of estimating first; no run was billed.
| Step | Estimated tokens | Actual tokens |
|---|---|---|
| Plan the task | 1,000 | 900 |
| Three tool calls | 3,000 | 3,200 |
| Write the answer | 1,500 | 1,400 |
| Estimate within 10% of actual | Yes | Pass |
Expected result (UNTESTED). the estimate lands within 10% of the actual token count, with the overshooting step named for next time. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- An estimate is only as good as the run shape it assumes; a run that loops blows past any estimate.
- Token counts vary with the input, so a single estimate fits one input, not all of them.
- Tool charges outside the model, such as paid searches, must be counted separately.
- Estimating costs a few minutes; for a one-off short task, a rough cap may be enough.
