← Back to Blog

GLM vs Claude for Coding Agents: The Gap Got Small, But It Didn't Close

An open-weight model you can download for free now trades blows with Claude on coding benchmarks at a fraction of the price. So why do experienced developers still keep Claude around? Because a coding agent is not a benchmark.

August 4, 2026


Here is a thing that would have sounded absurd a year ago. You can download the weights of a top-tier coding model for free, run it on your own hardware if you want, point Claude Code or Cline at it through a cheap API, and pay roughly a sixth of what Claude costs per token. On the coding benchmarks everyone quotes, that model lands within a few points of Anthropic’s best. The US government’s own AI evaluation body called it “probably the most capable open-weight AI model when it was released” (NIST/CAISI, July 17 2026).

The model is GLM-5.2, from the Chinese lab Zhipu AI (they trade as Z.ai). On paper, this is the end of the story: the open model caught up, it costs a fraction, go switch and save money.

It isn’t the end of the story, and the reason why is more interesting than the leaderboard. A coding agent is not a benchmark. The single place Claude still clearly wins is the exact thing benchmarks barely measure. So the honest question stopped being “which model is better” a while ago. It’s now “which job are you doing, on which turn,” and the smartest move is to stop treating it as a choice you make once.

What GLM even is, quickly

If you have only half-followed this, here is the catch-up. Zhipu AI is one of the strongest labs to come out of China, and their GLM series has been quietly climbing for a couple of years. The current released coding model, GLM-5.2, shipped around June 16 2026. It is a mixture-of-experts model, which just means the full network is huge (about 753 billion parameters) but only a slice of it (around 40 billion) actually fires on any given token, so it runs cheaper than its size suggests. It takes a one-million-token context window, and its weights are released under the MIT license, so you can host it yourself with no permission needed (The AI Rankings, June 2026).

There is a slightly funny detail in the lineage. The previous version, GLM-4.6 (September 2025), was described by the lab as “aligned with Claude Sonnet 4.” They were openly tuning against Claude’s behavior. The student has been studying the teacher.

You can reach GLM-5.2 through Z.ai’s own API, through resellers like OpenRouter or DeepInfra, through a subscription “Coding Plan” that starts around $18 a month, or by running the weights on your own GPUs (felloai, 2026).

On the other side: Claude. Anthropic’s newest are Claude Opus 5 (launched July 24 2026) and Claude Sonnet 5 (June 30 2026), sitting at roughly $5 in / $25 out and $3 in / $15 out per million tokens respectively (Anthropic, screenapp pricing, 2026). Closed weights, API only. You cannot download Claude and run it in your basement, and you cannot escape the metered bill.

One caveat before any comparison, because it matters for reading everything below. Claude’s 5-line is brand new. Almost every rigorous GLM-versus-Claude test that exists was run against the previous Claude, Opus 4.8, not against Opus 5. So when you see “GLM is a couple points behind Claude,” read it as “behind Opus 4.8.” The new models probably widen the raw-quality gap again, but nobody has independently tested them head to head with GLM yet. This is a snapshot as of early August 2026, and this space genuinely moves week to week.

The benchmarks are close. Also, be careful with benchmarks.

Here are the honest numbers, with the honest asterisks.

On SWE-bench Pro, a suite of real GitHub bug-fix tasks, GLM-5.2 scores in the low 60s against Opus 4.8’s high 60s, a gap of roughly seven points. On FrontierSWE, a long-horizon coding test, they’re nearly tied in the mid-70s. On the Artificial Analysis Intelligence Index, a blended cross-model score, GLM lands around 51 to Claude’s 56 (morphllm, 2026; The AI Rankings). Single-digit gaps, in most cases. That is remarkable for a model you can download for nothing.

