VynarisEarly betaGet your API key

What an AI coding agent costs per task: 6 models, real math

A reproducible cost model for what an AI coding agent costs per task across 6 models. Prices verified 2026-07-13, every assumption editable.

The same coding-agent task costs $0.021 on deepseek-v4-flash and $0.85 on Claude Opus 4.8 — a 41x spread on identical work. The reason is not the sticker price per million tokens. It is that a coding agent spends about 20 tokens reading for every 1 token it writes, and it re-reads the same code on every step. Below is the full model, every assumption in a table you can edit, prices verified 2026-07-13 from provider pages.

TL;DR

What we computed, and why

A chat request is one round trip. A coding agent is a loop: it reads an issue, loads files, plans, edits, runs tests, reads the failures, patches, and repeats. Each pass is a separate model call, and each call re-sends the system prompt, the tool schemas, and the code context. That structure is why agent inference costs behave nothing like the per-message math people carry over from chatbots.

We modeled one representative task, a small bug fix or feature, as three phases: plan, edit, verify. The goal is not a single "true" number. It is a transparent skeleton you can re-run with your own token counts. All arithmetic is in a script; nothing here was computed by hand.

The assumptions (edit these)

Every number below is an input you can change. Swap in your own trace and the results move with it.

Assumption              Value           Note
----------------------  --------------  -----------------------------------------------------------------------------------
Stable prefix per call  15,000 tokens   system prompt + tool schemas + loaded code context, re-sent each call unless cached
Model calls per task    8               plan (1) + edit (3) + verify (2), plus 2 for back-and-forth
Fresh input per call    2,000 tokens    new tool results and appended messages, never cacheable
Output per call         838 tokens      reasoning + tool calls + diffs, averaged
Total input per task    136,000 tokens  8 x (15,000 + 2,000)
Total output per task   6,704 tokens    8 x 838
Input : output ratio    20.3 : 1        this is the whole story

The 20.3:1 ratio is the load-bearing assumption. Chat apps sit near 3:1 or lower. Agents invert the economics because the context window fills with code the model must re-read to stay coherent, and most of that context is input tokens, not output tokens.

Results: cost per task, six models

Prices verified 2026-07-13 from the OpenAI, Anthropic, and DeepSeek pricing pages (sources below). Standard first-party rates, no caching applied yet, no tokenizer adjustment yet.

