Best Open Source LLM for Coding: 48x Cost Gap in Our Test

Last Updated: 2026-07-17 10:08:56

Short answer: GLM-5.2 is the strongest open source LLM for coding right now — in extended use its output quality lands near Claude Sonnet-tier, and it's the model we'd hand the hardest problems. It's also slow and token-hungry, so for fast API coding agents pick Kimi K2.7 Code, for lowest cost DeepSeek V4 Flash, and for your own 24GB GPU Qwen3.6-27B.

That's the conclusion from feeding the same two coding tasks to five open source flagships, with Claude Opus 4.8 as a closed-source reference. All of them produced correct code. What separated them was how many tokens they burned to get there, and that difference was as large as 48x in cost.

One note on wording: almost all of these are technically open-weight models: the weights are free, the training data isn't. We say "open source" because that's the term people search. The distinction matters only for one FAQ answer below.

How we tested

Two tasks, same prompt for every model, sent on July 17, 2026 with default settings:

  • Task 1: write a duration-parsing function with tricky edge cases (12 test cases)
  • Task 2: fix a buggy interval-merging function (6 test cases)

We graded the code locally and recorded three numbers per run: pass rate, output tokens, and wall-clock time. Cost is tokens times each vendor's list price, which we verified the same day. Two tasks is a probe, not a benchmark, but it's the kind of routine request you'll send hundreds of times.

The results

Every model passed every test case. So the table below is about one thing: efficiency:

ModelOutput tokens (both tasks)Task 1 timeCost
Kimi K2.7 Code2,18345.2s$0.0090
DeepSeek V4 Flash2,23116.7s$0.00066
DeepSeek V4 Pro2,52737.3s$0.0023
MiniMax M35,40936.7s$0.0067
GLM-5.27,13099.3s$0.0318
Claude Opus 4.8 (baseline)5398.1s
Output tokens used by each model to solve the same two coding tasks

The token column is the story. GLM-5.2 and MiniMax M3 are "thinking" models: by default they reason at length before answering. That reasoning is billed as output. For the same correct function, GLM-5.2 wrote 3x more tokens than Kimi K2.7 Code.

It gets worse with a token cap. When we limited responses to 2,048 tokens, both thinking models spent the whole budget reasoning and returned no code at all. You pay, you get nothing. GLM-5.2 needed a 16,384-token ceiling before it finished, and its two failed attempts cost about $0.045 on their own. If you use a thinking model inside a coding agent, raise max_tokens or turn thinking off for routine edits.

Cost to complete both test tasks at official API prices

For comparison, Claude Opus 4.8 solved both tasks in 539 tokens. Open models have caught up on correctness; on brevity, the closed baseline is still 4x ahead.

The best open source coding models by deployment tier

Pick by where the model will run. Prices are per 1M tokens, verified 2026-07-17.

Strongest model, if you can wait for it: GLM-5.2

On hard, multi-step coding work, GLM-5.2's output quality is the closest an open model currently gets to Claude-tier — it leads the agentic benchmarks (SWE-Bench Pro, Terminal-Bench 2.1), and in our own extended use it's the one we trust with the problems the others fumble. More in our GLM-5.2 API guide.

The price of that quality is patience. It was the slowest and hungriest model in our test (99.3s and 5,695 tokens on Task 1), and the sluggish serving reflects constrained GPU capacity on the vendor side more than the model itself. $1.40 in / $4.40 out, 1M context, plain MIT. Give it the hard problems and a big token budget; route quick edits elsewhere.

Best for fast API coding agents: Kimi K2.7 Code

The most token-efficient open model we tested: its bug fix took 259 tokens, Claude-like terseness. It also leads Kilo's task-completion benchmark at 60.7%.

Pricing: $0.95 in / $4.00 out, $0.19 on cache hits. The one real limitation is context: 262K tokens, while the rest of this list offers 1M. For how it stacks up against its closest rival, see Kimi K2.7 Code vs GLM-5.2.

Kimi K2.7 Code official pricing page showing $0.95 input and $4.00 output per million tokens

Best value: DeepSeek V4 Flash

$0.14 in / $0.28 out, the cheapest model here by far, and it still passed everything we threw at it, fastest among the open models. Its published scores (79.0% SWE-Bench Verified, 91.6% LiveCodeBench) sit within two points of its big brother. Context is 1M tokens, license is plain MIT.

Start here. Move up to V4 Pro only when multi-file work starts exposing the gap.

DeepSeek official pricing docs showing V4 Flash and V4 Pro with OpenAI and Anthropic format endpoints

Best on a 24GB consumer GPU: Qwen3.6-27B

A dense 27B that posts 77.2% on SWE-Bench Verified, flagship-adjacent scores from a model that fits on one consumer card, which is why it's the recurring answer in r/LocalLLaMA threads that open with "I have 24GB of VRAM."

Its faster sibling Qwen3-Coder-Next (80B total, only 3B active per token, Apache 2.0) is the community speed pick: one user ran it at ~20 tokens/s on a single RX 9070 XT at full 262K context. If you'd rather call it as an API, it starts at $0.30/$1.50 via Alibaba Cloud.

