Token spend tells you what you paid. Cost per successful task tells you whether the model, prompt, and workflow were worth it. If you only watch raw tokens, you’ll miss retries, dead-end branches, and the long tail of agent loops that quietly drain budget.
Why cost per task beats raw token totals
Most teams start with a simple question: how much did the model cost this month? That’s useful, but it’s not the metric that maps to product value. A coding agent that burns 4 million tokens to land one merged fix is very different from one that uses 400,000 tokens to ship ten accepted changes. The first number is a usage stat. The second is a unit cost.
Cost per successful task is basically:
cost per task = total AI cost / successful tasks
That sounds obvious, but it changes how you optimize. You stop asking, “Can I shave 10% off tokens?” and start asking, “Which workflow produces the cheapest accepted result?” That usually points to better prompts, smaller models for easy work, tighter context, and fewer retries, not just lower list prices.
This is also why a blended metric matters. A model with a cheap input rate can still be expensive if it produces verbose outputs, takes multiple turns, or fails often. The opposite can be true too: a pricier model can win on cost per task if it finishes in one shot. For a broader market view, the AI Cost Index is a useful benchmark, but your own task-level data is the number that actually decides whether a workflow is worth keeping.
The math: one task can be cheap or weirdly expensive
Let’s use real prices and do the arithmetic. Suppose a coding task uses 120,000 input tokens and 30,000 output tokens on gpt-4o. The price is $2.5 per 1M input tokens and $10 per 1M output tokens.
Input cost = 120,000 / 1,000,000 * 2.5 = $0.30
Output cost = 30,000 / 1,000,000 * 10 = $0.30
Total cost = $0.60
If that task produced one successful merged change, your cost per successful task is $0.60. If the first attempt failed and the agent repeated the same work, the cost doubles to $1.20 for the same outcome.
Now compare that with a smaller model on the same token counts. gpt-4o-mini is $0.15 per 1M input tokens and $0.6 per 1M output tokens.
Input cost = 120,000 / 1,000,000 * 0.15 = $0.018
Output cost = 30,000 / 1,000,000 * 0.6 = $0.018
Total cost = $0.036
Same token shape, very different bill. But that still isn’t the whole story. If the smaller model needs three retries, your effective cost becomes $0.108 for one success, and the bigger model may actually be cheaper per successful task if it finishes cleanly. That’s the point: task success changes the equation.
What to measure alongside task success
To make cost per successful task useful, you need a few supporting metrics. Raw token count alone is too blunt. Here’s the minimum set worth tracking for any coding agent or API workflow:
- Success rate, how often the task completes without manual rescue.
- Retry count, how many times the same objective gets re-run.
- Latency, because slow tasks block developer time even if the token bill is low.
- Model mix, since one expensive model in the loop can dominate the whole run.
- Use-case, because bug fixes, refactors, and feature scaffolding have very different token shapes.
That’s also where a breakdown by provider and model matters. A task that looks cheap at the platform level may be expensive in one specific use-case, especially if the workflow is doing a lot of back-and-forth. If you want to compare model economics directly, the live catalog at live model prices is the right place to sanity-check the current market.
A small comparison of common model economics
Here’s a compact view of the prices you can actually use in your own calculations. Remember, these are per 1M tokens, and input and output are priced separately.
| Model | Input | Output | What it implies |
|---|---|---|---|
| gpt-4o-mini | $0.15 | $0.6 | Very cheap for high-volume, short tasks |
| deepseek-chat | $0.28 | $0.42 | Low-cost option when outputs stay compact |
| gemini-2.5-flash | $0.3 | $2.5 | Cheap input, but output can matter fast |
| gpt-4o | $2.5 | $10 | More expensive, but often a better one-shot candidate |
| claude-sonnet-4-5 | $3 | $15 | Mid-to-high cost, worth it when success rate is high |
| claude-opus-4-1 | $15 | $75 | Use when task quality beats raw token efficiency |
The table is not a ranking by itself. It’s a reminder that output-heavy workflows get expensive fast, and that the “cheapest” model on paper may not be the cheapest per finished task. If you care about value, the value-for-money view is the better lens than list price alone.
How to turn task cost into a useful engineering metric
Start by defining what a “successful task” means in your stack. For a coding agent, that might be a merged PR, a passing test run, or a completed refactor that doesn’t need manual cleanup. For an API product, it might be a user-visible completion, a valid structured response, or a downstream job that finishes without retry.
Then group spend by task type. Don’t mix “quick fix in one file” with “multi-file feature implementation.” Those are different workloads, and if you average them together, you’ll hide the real cost centers. A good dashboard will let you break spend down by provider, model, platform, and use-case, so you can see whether the expensive part is the model itself or the workflow around it.
One practical trick: compute a cost band, not just an average. If 80% of tasks land under $0.10 and the last 20% explode to $2.00 because the agent loops, that tail is where you’ll save real money. Usually the fix is not “switch everything to a cheaper model,” it’s “route simple tasks to a cheaper model and cap retries on the hard ones.”
If you want a broader context on how the market is moving, the State of AI page gives a good top-level snapshot of what’s happening across the ecosystem. But for budgeting, task cost is still the metric that matters most.
How to track this
MyTokenTracker is built for exactly this kind of measurement. Run npx mytokentracker to read the usage logs your coding agents already keep locally, then print a 30-day cost table at API prices. No account is needed for that, and usage data never leaves your machine.
If you want a synced dashboard, create a free account and run npx mytokentracker init. It asks for the API token, uploads history, and then syncs every 30 minutes. It works with Claude Code, Codex, GitHub Copilot CLI, Antigravity, OpenCode, Amp, Qwen Code, and more. Only daily totals per agent and model are uploaded, never prompts, code, or file names.
It also captures cost, input/output/cache/reasoning tokens, latency, and success, which is exactly what you need to calculate cost per successful task instead of just staring at a token total. For setup details, see the install page.
FAQ
Is cost per successful task better than cost per token?
Yes, if your goal is to understand productivity. Cost per token is a pricing metric. Cost per successful task is an outcome metric. The first tells you what the model charges. The second tells you what it took to get something useful done.
Do I need exact success labels to use this metric?
No. Start with a simple definition that matches your workflow, like merged PR, accepted answer, or completed run without manual intervention. Even a rough success label is better than ignoring retries and failed attempts entirely.
What usually lowers cost per successful task the most?
Usually it’s a mix of smaller prompts, fewer retries, tighter task scope, and routing easy work to cheaper models. In practice, the biggest win is often reducing failed attempts, because retries multiply both token use and latency.
If you want to see your own numbers instead of guessing, run MyTokenTracker and measure the tasks you actually ship.