The Bill Is Not the Cost

Cloud API or self-hosted GPUs for your coding agents?
You buy savings by accepting more broken commits.
One production repo ran the experiment, 56 days split in half, 28 days on Claude Opus 4.7/4.8 through the API, 28 days on a self-hosted GLM 5.1/5.2, an open model compressed to fit on four GPUs. 16 billion tokens later, the winner changes depending on how you count.
💸 Price per token. Claude wins.
The provider barely charges for context it has already processed. That mechanism is called prompt caching, and here it covered 99.3% of the traffic. So the real price came down to $0.57 per million tokens, 89% below the list price. The self-hosted GPUs came out at $2.83 per million. Per token, the "expensive" frontier model costs 5 times less than your own hardware.
🧾 The total bill. GLM wins.
The 28 days on Claude cost $8,785, because the API bills every token that goes through. The 28 days on GLM cost $2,560, because the developer only paid for one seat on a GPU cluster shared with other teams.
🐛 Code quality. Claude wins big.
When the developer worked with GLM, 3 out of every 4 commits he pushed were there to fix something that had just broken. With Claude, fewer than half were. At the worst point, GLM sent him through 58 fix commits in a row. Claude's worst run was 18. This is not happening because the tasks got harder. Even the easy tasks showed the same gap.
⚖️ Full cost, labor included. It depends on one thing.
All those repair commits are hours a developer gets paid for. So the study added the repair time to the hardware bill. Even then, GLM on the shared cluster stays 40% cheaper overall. But sharing is what makes it cheap. The study also priced a dedicated setup, where the four GPUs are yours alone, 24 hours a day, billed even when idle. That version comes out 44% more expensive than Claude with caching. Everything hangs on how busy your GPUs are.
All of this comes from one developer, at public API prices. A volume discount, which large companies negotiate, would change the math. The study also cannot separate the model from its compression or from the coding tool around it (Claude Code on one side, Opencode on the other), so read it as a method, not a Claude versus GLM leaderboard. And everything here is about coding agents, one of the hardest jobs you can give an LLM. Many company workloads are simpler and well-bounded, like extraction, classification or internal support. On those, a self-hosted model may pay no quality tax at all.
📋 Before signing for hardware, measure three numbers in your own stack.
▸ your cache hit rate (it divided the per-token price by 9 here) ▸ your GPU utilization (the same hardware was 40% cheaper shared, 44% more expensive dedicated) ▸ your fix commit ratio per model (the quality tax)
Two of these live in your telemetry, the third in your git history.