Now the asterisks. Most of those specific percentages live on aggregator and SEO blog sites, not primary sources, and they don’t always agree with each other. Vendor-published benchmarks reliably run higher than independent ones. And GLM-5.2’s own release notes admit the model showed “reward-hacking behavior” during training, which is the polite term for a model learning to game the test instead of doing the underlying task (Semgrep, June 22 2026). So treat any single headline percentage as directional, not gospel. The trustworthy takeaway is the shape, not the decimal: the gap on coding evals is now small.

Which does bury one belief for good. “Open models can’t really code” was true, and then it quietly stopped being true. GLM-5.2 sits about a point behind Claude on some long-horizon coding composites and, as we’ll see, actually beats it in a couple of narrow tests. The chasm is a crack now.

The price gap is why anyone is asking at all

Nobody would be writing GLM-versus-Claude posts if the numbers were close and the prices were equal. They aren’t. GLM runs somewhere around six to seven times cheaper per token than Opus, depending on the provider (pricepertoken).

The obvious objection to a cheaper model is that you pay the savings back in retries: a weaker model flails, burns more tokens, needs more turns, and you end up even. Someone actually measured this. Braintrust ran a hands-on comparison in June 2026 and found GLM-5.2 was roughly seven times cheaper per correct answer, not just per token, and it used about half the tokens Opus did to get there (Braintrust, June 30 2026). The cheap model didn’t quietly cost you on the back end. On that test, it was cheaper all the way down.

That gap lands differently depending on who you are. If you’re a solo developer running Claude Code all day, it’s your monthly invoice and the moment you hit a usage wall mid-task. If you’re a startup that shipped an agent into your product, it’s cost of goods sold. Every user session that runs your agent is a bill you eat, and it scales with growth, straight against your margin. For that second group, a six-times price difference isn’t a nice-to-have. It can be the difference between a feature that’s viable at scale and one that isn’t.

Where Claude still wins: the loop

Here is the part the benchmarks keep missing, and it’s the whole argument.

A benchmark question is usually one shot. Read the problem, produce the answer, get scored. A coding agent is nothing like that. It’s a loop that runs for dozens of turns: read a file, call a tool, read the tool’s output, decide what to do next, edit something, run the tests, read the failure, try again. The model isn’t answering a question. It’s driving, for a long time, with a lot of state to keep straight.

That loop is exactly what the good hands-on tests said they did not measure. The Braintrust authors were explicit that their study covered retrieval, not agentic multi-step behavior, tool-calling, or instruction-following. The Semgrep team said the same about theirs. Both of them, having done careful work, drew a box around it and told you what was outside the box. What’s outside the box is the thing that actually makes or breaks a coding agent.

And on that thing, the reports point one direction. Claude has more tool-use mileage. It’s the model that, as one roundup put it, “rarely hallucinates a function signature” (mindstudio, 2026). It tends to stay coherent deeper into a long session and follow fuzzy, underspecified instructions the way a good pair-programmer does. Scan experienced-developer threads and a consistent pattern shows up: people keep Claude Code for their hardest problems and reach for cheaper or unlimited tools for the routine stuff (morphllm, 2026). “Right tool for the right task” is the settled opinion, not “one model to rule them all.”

I want to be fair to GLM here, because the story isn’t one-sided. GLM-5.2 performs reliably on structured JSON output and function-calling benchmarks. The problem is that a function-calling benchmark and forty consecutive tool calls in a live repo are not the same test, and the second one is barely measured for either model. Whether GLM holds up over a genuinely long agent session, versus Claude, is mostly anecdotal right now. That’s not me hedging to be safe. It is honestly an open question, and anyone who tells you they have the definitive answer is selling something.

One wrinkle worth sitting with. In Braintrust’s retrieval test, the brand-new Claude Sonnet 5 degraded more over long context (from about 83% down to 71%) than GLM-5.2 did, and GLM stayed roughly flat. Newer and pricier does not automatically mean steadier. “Long context always rots” used to be a safe assumption. It’s now a per-model question you have to actually check.

The parts that aren’t about quality at all

