AI Model Cost Per Task (CPT) Guide 2026: Real-World Agentic API Spend vs. Token Pricing
Quick answer
Headline token rates ($/1M) are misleading for AI agents. This 2026 breakdown calculates Cost Per Task (CPT) across three standard developer task profiles for Claude, GPT, Gemini, and DeepSeek.
Updated 24 October 2026: the Gemini 3.6 Flash costs in this guide use $1.50 input and $7.50 output per million tokens, which Google’s Gemini API pricing page (checked 24 October 2026) lists from 1 January 2027; through 31 December 2026 the listed prices are $0.75 and $3.75, half as much. The same page and Google’s models page call Gemini 3.6 Flash the previous-generation Flash model and Gemini 3.8 Flash the most intelligent Flash model, at the same listed prices. Google Cloud’s page for Gemini 3.6 Flash (in its Vertex AI documentation, headed Gemini Enterprise Agent Platform) says it will be retired there on 19 November 2026 and adds that models may remain accessible through the Gemini API afterwards; the Gemini API deprecations page lists no shutdown date for gemini-3.6-flash. GPT-5.6 Luna is priced here from OpenAI’s own model page ($0.20 input / $1.20 output per million tokens, checked 24 October 2026); Google’s Gemini 3.6 Flash model card lists different figures for it, which this guide does not use. The guide’s Task D (cached monitor) column was removed on 24 October 2026 because its stated token count and its published figures did not agree with each other. Second correction pass, 24 October 2026: every non-Google price in the matrix and the code sample now follows the vendor’s own page, checked that day, and every matrix figure was recomputed from those prices as input tokens x input rate plus output tokens x output rate, with no caching (the rates are listed under the table). Changes from the originally published figures: Claude Sonnet 5 is listed by Anthropic at $2.00 / $10.00 per million tokens (was $3.00 / $15.00; Google’s model card shows $3.00 / $15.00 with $2.00 / $10.00 as a temporary discount, while Anthropic’s pricing page lists $2.00 / $10.00 with no end date); GPT-5.6 Terra is listed by OpenAI at $2.00 / $12.00 (was $3.00 / $15.00); Claude Opus 4.8 at $5.00 / $25.00 and GPT-5.5 Pro at $30.00 / $180.00; and DeepSeek now lists deepseek-flash (served by DeepSeek-V4.1-Flash-1017; the older name deepseek-v4-flash is retired and billed at the Flash price) and deepseek-v4-pro, with peak-hour prices of $0.30 / $1.20 and $1.32 / $3.96 used in the matrix (off-peak prices are half as much). Newer models exist: Anthropic’s models overview lists Claude Haiku 5.5, Claude Sonnet 5.5, Claude Opus 5.5 and Claude Fable 5.1 as its current models, and OpenAI’s models page lists GPT-6 Astra, GPT-6.1 Sol and GPT-6 Luna as its flagship models; this guide prices the older models in the matrix and none of the newer ones.
When evaluating large language models for developer tools, terminal agents, and automated subagent workflows, headline input/output token rates ($/1M tokens) are fundamentally misleading. A model charging $5.00 per million output tokens can easily end up costing double a model charging $7.50 if it requires twice as many conversational reasoning tokens or fails git diff validation, triggering expensive retry loops.
To establish true economic benchmarks for 2026 engineering stacks, this guide compares frontier and mid-tier models. It introduces the Cost Per Task (CPT) metric, calculates exact API spend across three standard developer task profiles, analyzes hidden token inflation drivers, and provides token optimization middleware for Node.js and Python.
1. What is Cost Per Task (CPT)?
Headline pricing measures token volume, but AI agents consume tokens in multi-turn feedback loops. Cost Per Task (CPT) calculates the real financial cost required to take a task from initial prompt to clean, verified execution:
CPT = (Input Tokens × Input Rate) + (Output Tokens × Output Rate) + (Cache Miss Penalty) + (Retry Loops × Fail Cost)
2. Cost Per Task (CPT) Matrix Across 3 Developer Benchmark Tasks
Estimated cost per task is shown below for three standard 2026 developer task profiles:
- Task A: Light Bug Fix & Log Triage (10,000 Input tokens, 500 Output tokens, single turn).
- Task B: Multi-File Feature Edit / Git Diff (40,000 Input tokens, 1,800 Output tokens, 3 tool calls).
- Task C: Autonomous Repo Refactor / SWE-bench Task (180,000 Input tokens, 6,500 Output tokens, 12 tool iterations).
| Model Name | Model Tier | Task A (Fix & Triage) | Task B (Feature Diff) | Task C (SWE Refactor) |
|---|---|---|---|---|
| DeepSeek-V4.1 Flash (peak-hour prices) | Ultra-Budget | $0.0036 | $0.0142 | $0.0618 |
| Claude Haiku 4.5 | Speed / Budget | $0.0125 | $0.0490 | $0.2125 |
| GPT-5.6 Luna | Speed / High-Volume | $0.0026 | $0.0102 | $0.0438 |
| Gemini 3.6 Flash (priced at $1.50 / $7.50, its list price from 1 January 2027) | Speed / Precision | $0.0188 | $0.0735 | $0.3188 |
| DeepSeek-V4 Pro (peak-hour prices) | Mid-Tier MoE | $0.0152 | $0.0599 | $0.2633 |
| GPT-5.6 Terra | Balanced Workhorse | $0.0260 | $0.1016 | $0.4380 |
| Claude Sonnet 5 | Agentic Workhorse | $0.0250 | $0.0980 | $0.4250 |
| Claude Opus 4.8 | Flagship Reasoning | $0.0625 | $0.2450 | $1.0625 |
| GPT-5.5 Pro | Flagship Reasoning | $0.3900 | $1.5240 | $6.5700 |
Rates used, in US dollars per million tokens (input / output), from each vendor’s own pages checked on 24 October 2026: DeepSeek-V4.1 Flash $0.30 / $1.20 and DeepSeek-V4 Pro $1.32 / $3.96 at DeepSeek’s peak-hour prices (its off-peak prices are half as much); Claude Haiku 4.5 $1.00 / $5.00; GPT-5.6 Luna $0.20 / $1.20; Gemini 3.6 Flash $1.50 / $7.50 (its list price from 1 January 2027; $0.75 / $3.75 through 31 December 2026); GPT-5.6 Terra $2.00 / $12.00; Claude Sonnet 5 $2.00 / $10.00; Claude Opus 4.8 $5.00 / $25.00; GPT-5.5 Pro $30.00 / $180.00. Each figure is the task’s input tokens x the input rate plus its output tokens x the output rate, with no caching, rounded to four decimals.
3. What Wastes Token Spend in Production Agents?
Four primary drivers of hidden API cost inflation across autonomous agents:
A. Spurious Diff Rewrites
Imprecise models often output an entire 400-line file when only 3 lines needed editing. A model costing $5.00/1M output that rewrites 400 lines (4,000 tokens) costs $0.020 per edit, whereas a model like Gemini 3.6 Flash that returns a concise 20-line diff (200 tokens) costs just $0.0015 per edit at its $7.50/1M output list price from 1 January 2027, a 13x savings, or $0.00075 per edit at $3.75/1M output through 31 December 2026, about a 27x savings (Google Gemini API pricing page, checked 24 October 2026).
B. Uncached System Instructions & Tool Schemas
Sending a 5,000-token repository schema on every tool call in a 20-turn agent conversation adds 100,000 unneeded input tokens ($0.15 to $0.50 per task). Enabling prompt caching in Claude Sonnet 5, Gemini 3.6 Flash, or Claude Haiku 4.5 cuts the price of cached input tokens by up to 90%: Google lists Gemini 3.6 Flash cached input at $0.075 per million tokens against $0.75 standard through 31 December 2026 ($0.15 against $1.50 from 1 January 2027), and Anthropic charges cache reads at 0.1x the base input price for Claude Haiku 4.5 and Claude Sonnet 5 (cache writes cost more: 1.25x for the 5-minute cache). Checked 24 October 2026.
C. Tool Call Retry Loops
If an agent generates invalid JSON or malformed parameters, the harness must resubmit the entire context window with error logs. Models with higher tool failure rates incur a higher overall CPT due to retry overhead.
D. Context Accumulation Inflation
In multi-turn conversations exceeding 15 turns, unfiltered history accumulation increases input token usage with every turn. Implementing turn truncation or summarizing conversation history using budget models (like Claude Haiku 4.5 or DeepSeek-V4.1 Flash) limits context growth.
4. Cost Optimization Strategy & Two-Tier Routing
To achieve the lowest average CPT across team engineering workloads, implement a Two-Tier Dynamic Model Router:
“`
┌──────────────────────────────────┐
│ Incoming Agent Developer Task │
└───────────────┬──────────────────┘
│
▼
┌────────────────────────────────────┐
│ Task Risk & Complexity Classifier │
└─────────┬────────────────┬─────────┘
│ │
Low/Medium Risk│ │High Risk / Complex
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Gemini 3.6 Flash │ │ Claude Sonnet 5 │
│ DeepSeek-V4 Pro │ │ GPT-5.6 Terra │
│ (CPT: $0.06-$0.32)│ │ (CPT: $0.10-$0.44)│
└──────────────────┘ └──────────────────┘
“`
The cost ranges in the diagram are the lowest and highest Task B and Task C figures from the matrix above for the two models named in each box, at the prices used in the matrix as checked on 24 October 2026: DeepSeek-V4 Pro at its peak-hour prices and Gemini 3.6 Flash at its $1.50 / $7.50 list price from 1 January 2027.
5. Node.js CPT Calculation Middleware
Developers can track real-time CPT metrics across API calls using the following TypeScript middleware wrapper:
interface TokenPricing {
inputPerM: number;
outputPerM: number;
cacheReadPerM?: number;
}
// Vendor list prices per 1M tokens, checked 24 October 2026
const MODEL_PRICING: Record = {
'gemini-3.6-flash': { inputPerM: 1.50, outputPerM: 7.50 }, // Google list price from 1 January 2027; $0.75 / $3.75 through 31 December 2026 (checked 24 October 2026)
'claude-sonnet-5': { inputPerM: 2.00, outputPerM: 10.00, cacheReadPerM: 0.20 },
'deepseek-v4-pro': { inputPerM: 1.32, outputPerM: 3.96 }, // DeepSeek peak-hour price; off-peak is half
'claude-haiku-4-5': { inputPerM: 1.00, outputPerM: 5.00, cacheReadPerM: 0.10 }
};
export function calculateTaskCost(
model: string,
inputTokens: number,
outputTokens: number,
cachedTokens = 0
): number {
const rates = MODEL_PRICING[model] || { inputPerM: 3.00, outputPerM: 15.00 };
const standardInput = Math.max(0, inputTokens - cachedTokens);
const inputCost = (standardInput / 1_000_000) * rates.inputPerM;
const cacheCost = (cachedTokens / 1_000_000) * (rates.cacheReadPerM ?? (rates.inputPerM * 0.1));
const outputCost = (outputTokens / 1_000_000) * rates.outputPerM;
return parseFloat((inputCost + cacheCost + outputCost).toFixed(6));
}
6. Frequently Asked Questions (FAQ)
Why is headline token pricing ($/1M) not enough to estimate monthly API bills?
Headline rates ignore output verbosity and tool-call failure retries. A model with cheaper headline output rates can consume significantly more output tokens to solve the exact same problem.
Which model has the lowest Cost Per Task (CPT) in this guide’s matrix?
GPT-5.6 Luna has the lowest figure in this guide’s matrix for all three tasks ($0.0026 for Task A, $0.0102 for Task B, the multi-file feature edit, and $0.0438 for Task C), ahead of DeepSeek-V4.1 Flash at its peak-hour prices ($0.0036, $0.0142 and $0.0618). At DeepSeek’s off-peak prices, which are half the peak prices, DeepSeek-V4.1 Flash’s figures are lower than Luna’s (for example $0.0071 for Task B). For high-precision coding and diff accuracy, this guide’s matrix gives Gemini 3.6 Flash $0.0735 per edit at its $1.50 / $7.50 list price from 1 January 2027 ($0.0368 at the $0.75 / $3.75 prices through 31 December 2026). Google now labels it previous-generation, so check Gemini 3.8 Flash, listed at the same prices, before choosing it for a new build.
How much does prompt caching save on CPT?
Prompt caching cuts the price of cached input tokens by up to 90% on long system instructions or codebase schemas (see section 3B for the vendor prices).
7. Final Recommendation
- For Primary Agentic Coding & Git Diffs: Gemini 3.6 Flash was this guide’s pick ($0.0735 CPT per feature edit at $1.50 / $7.50, $0.0368 at $0.75 / $3.75 through 31 December 2026). Google now labels it previous-generation and Google Cloud lists its retirement for 19 November 2026, so evaluate Gemini 3.8 Flash (same listed prices; Google calls it its most intelligent Flash model) first for new builds; this guide has no CPT figures for it.
- For High-Volume Log Filtering & Micro-Tasks: Use Claude Haiku 4.5 ($0.049 CPT), GPT-5.6 Luna ($0.0102 CPT) or DeepSeek-V4.1 Flash ($0.0142 CPT at peak-hour prices).
- For Complex Enterprise Refactoring: Escalate to Claude Sonnet 5 ($0.098 CPT) or GPT-5.6 Terra ($0.1016 CPT).