Best LLM for Coding: The Cost-Quality Table Nobody Publishes
TL;DR: No model wins every coding job. For agentic, multi-file work, developer consensus in July 2026 points to Claude Opus 4.8 and the GPT-5.x-codex line. Claude Sonnet 5 and Gemini 3.1 Pro give near-top quality for less. DeepSeek V4 Pro is the budget pick at $0.44 input per million tokens.
Every ranking page answers "which model" and skips "at what price." We fixed that. This page joins live OpenRouter prices to a dated read on coding quality. Both are verified July 10, 2026, so you can see the cost-quality tradeoff in one table. Google's July 9, 2026 results for "best llm for coding" carry an AI Overview but no cost column, and the top organic result is a Reddit thread. We have not run our own coding suite on these models yet. Every quality claim below is labeled as consensus, vendor claim, or user report.
Best LLM for coding right now: the verdict and the table
The best LLM for coding depends on the job. For agentic, multi-file work, Claude Opus 4.8 and the GPT-5.x-codex line lead on developer consensus (July 2026). For value, Claude Sonnet 5 and Gemini 3.1 Pro. For budget, DeepSeek V4 Pro at $0.44 input per million tokens. No single model wins every task.
The July 9, 2026 AI Overview agrees and says so first. It opens with "depends heavily on your specific task." For complex architecture and multi-file refactoring, that overview and its cited pages name Claude Opus as the developer favorite. For value, Claude Sonnet. For budget or self-hosting, DeepSeek and open-weight models.
Prices below are verified from the OpenRouter snapshot fetched July 10, 2026. The last column is our own calculation: the cost of one heavy agentic session, defined as 1,000,000 input tokens plus 150,000 output tokens, with no prompt caching. That ratio reflects agentic coding, where re-read context and tool output dominate input. No leaderboard publishes this number.
| Model (snapshot version) | Input $/1M | Output $/1M | Context | Heavy session* | Tier |
|---|---|---|---|---|---|
| Claude Opus 4.8 | $5.00 | $25.00 | 1,000,000 | $8.75 | Top |
| GPT-5.6 Terra | $2.50 | $15.00 | 1,050,000 | $4.75 | Top |
| Gemini 3.1 Pro | $2.00 | $12.00 | 1,048,576 | $3.80 | Top |
| GPT-5.2-codex | $1.75 | $14.00 | 400,000 | $3.85 | Top |
| Claude Sonnet 5 | $2.00 | $10.00 | 1,000,000 | $3.50 | Value |
| GPT-5.1-codex | $1.25 | $10.00 | 400,000 | $2.75 | Value |
| Grok 4.5 | $2.00 | $6.00 | 500,000 | $2.90 | Value |
| Kimi K2.7-code | $0.72 | $3.49 | 262,144 | $1.24 | Value |
| Qwen3-Coder-Plus | $0.65 | $3.25 | 1,000,000 | $1.14 | Budget |
| GLM-5.2 | $0.77 | $2.42 | 1,048,576 | $1.13 | Budget |
| DeepSeek V4 Pro | $0.44 | $0.87 | 1,048,576 | $0.57 | Budget |
*Heavy session = 1M input + 150k output tokens, no caching. Prices last verified July 10, 2026 from the OpenRouter models snapshot.
Read the last two columns together. Claude Opus 4.8 costs 15 times more per heavy session than DeepSeek V4 Pro, $8.75 against $0.57. That gap only pays off when a task genuinely needs frontier reasoning. The tier labels come from the dated AI Overview consensus and the practitioner threads below, not from our own tests. Prompt caching changes the math again. Opus 4.8 reads cached input at $0.50 per million, a 90% cut, so a session that reuses a large fixed codebase costs far less than the table's uncached figure. One r/ClaudeAI user who burned 1.15 billion input tokens in May 2026 put it plainly: JSON is a token pig, and choosing the right model is still the biggest lever.
Route by job: agentic work to Opus 4.8 / GPT-5.x-codex (or Sonnet 5 / Gemini 3.1 Pro for value), autocomplete to the small fast tier, budget or self-host to DeepSeek V4 Pro. Tiers reflect July 2026 developer consensus, not our own tests.
SWE-bench and HumanEval: what the scores actually mean
Two benchmarks dominate coding claims, and they measure different things. SWE-bench Verified is 500 human-validated real GitHub issues drawn from the larger 2,294-issue SWE-bench set. A model scores by generating a patch that passes the repository's own test suite. HumanEval is 164 self-contained Python problems from OpenAI's 2021 Codex paper, scored on pass@1. HumanEval is close to saturated now, with top models above 90%, so it no longer separates the leaders. SWE-bench Verified is the harder, more real signal. A third signal, LMArena ELO, ranks models by crowdsourced human preference on live prompts rather than a fixed test set. None of the three replaces a task-specific evaluation on your own repo.
Here is the honest limit. The July 2026 flagships in the table above (Opus 4.8, GPT-5.6, Gemini 3.1 Pro) have no independent third-party SWE-bench Verified score published as of July 10, 2026. Slapping a number on them would be a guess. What exists is a trail of vendor-reported figures for the exact model versions that published them, each a self-reported claim:
| Model as launched | SWE-bench Verified (vendor-reported) | Source and date |
|---|---|---|
| Claude 3.5 Sonnet | 49.0% | Anthropic, October 2024 |
| Gemini 2.5 Pro | about 63.8% | Google, 2025 |
| Claude Sonnet 4 / Opus 4 | about 72 to 73%, single attempt | Anthropic, May 2025 |
| GPT-5 | 74.9% | OpenAI, August 2025 |
Those are launch numbers. Vendors report them with custom agent scaffolds and sometimes best-of-N sampling, so real single-shot performance runs lower. The climb is real but incremental, a few points per release. Treat any coding benchmark as a claim until an independent leaderboard confirms it, the same way you treat a vendor uptime figure. Community monitoring backs the caution. The IsItNerfed project tracked Claude Code's failure rate spiking to 70% on August 30, 2025 before it settled, a swing no static score would ever show.
Cost-quality tradeoff: where the money actually goes
The cost-quality tradeoff is steep and non-linear. A frontier model can cost 10 to 16 times more per token than a strong budget model while scoring only a handful of benchmark points higher. DeepSeek V4 Pro at $0.44 input handles most everyday generation, refactors, and test-writing that developers actually run. For narrow jobs like SQL generation or data analysis notebooks, a mid-tier model usually ties the flagship. The premium buys reliability on the hard 10%, not on the routine 90%.
Practitioners price this directly. One HN startup lead reported that LLMs are worth "about 1.5 excellent junior/mid-level engineers per engineer," which makes paying for several models trivially worth it, and they let engineers pick any model per task. Another HN thread asked the question the leaderboards ignore. It wanted to know how to forecast API costs when a single user action fires dozens of reasoning and tool calls. The answer is the heavy-session column above, run against your real call volume.
Two structural cautions belong here. A single reasoning-heavy call can 20x your output-token bill, because output is priced 4 to 6 times higher than input on almost every model in the table. And the r/automation builders keep repeating a discipline the hype skips: use deterministic code for every task it can handle, and delegate to a model only what code cannot do. The cheapest coding token is the one you never send. That reframes the whole "which model" question. Pick the smallest model that clears your task, then cache aggressively.
Best budget option and best open-source option
The best budget LLM for coding is DeepSeek V4 Pro, at $0.57 per heavy session (verified July 10, 2026). It pairs a near-frontier price with a 1,048,576-token context. If you want to go lower, DeepSeek V4 Flash costs $0.12 per heavy session, and Qwen3-Coder-Next runs $0.23. These handle autocomplete, boilerplate, and routine refactors well below the flagship price.
| Budget / open pick | Input $/1M | Output $/1M | Context | Heavy session* | Weights |
|---|---|---|---|---|---|
| DeepSeek V4 Flash | $0.09 | $0.18 | 1,048,576 | $0.12 | Open |
| Qwen3-Coder-Next | $0.11 | $0.80 | 262,144 | $0.23 | Open |
| Codestral 2508 | $0.30 | $0.90 | 256,000 | $0.44 | Restricted |
| Qwen3-Coder (1M) | $0.22 | $1.80 | 1,048,576 | $0.49 | Open |
| GLM-4.7 | $0.40 | $1.75 | 202,752 | $0.66 | Open |
| Devstral 2512 | $0.40 | $2.00 | 262,144 | $0.70 | Open |
| GPT-5.1-codex-mini | $0.25 | $2.00 | 400,000 | $0.55 | Closed |
*Heavy session = 1M input + 150k output tokens, no caching. Verified July 10, 2026.
The best open-source LLM for coding is task-dependent too. The July 9, 2026 AI Overview names GLM and DeepSeek-Coder as the frontier open picks for strict privacy. DeepSeek, Qwen3-Coder, GLM, and Mistral's Devstral all publish downloadable weights. Licenses differ, so verify commercial terms before you ship; Codestral's weights carry a non-production license. The honest ceiling on local coding is hardware. An AMD team behind Infinity Arcade reported that the best sub-8B models, the largest that fit a typical 16GB laptop, "can barely produce working copies" of simple retro games. Frontier open weights code well; they also need a real GPU, not a laptop.
Agent workflows vs autocomplete: different winners
Agentic coding and inline autocomplete reward opposite traits, so the best LLM for coding splits into two answers. Agents need reasoning, tool use, long context, and reliability across many steps. Autocomplete needs speed, measured in tokens per second, plus low cost at every keystroke. A 200ms latency gap matters more there than three benchmark points.
For agent workflows, the flagships lead. One r/ChatGPTPro developer tracked both tools for four months. He found Claude best "for code reasoning (not generation, reasoning)," saying Sonnet "feels like talking to a senior eng." A counter-report is just as specific. Another user found GPT-5-codex fixed bugs that Opus could not, calling it "a real code generator." Both are true, because these models have different blind spots. That is why one HN builder wired Claude, Codex, and Gemini to debate a change before synthesizing it.
For autocomplete, route to the small fast tier: GPT-5.1-codex-mini, Qwen3-Coder-Next, or Codestral, which was built for fill-in-the-middle. The reliability caveat spans both modes. An r/automation engineer summed up production reality. Their AI agents "need more babysitting than the intern we fired last year," and one silently pulled the wrong data source for two weeks. Guardrails carry more weight than model choice. The established-codebase HN thread leans on pre-commit hooks, type checks, and tests across every language so a model's mistakes get caught before merge. Pick your model, then build the net under it. For the IDE-tooling layer, our forthcoming Cursor vs Copilot comparison covers where these models actually run.
Once you pick a model, the API bill is next. See live numbers on our OpenAI API pricing and Claude API pricing pages, and read how we source this data in the OpenRouter review.
FAQ
Which LLM model is currently the best for code?
No single model wins every job. For complex, multi-file agentic work, developer consensus in the July 9, 2026 search results points to Claude Opus 4.8 and the GPT-5.x-codex line. Claude Sonnet 5 and Gemini 3.1 Pro give near-top quality at lower cost. Match the model to the task, not to a leaderboard rank.
Is a coding-specialized model better than a general model?
Sometimes. GPT-5.2-codex and Qwen3-Coder are tuned for code and tool use, and practitioners report the codex line fixing bugs general Opus missed (r/ChatGPTPro, October 2025). But general flagships like Claude Opus 4.8 still lead on multi-file reasoning. Test both on your own repo before committing.
What is the cheapest LLM that is actually good for coding?
DeepSeek V4 Pro, at $0.44 input and $0.87 output per million tokens (verified July 10, 2026), is the strongest low-cost pick, roughly 10 to 16 times cheaper per token than the top-tier flagships. Qwen3-Coder-Plus and GLM-5.2 sit in the same value band under $1.20 per heavy session.
Can I self-host an LLM for coding?
Yes, with a real GPU. DeepSeek, Qwen3-Coder, GLM, and Mistral Devstral publish downloadable weights. Sub-8B models that fit a 16GB laptop stay weak: an AMD team reported they can barely produce working retro games (Hacker News, October 2025). Frontier open weights need serious hardware.
Do SWE-bench scores predict real-world coding performance?
Partly. SWE-bench Verified measures whether a patch passes a repo test suite on 500 real GitHub issues, which is closer to real work than HumanEval. But vendor scores use custom scaffolds and best-of-N runs, and day-to-day quality drifts. Treat a score as a claim, not a guarantee.
Prices last verified July 10, 2026 from the OpenRouter /api/v1/models snapshot (models-2026-07-10.json), input and output in USD per million tokens. Quality reads draw on the July 9, 2026 Google AI Overview and its cited pages, plus 60 combined threads from r/ClaudeAI, r/ChatGPTPro, r/automation, and Hacker News. Vendor benchmark figures are self-reported and labeled as claims. We have not run our own coding suite on these models yet; dated results will be added with a changelog entry.
Disclosure: we have no affiliate or business ties to Anthropic, OpenAI, Google, DeepSeek, Alibaba, Z.ai, Mistral, or OpenRouter as of publication. If that changes, this paragraph will say so.