AI Agent Cost per Task: How to Measure the Real Number
Most teams undercount AI agent costs by tracking only model spend per run. The useful metric is cost per completed accepted task after retries, tool fees, review time, and failed runs.
If you want the real answer to ai agent cost per task, use this formula:
Cost per completed accepted task = total agent operating cost over a period ÷ number of tasks completed and accepted in that period.
That is different from cost per run. A run can be cheap and still fail. A task only counts when it finishes and passes your acceptance rule. Your total cost should include model tokens, tool fees, retries, failed attempts, and human review. If a task takes 1.4 average attempts to get accepted, your accepted-task cost is higher than your single-run cost.
This distinction matters for planning, pricing, and ROI. It also helps you compare hosted APIs against local models, where electricity and hardware matter. If you need baseline provider pricing, see our OpenClaw API cost comparison and AI agents for small business guide.
What is AI agent cost per completed accepted task?
It is the full cost to get one task done to an acceptable standard.
That means you do not divide by all started tasks. You divide by tasks that finished and were accepted by your system, team, or customer.
A clean definition:
Accepted task cost = (model token cost + tool/API fees + compute or hosting + human review labor + failure and retry overhead) ÷ accepted tasks
This is the best operating metric because it matches business output.
Examples of accepted tasks:
- A support reply sent without agent error
- A lead enrichment job that passes validation
- A document extraction that meets quality thresholds
- A code change that passes review and gets merged
If you only track model spend per request, you miss the cost of bad runs. That leads to false savings.
Why is cost per accepted task higher than cost per run?
Because production agents waste money in small ways.
Common reasons:
- The first answer is wrong, so the agent retries
- A tool call fails and the workflow starts over
- A human checks outputs before release
- Some tasks are abandoned after spending tokens
- Some tasks take longer because of prompt growth and memory
A cheap run can still be an expensive accepted outcome.
Here is the difference:
| Metric | What it includes | Good for | Main risk |
|---|---|---|---|
| Cost per run | Token and tool cost for one attempt | Debugging and prompt tuning | Hides failures and review work |
| Cost per started task | Costs across all attempts divided by started tasks | Capacity planning | Still ignores acceptance quality |
| Cost per completed accepted task | All costs divided by accepted outputs | Budgeting, pricing, ROI | Requires better tracking |
If you are still setting budgets only at the request level, add spending controls. Our OpenClaw spending limits guide covers practical guardrails.
How do you calculate AI agent cost per task step by step?
Use one reporting period. A day or week works well.
Then calculate:
- Model token cost
- Tool and external API cost
- Infrastructure cost
- Human review and correction cost
- Total accepted tasks
Then divide total cost by accepted tasks.
1. Model token cost
Use official price pages.
OpenAI API pricing lists standard GPT-5.6 Sol at $5 per 1M input tokens and $30 per 1M output tokens, Terra at $2.50 input and $15 output, and Luna at $1 input and $6 output. That same page says Batch is 50% off.
Google lists Gemini 3.5 Flash paid at $1.50 per 1M input tokens and $9 per 1M output tokens, with Batch at $0.75 input and $4.50 output.
Formula:
Token cost = (input tokens ÷ 1,000,000 × input price) + (output tokens ÷ 1,000,000 × output price)
2. Tool and external API cost
Examples:
- Web search API calls
- OCR charges
- CRM enrichment
- Database query fees
- Browser automation services
Use your actual vendor bill. If one accepted task used three paid tool calls, include all three.
3. Infrastructure cost
For hosted APIs, this may be near zero beyond your app hosting.
For local inference, include electricity and hardware allocation. The US EIA says the 2025 US average electricity price was 17.30 cents per kWh for residential and 13.41 cents per kWh for commercial customers. NVIDIA lists the RTX 5090 at 575W TGP and a 1000W required system power. That is enough to estimate an upper-bound system power budget for local runs. For more on local economics, see our local LLM electricity cost break-even guide and local estimator.
4. Human review and correction cost
This is often the hidden line item.
Formula:
Review cost per period = total review minutes × loaded hourly labor rate ÷ 60
If reviewers reject 20% of tasks and spend extra time fixing them, include that too.
5. Divide by accepted tasks
Only count tasks that met your acceptance rule.
What is a worked example for a simple hosted agent?
Assumption-based example:
A support triage agent uses GPT-5.6 Luna. Each attempt uses 8,000 input tokens and 1,200 output tokens. It also makes one paid tool call at $0.002 per attempt. Acceptance rate per attempt is 80%, so average attempts per accepted task are 1.25. Human review takes 20 seconds per accepted task at a loaded labor rate of $30 per hour.
First, token cost per attempt using Luna pricing:
- Input: 8,000 ÷ 1,000,000 × $1 = $0.008
- Output: 1,200 ÷ 1,000,000 × $6 = $0.0072
- Total model cost per attempt: $0.0152
Add tool fee:
- Per attempt total: $0.0172
Convert to accepted-task basis:
- Attempts per accepted task: 1.25
- Attempt-related cost per accepted task: $0.0172 × 1.25 = $0.0215
Now review labor:
- 20 seconds = 0.333 minutes
- $30 per hour = $0.50 per minute
- Review cost per accepted task: 0.333 × $0.50 = about $0.1665
Final accepted-task cost:
- $0.0215 + $0.1665 = about $0.188
So the run looks cheap at 1.72 cents per attempt, but the accepted outcome costs 18.8 cents. Review dominates.
What is a worked example for a more complex multi-step agent?
Assumption-based example:
A document agent extracts fields, validates them, and writes to a system. It uses Gemini 3.5 Flash paid for the main generation. Each attempt uses 30,000 input tokens and 4,000 output tokens. It also uses:
- OCR tool fee: $0.015 per attempt
- Validation API fee: $0.003 per attempt
- Acceptance rate per attempt: 60%
- Human review time: 90 seconds per accepted task
- Labor rate: $36 per hour
Token cost per attempt using Gemini 3.5 Flash paid pricing:
- Input: 30,000 ÷ 1,000,000 × $1.50 = $0.045
- Output: 4,000 ÷ 1,000,000 × $9 = $0.036
- Model total: $0.081
Add tools:
- OCR + validation = $0.018
- Total attempt cost = $0.099
Accepted-task conversion:
- Attempts per accepted task = 1 ÷ 0.60 = 1.667
- Attempt-related accepted cost = $0.099 × 1.667 = about $0.165
Review cost:
- 90 seconds = 1.5 minutes
- $36 per hour = $0.60 per minute
- Review cost = 1.5 × $0.60 = $0.90
Final accepted-task cost:
- $0.165 + $0.90 = about $1.065
Again, the run cost is under 10 cents, but the accepted-task cost is about $1.07.
That is why cheap runs and accepted outcomes must be reported separately.
How should you account for failures, retries, and fallbacks?
Count all spending, even when output is discarded.
A practical method:
- Log every attempt ID
- Log task ID and final task outcome
- Attach all model and tool usage to the task
- Mark the final state as accepted, rejected, or abandoned
Then calculate:
Failure overhead = total cost of non-accepted attempts ÷ accepted tasks
You can also break out fallback paths. Example:
- Primary model handles 85% of accepted tasks
- A larger fallback model handles the hard 15%
- Human escalation handles the final edge cases
That gives you a weighted accepted-task cost. This is much better than quoting one average request price.
Can local models reduce AI agent cost per task?
Sometimes, yes. But only if quality and operations hold up.
For local inference, you should include:
- Electricity
- Hardware depreciation or monthly allocation
- Ops time
- Lower or higher acceptance rates
- Latency impact on reviewer time
Electricity is the easy part. If a full local system averaged 1.0 kW during inference, one hour of runtime would cost about $0.173 residential or $0.134 commercial using the 2025 US average electricity rates from EIA. NVIDIA’s RTX 5090 page lists 575W TGP and a 1000W required system power, which helps frame realistic system-level assumptions.
But electricity alone is not your answer. If a local model reduces acceptance rate and creates more human cleanup, your accepted-task cost can rise even when token cost falls. For model sizing and hardware fit, see best local LLM by RAM, best local LLM by GPU, and quantization in plain English.
What should you track in a dashboard?
Track these fields per task:
- Task ID
- Workflow type
- Start and end time
- Accepted or rejected status
- Number of attempts
- Input tokens
- Output tokens
- Tool calls and fees
- Human review minutes
- Escalation flag
- Final accepted-task cost
Then publish at least four metrics:
- Cost per attempt
- Acceptance rate
- Attempts per accepted task
- Cost per completed accepted task
This lets you see whether savings came from cheaper models or from fewer retries and less review.
How do you avoid underpricing your agent service?
Never quote from token price alone.
Use this checklist:
- Define acceptance clearly
- Estimate retries from pilot data
- Include tool fees
- Include review time
- Include a failure buffer
- Recalculate monthly
If you sell AI automation to clients, price from accepted outputs. If you run internal automation, report savings against accepted outputs too. Our AI automation cost guide and OpenClaw costs guide can help build that model.
What should you read next?
Need a second pair of hands on a broken OpenClaw setup?
Gateway, auth, secure access, VPS, and model troubleshooting.
See Rescue Session →