Guides

Cheapest LLM for coding agents

A coding agent re-sends its whole history on every step, so its cost behaves very differently from a single API call. This ranks every model on one realistic agent run. Prices verified 2026-10-18.

Assumptions

Change any of these in the calculator: every row below has a link that opens the same scenario for that model.

The short answer

The cheapest model overall is GPT-6 Luna at $0.05 per run; the most expensive is GPT-6 Astra at $5.16, a 100× spread for the same token counts.

What drives the cost

History, not the task. By the last step the prompt is 131,000 tokens, and the run bills 2,160,000 input tokens in total. That is why prompt caching matters so much here: across models with cache pricing it cuts the cost of this run by 68% to 87%.

Long-context tiers. The final steps cross the long-context threshold of Claude Haiku 5.5 (100K), so those requests are billed at the higher rate for the whole prompt.

Step count grows cost faster than linearly. Each extra step re-sends everything before it. Going from 30 to 45 steps:

A model that solves the task in fewer steps, or with fewer retries, can be cheaper per finished task even when its per-token price is higher. Measure steps per solved task on your own repository before switching on price alone.

Full ranking (36 models)

#ModelTierPer run (cached)Per run (no cache)Per month (1,000 runs)
1GPT-6 Luna OpenAIsmall$0.05$0.23$51.55Calculator
2Ministral 3 8B Mistral AIsmall$0.05$0.33$54.45Calculator
3Mistral Small 4 Mistral AIsmall$0.07$0.34$67.95Calculator
4DeepSeek V4.1 Flash DeepSeeksmall$0.09$0.68$87.18Calculator
5GPT-5.6 Luna OpenAIsmall$0.11$0.47$109Calculator
6Claude Haiku 5.5 Anthropicsmall$0.12$0.62$119Calculator
7Codestral Mistral AIsmall$0.13$0.67$127Calculator
8Gemini 3.1 Flash-Lite Googlesmall$0.13$0.59$128Calculator
9Gemini 3.5 Flash-Lite Googlesmall$0.17$0.72$175Calculator
10Gemini 2.5 Flash Googlesmall$0.17$0.72$175Calculator
11Mistral Large 4 Mistral AI sale priceflagship$0.29$1.53$293Calculator
12Gemini 3.8 Flash Google price changes 2027-01-01mid$0.36$1.73$362Calculator
13Gemini 3.6 Flash Google price changes 2027-01-01mid$0.36$1.73$362Calculator
14DeepSeek V4 Pro DeepSeekflagship$0.38$2.97$380Calculator
15GPT-5.4 mini OpenAIsmall$0.38$1.76$385Calculator
16Claude Haiku 4.5 Anthropicsmall$0.52$2.31$516Calculator
17Grok Build 0.1 xAIsmall$0.60$2.22$596Calculator
18Grok 4.20 (Reasoning) xAIreasoning$0.64$2.77$644Calculator
19Grok 4.3 xAImid$0.64$2.77$644Calculator
20Mistral Medium 3.5 Mistral AImid$0.72$3.47$725Calculator
21Gemini 4 Argon Google price changes 2026-12-01flagship$0.76$4.62$763Calculator
22Claude Sonnet 5.5 Anthropicmid$0.83$4.62$828Calculator
23GPT-6.1 Sol OpenAImid$0.83$4.62$828Calculator
24Gemini 3.1 Pro (Preview) Googleflagship$1.03$4.68$1,026Calculator
25Claude Sonnet 5 Anthropicmid$1.03$4.62$1,031Calculator
26GPT-6 Sol OpenAImid$1.03$4.62$1,031Calculator
27GPT-5.6 Terra OpenAImid$1.09$4.68$1,091Calculator
28Grok 4.7 xAIflagship$1.45$4.50$1,455Calculator
29Claude Sonnet 4.6 Anthropicmid$1.55$6.93$1,547Calculator
30Claude Opus 5.5 Anthropicflagship$1.66$9.24$1,656Calculator
31GPT-5.6 Sol OpenAIflagship$2.06$9.24$2,062Calculator
32GPT-5.5 OpenAIflagship$2.56$11.70$2,565Calculator
33Claude Opus 5 Anthropicflagship$2.58$11.55$2,578Calculator
34Claude Opus 4.8 Anthropicflagship$2.58$11.55$2,578Calculator
35Claude Fable 5.1 Anthropicflagship$3.63$23.10$3,633Calculator
36GPT-6 Astra OpenAIflagship$5.16$23.10$5,155Calculator

USD, standard list prices. Tags mark announced price changes and temporary sale prices.

Price is not quality

This page ranks by cost only. Models differ in accuracy, instruction following, tool use, latency, rate limits and data policies, and those differences often matter more than the price gap. Shortlist two or three models from the table, run them on a sample of your real inputs, and compare cost per successful result.

Related comparisons

More guides

FAQ

What is the cheapest model for a coding agent?

On this workload (30 steps, caching on) it is GPT-6 Luna at $0.05 per run. The cheapest flagship model is Mistral Large 4 at $0.29. Cheapest is not the same as best: compare success rate on your own tasks.

How much does prompt caching save on an agent run?

Between 68% and 87% on this run, depending on the model's cached-input price.

Do thinking tokens count?

Yes. Providers bill thinking or reasoning tokens as output tokens. This guide assumes 1,000 output tokens per step including thinking; raise it in the calculator if your agent thinks longer.