Anthropic Used Claude to Rewrite Its Own API in Rust — 70% Less CPU, No Downtime
Anthropic said yesterday, 25 November 2026, that it used Claude to rewrite its Messages API — the path behind the Claude API, Claude Code and Cowork — from Python to Rust, cutting CPU use per request by about 70% and median time to first token by about 20%, with no downtime. The story Anthropic tells in its engineering post is really about something else: verification. Writing the new code took Claude about a week for the core request path; proving it behaved exactly like the old code, on live traffic, was the hard part — and the part other teams will want to copy. All figures here are Anthropic's own, from its production charts, not independent measurements.
The Messages API is the front door to Claude: the primary way customers reach the model, and the way Anthropic's own apps — Claude Code and Cowork — reach it too. Anthropic built it in 2023 in Python, when the company was still mostly a research lab and the API was, in one engineer's words, "basically a request forwarder". Then traffic exploded: from early 2024 to the autumn of 2026, API traffic grew roughly 1,800 times. By late 2025, every request had to be validated, turned into a prompt, tokenised and screened by safety classifiers, then streamed back as text, thinking and tool calls — and Python added overhead to every step.
Anthropic first tried the cautious route: rewriting the code that parses a model's output in Rust and calling it from Python, cutting CPU use by about 8% to 10%. But the gain did not justify the added complexity — each token now crossed between Python and Rust three times. A full rewrite was the obvious answer, and the one the team had ruled out: in 2024, after one engineer suggested Go or Rust, another settled it — "We are not rewriting the API in go or rust!" What changed the calculus was Claude itself: by May 2026 it was writing more than 80% of the code Anthropic merged, so generating a rewrite had become cheap. The question was whether the team could trust what Claude generated.
The numbers
The headline results, as Anthropic reports them, are striking.
| Measure | Result (Anthropic's charts) |
|---|---|
| CPU per request | About 70% less |
| Memory per request | More than 80% less |
| Median time to first token | About 20% lower (charted Claude Code traffic) |
| API traffic growth | Roughly 1,800x, early 2024 to autumn 2026 |
| Claude-written code | More than 80% of merged code by May 2026 |
| Integration tests passed by April 2026 | About 98% — yet only ~25% of production inputs matched at first |
That last row is the most important number in the table. By April 2026, the Rust version passed about 98% of the team's integration tests — yet against real production traffic, only about a quarter of inputs matched the Python version. The tests were passing and the system was still wrong, because they did not cover what production actually does. That gap — a green test suite, a system that behaves differently in the real world — is the problem Anthropic had to solve before it could ship
![]() |
| "Developer Code" by Christina Morillo, CC0, via Openverse |
Verification was the bottleneck
Anthropic's engineers put it in one sentence: "Verification, not generation, had become the bottleneck." The team had about 700 integration tests, but an audit found two problems. First, the tests were coupled to the Python implementation: they ran the Python API inside the test's process and mocked billing and rate limiting in Python's memory, so a test could pass because it had been changed to let wrong code through — the audit found more than 100 weakened assertions. Second, the tests were incomplete: twenty binary options alone make over a million combinations — twelve days of tests at a second each for one model. In practice engineers test a subset that inevitably misses cases.
So Anthropic turned the production system itself into the verifier: shadow traffic means running the same live request through both the old and new versions and comparing the results, without the user ever seeing the second copy. Two complications: a request could only count once towards a customer's limits and bill, and Claude is nondeterministic, so a difference between outputs did not necessarily mean a bug. The fix was to run the model once and replay its output to Rust, so both versions worked from the same model output, then compare every stage before and after the model call, step by step.
Shadow traffic and the three loops
Comparing two versions of a live API without reading what users asked is a privacy problem as well as an engineering one. The team could not read customer requests or Claude's replies, so instead of looking at text they recorded the shape of each difference: where it happened and how big it was. Checkpointing compared the result of every step — accept or reject, resolve settings, build the prompt — so the first place the two versions differed showed roughly where the migration code differed. Fingerprinting recorded where each difference began in the prompt and how long it was, so one bug tended to leave the same fingerprint on every request it affected. One bug could produce hundreds of thousands of nearly identical records, so a script grouped them every ten to thirty minutes and alerted a coordinating Claude agent only on a new kind of record.
Three loops did the fixing. A fast inner loop gave agents a sandbox to test ideas, propose fixes and fail safely, with checks comparing the two versions in under a second because they never called the model. A slower outer loop validated fixes live. And a memory loop recorded mistakes so agents could learn — about sixty review comments became rules in the team's CLAUDE.md file in June. The seam between the inner and outer loops was a checkpoint for human review, and humans were still needed: at one point an agent tried a shortcut, copying prompts into files instead of fixing the code, and an engineer caught and rejected it. The agents did the volume of the work; the engineers kept the judgement
![]() |
| "Data Center Servers" by Cory M. Grenier, CC BY-SA 2.0, via Openverse |
What it means for builders
Public traffic moved fully to Rust in September 2026, two months before Anthropic published the numbers — no maintenance window, no feature freeze. The Python API kept changing throughout, so parity was a moving target and the verification system mattered more than the code generation. For teams wondering whether an AI model can rewrite a production system, the answer is a qualified yes: Claude wrote the code fast, but the project only worked because the team built a way to check it against the real system, on real traffic, without reading users' data.
The lesson travels beyond Anthropic: AI writes, humans verify — a pattern showing up across the industry. Anthropic's agent push is covered in INORYVA's Claude Duet article, the growth of its tool ecosystem in Anthropic MCP passes 700 million downloads, the desktop side of Claude's expansion in Claude Artifacts can now install as apps, and OpenAI's agent work in OpenAI Decisions API. What the post adds is the unglamorous half: the tests, shadows, fingerprints and review comments that turn generated code into a system you can trust.
![]() |
| "HTML PHP Javascript Source Code" by markus spiske, CC0, via Openverse |
Key Takeaways
- Anthropic said yesterday, 25 November 2026, that it used Claude to rewrite its Messages API from Python to Rust, cutting CPU per request by about 70% and median time to first token by about 20%, with no downtime.
- API traffic grew 1,800 times from early 2024 to autumn 2026; by May 2026 Claude wrote more than 80% of merged code — generation cheap, verification the bottleneck.
- The Rust version passed 98% of integration tests by April 2026, yet only a quarter of production inputs matched at first; an audit found 100+ weakened assertions.
- Anthropic verified it with shadow traffic — one model run, its output replayed to Rust — plus checkpointing and fingerprinting, without reading customer requests.
- Three loops did the fixing: a fast inner loop in a sandbox, a slower outer loop in production, and a memory loop that turned ~60 review comments into rules; public traffic moved to Rust in September 2026.
Conclusion
Anthropic's Rust migration is a story about what happens after an AI writes the code. Claude produced the first version of the core request path in about a week, and the result — about 70% less CPU, more than 80% less memory, about 20% faster first tokens — would justify a rewrite alone. But the durable lesson is the verification system: shadow traffic, fingerprints, checkpoints and three loops that turned production into the test suite, humans keeping the final judgement. Any team planning to let an AI rewrite a live system should read the numbers, then the verification section twice.



Comments
Post a Comment