Two things sit next to the quality question and quietly shape the decision.

The first is where your code goes. If you use Z.ai’s hosted API, your prompts, which for a coding agent means your source code, get processed on servers in China. China’s National Intelligence Law, Data Security Law, and Cybersecurity Law create legal pathways to compel data handover, and US agencies including DHS have flagged the risk (CSIS, 2026; TechTimes, June 17 2026). For a regulated team, or anyone shipping code they can’t send offshore, that can be a hard stop.

The nuance that often gets dropped: this is a risk of the hosted API, not of the model. GLM-5.2’s weights are open. Self-host them, and the data never leaves your environment. The privacy question and the migration question turn out to be the same question, which is a point in favor of the open model, not against it, if you’re set up to run it.

The second thing is that everything here is a moving target. GLM-5.2 landing near Claude on cyber-capability benchmarks became part of an export-control fight, with a US House inquiry opened in May 2026 (TechTimes, June 28 2026). Anthropic shipped two new models in the five weeks before this was written. GLM-5.5 is rumored for sometime this month and could reset the whole comparison. Whatever you conclude today has a short shelf life, so build a workflow that can change its mind, not a religion.

So which one? Honestly: both, on purpose

If you’ve read this far waiting for me to crown a winner, I’m going to disappoint you, because picking one is the wrong frame.

The reasonable read as of early August 2026: GLM-5.2 for cost-controlled, self-hostable, repo-scale work and the large volume of routine coding that doesn’t need a genius. Claude when frontier agentic reliability is worth paying for, on the gnarly multi-step problems where a hallucinated function signature or a lost thread costs you an hour. That’s not a compromise. It’s what the experienced developers in those threads already do by hand, one task at a time.

The trouble is that doing it by hand is a pain, and switching is usually all-or-nothing. You pick a model, you wire your agent to it, and reversing that mid-task is awkward. You can’t easily try the cheap model and fall back to the expensive one the moment it starts flailing. And underneath all of it, every long agent session pays the same hidden tax no matter which model serves it: the agent re-sends its entire growing history on every single turn, so a session that’s been running for an hour is burning tokens re-reading everything it has ever read, on both models, regardless of which one is cheaper per token.

Where this connects to what we build

This seam, “GLM for the cheap routine turns, Claude for the hard ones, without rewiring anything,” is roughly the problem AJNT sits on top of, so I’ll be upfront that this is the part where I talk about our own thing.

The gateway gives your existing agent one endpoint and then routes each request down a cost-ordered ladder. You can put GLM on the cheap rung and Claude behind it, so a request tries the cheaper model and falls through to Claude automatically when a provider degrades, with the savings measured rather than guessed. That turns “migrate to the open model” from an all-or-nothing bet into something incremental and reversible, which given how fast this space moves is the only sane way to make the bet at all. Because the gateway translates across model families, a session you opened in Claude Code can be served by GLM without touching your code, and switched back just as easily.

It also goes after that hidden tax directly. A per-session compression engine rewrites the resent history before it goes upstream, so the agent keeps behaving normally, resending everything the way agents do, while what actually crosses the wire stays bounded. That’s the same win whichever model wins the turn. And if the China-data question is your blocker, the same pipeline runs against your own keys, an encrypted vault, or a self-hosted endpoint, so you can keep GLM inference entirely under your control.

We’re early, so I’m not going to hand you a savings percentage I’d have to make up. The honest pitch is just the shape of it: the choice between a cheap open model and an expensive frontier one shouldn’t be a wall you commit to. It should be a dial you can turn.

The real takeaway

The interesting thing about GLM-5.2 isn’t that it beat Claude somewhere. It’s that it got close enough that the question changed. For a while the debate was “are the open models good enough yet,” and that debate is basically over. The new question is smaller and more practical: which job, which turn, which model. The best answer to that isn’t picking a side and defending it. It’s building things so you don’t have to.


← Back to Blog