Model                                                              Input $/1M  Output $/1M  Cost/task  Cost/1,000 tasks
-----------------------------------------------------------------  ----------  -----------  ---------  ----------------
[Claude Opus 4.8](https://vynaris.com/models#claude-opus-4-8)      $5.00       $25.00       $0.8476    $847.60
[gpt-5.6-terra](https://vynaris.com/models#gpt-5-6-terra)          $2.50       $15.00       $0.4406    $440.56
[Claude Sonnet 5](https://vynaris.com/models#claude-sonnet-5)      $2.00       $10.00       $0.3390    $339.04
[gpt-5.3-codex](https://vynaris.com/models#gpt-5-3-codex)          $1.75       $14.00       $0.3319    $331.86
[Claude Haiku 4.5](https://vynaris.com/models#claude-haiku-4-5)    $1.00       $5.00        $0.1695    $169.52
[deepseek-v4-flash](https://vynaris.com/models#deepseek-v4-flash)  $0.14       $0.28        $0.0209    $20.92
Cost per 1,000 coding-agent tasks across 6 models
Cost per 1,000 coding-agent tasks. 136k input + 6.7k output tokens per task, no caching. Prices verified 2026-07-13.

Notice how the ranking tracks input price almost exactly. gpt-5.3-codex has a high $14 output price but a low $1.75 input price, and it lands cheaper per task than Claude Sonnet 5, whose output is $10. In an output-heavy chat workload the order would flip. Agents reward cheap input.

If you are sizing a real budget, this is the moment to plug your own numbers in: run the per-task math in the calculator with your call count and context size before you commit to a model.

The tokenizer tax nobody prints on the pricing page

Per-token price is not per-task price, because tokenizers differ. Anthropic states that Claude Opus 4.7 and later, plus Claude Sonnet 5, use a newer tokenizer that produces about 30% more tokens for the same text. Claude Haiku 4.5 and earlier models use the previous tokenizer.

That means an apples-to-apples comparison (same code, same English prompt) bills the new-tokenizer models for more tokens. Applying the stated +30% to the token counts on those two models:

Model            Base cost/1,000  Tokenizer-adjusted /1,000  Change
---------------  ---------------  -------------------------  ------
Claude Opus 4.8  $847.60          $1,101.88                  +30%
Claude Sonnet 5  $339.04          $440.75                    +30%

The adjustment reorders the field. On raw price lists, Claude Sonnet 5 ($339.04) looks cheaper than gpt-5.6-terra ($440.56). On the same task, adjusted for the tokenizer, Sonnet 5 ($440.75) is level with gpt-5.6-terra and more expensive than gpt-5.3-codex ($331.86). The exact multiplier depends on your content, so treat 30% as the provider's stated average, not a guarantee. But do not compare token prices across tokenizer families as if a token means the same thing on both.

What prompt caching does to the bill

The stable prefix (system prompt, tool schemas, loaded files) is identical across all 8 calls in a task. Without caching, you pay full input price for it 8 times. With prompt caching, you pay to write it once and then read it cheaply.

Anthropic's multipliers are uniform: a 5-minute cache write costs 1.25x the base input price, and a cache hit reads at 0.1x. Applied to our task, the effective input drops from 136,000 tokens to 45,250 token-equivalents — 67% less input, before touching output.

Model              No-cache /1,000  Cached /1,000  Saving
-----------------  ---------------  -------------  ------
Claude Opus 4.8    $847.60          $393.85        54%
Claude Sonnet 5    $339.04          $157.54        54%
Claude Haiku 4.5   $169.52          $78.77         54%
deepseek-v4-flash  $20.92           $6.51          69%

deepseek-v4-flash saves more because its cache-hit price ($0.0028/1M) is 2% of its cache-miss price, a steeper discount than Anthropic's 10%. OpenAI also offers cached input, but its pricing page did not itemize a per-model cache-read rate in our 2026-07-13 capture, so we left gpt-5.6-terra and gpt-5.3-codex out of this table rather than guess. Caching applies to them too; we will add exact numbers when the page publishes them.

Caching only pays off when calls land inside the cache window and share a prefix. An agent loop on one task is close to the ideal case: the calls are seconds apart and the prefix is stable. This is the single highest-impact change most agent builders have not made.

What it means for routing

Right-sizing an agent is not one decision. The plan step and the verify step have different quality bars.

An OpenAI-compatible gateway makes this testable without rewriting provider glue: point one base URL at a router, send verify-step calls to a cheap model, keep planning on the frontier, and compare the invoice. That is the model routing case in one sentence.

Where this model is wrong

Honesty first, because a cost model that hides its failure modes is marketing.

When does the expensive model win outright? When one bad plan cascades. On a task where a flawed plan burns all 8 calls and then a human's afternoon, the $0.85 Opus 4.8 run is cheaper than three failed $0.02 runs plus the cleanup. Frontier pricing buys fewer retries, and on the planning step that is often the right trade.

FAQ

How much does an AI coding agent cost per task? On this model (8 calls, ~136k input and ~6.7k output tokens), a single task ranges from $0.021 (deepseek-v4-flash) to $0.85 (Claude Opus 4.8) at standard rates verified 2026-07-13. Prompt caching lowers both ends by 54% to 69%.

Why is input so much more expensive than output for agents? Because the agent re-reads its context on every step. At a 20.3:1 input-to-output ratio, input tokens set the bill. Chat apps sit closer to 3:1, which is why chat cost intuition misleads agent builders.

Does prompt caching really cut agent costs in half? On the Anthropic models here it cut 54%, and on deepseek-v4-flash 69%, because the stable prefix is re-read cheaply instead of re-billed at full input price. The calls must fall inside the cache window and share a prefix, which an agent loop on one task does naturally.

Is the cheapest model per token the cheapest per task? Usually, for read-heavy agent work, because input price drives the total. The exceptions are retry rate (a weaker model that fails verification more often) and the tokenizer a model uses, which changes how many tokens the same text becomes.

Which model should I route agent steps to? Keep planning on a stronger model, and route mechanical steps (verification, simple edits, formatting) to a cheaper one like Claude Haiku 4.5 or deepseek-v4-flash. Sort candidates by input price, and turn on caching before you change models at all.

Sources

Prices change. We re-verify every figure in this post monthly and stamp updates. Numbers here are current as of 2026-07-13.

Want the same math on your own workload? Vynaris is an OpenAI-compatible gateway that routes each request to the cheapest right-sized model and shows the per-request cost. One base URL swap. Get an API key at vynaris.com.