Home / Guides / Cheapest AI for coding: review, SQL and 50-step agent runs

Cheapest AI for coding: review, SQL and 50-step agent runs

Coding work ranges from a quick SQL query to a long agent run, and the cheapest model changes with the job. This article ranks models for each coding task using real per-task costs.

By Piotr Olszewski · Oct 23, 2026 · prices as of Nov 22, 2026

The cheapest model for short coding tasks in my measurements is GLM 5.3 Flash: 0.32¢ for a code review and 0.03¢ for a SQL query. It is also the cheapest of the six models for a modeled 50-step agent run, at 2.0¢. List price per token does not predict the bill, because reasoning tokens are billed as output and some cheap models generate a lot of them.

The six models

These are the coding-capable models in this comparison, with list prices per 1M tokens from the official pricing pages:

ModelInputOutputCached inputReasoning mode
GLM 5.3 Flash$0.005$0.20$0.005always
DeepSeek V4.1 Flash$0.17$0.66$0.006default
Qwen3.8 Flash$0.15$0.47$0.016none
Claude Haiku 5.5$0.10$0.50$0.01default
GPT-6.1 Sol$2.00$10.00$0.10always
Claude Sonnet 5.5$2.00$10.00$0.10always

List price is only the starting point. I ran the short tasks with default settings through OpenRouter, with output capped at 16,000 tokens. Reasoning tokens count as output, so a model that thinks for a long time pays for every one of them. See the methodology for details.

Short coding tasks

Code review

The review task sends CPython's textwrap.py (497 lines). The median across all 335 models is 1.3¢.

ModelCost per reviewReasoning tokensNotes
GLM 5.3 Flash0.32¢15,998hit the 16,000-token cap
Claude Haiku 5.50.66¢8,532measured
Qwen3.8 Flash0.83¢16,000hit the 16,000-token cap
DeepSeek V4.1 Flash1.1¢16,000hit the 16,000-token cap
GPT-6.1 Sol4.9¢2,843measured
Claude Sonnet 5.58.0¢3,476measured

GLM 5.3 Flash is cheapest, but it spent almost its whole budget on reasoning and produced 2 output tokens. Qwen3.8 Flash and DeepSeek V4.1 Flash hit the cap too, and both produced no output at all. Their low cost reflects runs that ran out of budget, not complete reviews.

Claude Haiku 5.5 produced 3,258 output tokens for 0.66¢, with 8,532 reasoning tokens, well under the cap. For review work it is the more trustworthy cheap option. See the code review task page for the full ranking.

SQL query

The median across all models is 0.22¢.

ModelCost per queryReasoning tokens
GLM 5.3 Flash0.03¢1,123
Claude Haiku 5.50.08¢810
Qwen3.8 Flash0.13¢2,225
DeepSeek V4.1 Flash0.14¢1,723
GPT-6.1 Sol0.48¢147
Claude Sonnet 5.51.1¢218

The spread is small in absolute terms. Even Sonnet 5.5 costs 1.1¢ per query. The cheap models win on cost, but the gap matters mostly at high volume. More in the SQL task page.

Multi-step agents

The agent scenario is modeled, not measured, so treat it as an estimate. It starts with an 8,000-token system prompt, runs 50 steps, adds 1,500 tokens of context per step, and produces 300 visible output tokens per step.

ModelCost per 50-step runReasoning tokens
GLM 5.3 Flash2.0¢28,800
Claude Haiku 5.56.6¢29,550
Qwen3.8 Flash9.2¢80,850
DeepSeek V4.1 Flash9.4¢87,450
GPT-6.1 Sol53¢0
Claude Sonnet 5.584¢10,900

The median across all 335 models is 47¢. GLM 5.3 Flash leads, and Haiku 5.5 and the two other Flash models sit well below the median. GPT-6.1 Sol and Sonnet 5.5 are above it. See the agent task page.

Why a cheap model can cost more

An agent run re-sends a growing context on every step, so input volume is large: over 2 million input tokens for most models here. That is why cached input prices matter. For GLM 5.3 Flash the cached rate equals the input rate, $0.005, and the input price is the lowest in the group. Its modeled cost without caching is $0.02.

Reasoning volume is the other lever:

  • DeepSeek V4.1 Flash lists $0.66 output but generated 87,450 reasoning tokens in the agent run, all billed as output.
  • Qwen3.8 Flash lists $0.47 output and generated 80,850. Its reasoning mode is "none" on paper, yet it produced 16,000 reasoning tokens in the code review run. The label does not tell the whole story.
  • Claude Haiku 5.5 uses reasoning mode "default", so the model decides how much to think. It used 29,550 reasoning tokens in the agent run.
  • GPT-6.1 Sol has a high token price, $2.00 input and $10.00 output, but 0 reasoning tokens in the agent scenario. Its bill comes from price, not thinking volume.

So a low list price can be eaten by volume, and a high list price can come with less of it. Check how much a model thinks, not only what it charges. You can test your own token counts in the calculator.

The cheapest choices

Short coding tasks: GLM 5.3 Flash, at 0.32¢ per review and 0.03¢ per query. The caveat is that its review run hit the reasoning cap, so verify output quality. If you want a review that finished with room to spare, Claude Haiku 5.5 at 0.66¢ is the safer pick.

Multi-step agents: GLM 5.3 Flash again, at 2.0¢ per modeled 50-step run. Claude Haiku 5.5 is next at 6.6¢. Sonnet 5.5 at 84¢ is worth it only for steps where quality matters.

FAQ

Is the cheapest model good enough for real code review?

Not necessarily. GLM 5.3 Flash was cheapest in my review run, but it hit the 16,000-token cap and produced 2 output tokens. Test it on your own code before relying on it.

Why does a model with a low token price cost more on long runs?

Reasoning tokens are billed as output. A model with a low output price can still cost more if it generates tens of thousands of them. DeepSeek V4.1 Flash produced 87,450 reasoning tokens in the 50-step scenario.

Should I use Sonnet 5.5 for coding agents?

Only where the extra quality matters. In the modeled 50-step run it cost 84¢, against 2.0¢ for GLM 5.3 Flash and 6.6¢ for Claude Haiku 5.5. Using a cheap model for routine steps keeps the bill down.

Sources