Best single-GPU self-host: Gemma 4 31B

Per Google's model card, the 31B fits on one 80GB H100 with a 256K context, under Apache 2.0. The 12B variant runs in 16GB of VRAM.

One sizing trap: MoE models advertise small "active" parameter counts, but you still have to store the full weights. DeepSeek V4 Flash activates 13B per token yet weighs 284B total, about 142GB even at 4-bit. That's a multi-GPU project, not a single card.

Best budget pick for long autonomous runs: MiniMax M3

1M context at $0.30/$1.20, built for multi-hour agent sessions — MiniMax has demonstrated a 12-hour unattended research run. It shares the thinking-model verbosity you saw in the results table, so budget tokens accordingly. When quality matters more than cost on a long run, GLM-5.2 above is the upgrade.

What the leaderboards don't tell you

Benchmark numbers are close now: Stanford's AI Index found the gap between the #1 and #10 model shrank from 11.9% to 5.4% in a year. Three things the score tables still hide:

Cost per task beats cost per token. GLM-5.2's $4.40 output price looks close to Kimi's $4.00. After real token counts, the same job costs 3.5x more. Kilo's live stats show the extreme case: DeepSeek V4 Pro averages $15.91 per completed benchmark attempt on a $0.87 sticker price.

Same model, different harness, different result. A model inside a well-built agent loop (structured tools, retries, sane token limits) behaves nothing like the same model in a raw chat call. Our GLM zero-code failures were a configuration interaction, not a capability gap.

Each benchmark measures a different job. LiveCodeBench is algorithmic generation; DeepSeek V4 Pro wins it at 93.5%, above the closed models' published scores. SWE-Bench Verified is repo-level bug fixing; Claude Mythos 5 still leads at 95.5% with open models around 80%. Match the benchmark to your actual work before trusting a ranking.

Replacing a Claude subscription

A common trigger for going open source: hitting Claude's subscription limits mid-workday. The math works. Our two-task probe cost $0.00066 on DeepSeek V4 Flash; a few hundred such calls a day still stays under a dollar.

The switch is also less plumbing than it used to be. DeepSeek publishes an Anthropic-compatible endpoint (api.deepseek.com/anthropic), so Claude Code can drive it with an environment-variable change; the same setup works for GLM-5.2. And if you want to keep Claude for the hard problems while routing routine work to open models, platforms like AIReiter serve Claude at 20% of list price through the same Anthropic-compatible interface.

Kimi K3: the one to watch

Moonshot shipped Kimi K3 on July 16, 2026, and on frontend work it has already passed the strongest closed model: #1 on the Frontend Code leaderboard at 1,679 versus Claude Fable 5's 1,631, and early hands-on reports point the same direction.

It's not ranked here for one reason: the weights open on July 27. Until then it's a closed API at $3/$15. Once they land, K3 becomes the largest open-weight model released to date, and the frontend numbers above suggest it will contend for the top of this list. We're tracking the K3 open-weights release separately.

How to choose

1. Where will it run? Under 16GB VRAM: use an API (Gemma 4 12B fits locally, but expect a real quality drop). 24GB: Qwen3.6-27B. One H100: Gemma 4 31B. API: DeepSeek V4 Flash until it proves insufficient. 2. What kind of work? Quick edits favor terse models: Kimi K2.7 Code or DeepSeek. Hard problems and long agent runs favor GLM-5.2 (or MiniMax M3 on a budget), with generous token budgets. 3. License constraints? MIT (GLM, DeepSeek) and Apache 2.0 (Qwen, Gemma) have no strings. Kimi's modified MIT adds an attribution rule that only kicks in at very large commercial scale.

FAQ

What is the best open source LLM for coding in 2026?

GLM-5.2 has the highest ceiling — near Claude Sonnet-tier output on hard problems, at the cost of speed. Kimi K2.7 Code wins on token efficiency for API agents, Qwen3.6-27B for local hardware, DeepSeek V4 Flash on cost.

Can I run these models locally for free?

The weights are free; the hardware isn't. A 27B model needs a 24GB GPU, Gemma 4 31B wants 80GB, and the trillion-parameter flagships are API-or-cluster only.

What's the difference between open source and open weight?

Open-weight means free weights but private training data and code, which describes nearly every model here. Fully open source models (OpenCoder, StarCoder2, IBM Granite Code) publish everything but trail in capability.

Is there an open source LLM as good as Claude for coding?

On algorithmic benchmarks, yes: DeepSeek V4 Pro's 93.5% LiveCodeBench beats published closed-model scores. On repo-level fixes, Claude still leads (95.5% vs ~80% SWE-Bench Verified). In our test the open models matched Claude on correctness but used 4–13x more tokens.

Which open source LLM is best for C++ or niche languages?

Kimi's K2 series has the strongest niche-language reputation (Moonshot specifically calls out Zig). For C++, community consensus points to DeepSeek V4 Pro and Qwen3 Coder Next. Whatever you pick, test on your own codebase; niche-language quality varies far more than Python benchmarks suggest.