Anthropic has rebuilt the engine room of its own business. The Messages API — the route nearly every Claude request travels, from customers, Claude Code, or Cowork — now runs on Rust instead of Python. Claude agents wrote most of the new code, and the company says the switch cut CPU use per request by about 70% and the wait for the first token by about a fifth, without taking the service offline once.

The numbers are the headline; the method is the story. In an engineering post published November 25, Anthropic describes a migration where writing the code took about a week and proving it behaved like the old code took months. The test suite passed. Production traffic disagreed. Closing that gap was the real project.

Why the rewrite became unavoidable#

Built in 2023, the Messages API began as little more than a forwarder: a request came in, the model answered, the answer went back. But the service kept gaining responsibilities — by late 2025 every request had to be validated, turned into a prompt, tokenized, and screened by safety classifiers, and every reply sorted into text, thinking, and tool calls. Traffic had grown roughly 1,800-fold since early 2024.

A rewrite had been suggested in 2024 and shot down — “We are not rewriting the API in go or rust!” one engineer replied. Rewriting just the output parser in Rust saved only 8–10% of CPU while sending each token across the language boundary three times. What changed the calculus was Claude: by May 2026, Anthropic says, it was writing more than 80% of the code the company merged. A full rewrite suddenly looked cheap. The question was whether the result could be trusted.

The code was the easy part#

Claude produced a first version of the core request path in about a week. The team had roughly 700 integration tests, and the Rust code passed about 98% of them by April. But the tests were a weak judge: they were tangled up with the Python implementation, so porting them meant changing the tests with the code. An audit found more than 100 assertions that had quietly been weakened — a passing test could mean the code was right, or that the test had been edited to let wrong code through.

The tests were also incomplete: dozens of features with binary options multiply into millions of combinations, and live traffic holds cases no test imagined. The gap showed up in the numbers — 98% of tests passing, yet only about a quarter of real inputs behaving identically on live traffic. As Anthropic puts it, verification, not generation, had become the bottleneck.

A stream of light splitting into parallel lanes that pass through identical checkpoints, with small markers flagging where the lanes diverge
AI-generated illustration: one request stream, two implementations, every checkpoint compared.

Proving the new API matched the old one#

The fix was to turn the production system into the verifier. Anthropic ran live requests through both versions at once — shadowing — and compared what each did at every step: accepting or rejecting the request, resolving settings, building the prompt, sorting the model’s reply, and counting usage for billing.

Two constraints made that hard. A request could count only once toward a customer’s limits and bill, so it couldn’t simply run twice — and Claude’s replies are nondeterministic, so a difference between versions didn’t necessarily mean a bug. The answer: run the model once and replay its output through the Rust code, comparing every stage before and after the model call.

Privacy shaped the design, too. The engineers couldn’t read customer requests or replies, so instead of comparing text they recorded the shape of each difference — where it happened and how big it was. Checkpointing compared the result of each processing step; fingerprinting grouped identical differences so one bug, which leaves the same fingerprint on every request it touches, could be triaged as one item.

Three loops, one human gate#

Every difference became a small record. A script grouped records every 10 to 30 minutes and alerted a coordinating Claude agent only when a new kind appeared; the coordinator assigned a worker agent to each kind and opened a Slack thread where engineers could follow along and steer.

Fixes moved through three loops: a fast inner loop in a cloud sandbox, where agents tested ideas against checks that ran in under a second; a slower outer loop that validated fixes against shadowed production traffic; and a memory loop that saved lessons as rules. After one agent guessed at Python’s behavior, an engineer made it a rule to port exactly what Python did — and a later sweep found seven more places the port had relied on a guess.

Humans stayed at the gate between the loops. In mid-May the largest remaining difference traced to web search: the Rust API wasn’t yet calling the internal service that supplies tool descriptions. An agent proposed copying the text into files Rust could read; the prompts matched and local checks passed, but an engineer rejected it — the workaround would have to be thrown away before launch. A verifier can say whether outputs match, Anthropic notes, but not whether a fix is good enough to ship. The real fix took weeks.

A wooden sailing ship being rebuilt at sea while a glowing blueprint ship takes shape beside it
AI-generated illustration: Anthropic’s own metaphor — rebuilding the ship while it sails.

What it delivers, and what to watch#

The payoff, as Anthropic reports it: about 70% less CPU per request, more than 80% less memory, and about 20% less time waiting for the first token — with no downtime and no freeze on feature development. Coverage of the post puts the move of public traffic to Rust in September.

The wider lesson is the one Anthropic stresses: when AI writes code faster than humans can check it, the bottleneck moves to verification. Its answer — use the live system as the oracle, give agents fast feedback loops, keep human judgment where “matches” stops meaning “correct” — is a pattern other teams will now try to copy. One caveat: these are Anthropic’s own figures, with no independent verification published. Read it as a case study from an interested party, not a neutral benchmark.

What to watch: whether other labs publish migrations in the same shape, and whether the verification loops hold up for a team without Anthropic’s traffic volume or in-house models.

Sources: Anthropic, “Migrating our Messages API to Rust”; TechRepublic, “Anthropic Used Claude to Rebuild Its API in Rust, Cutting CPU Use 70%”; InfoWorld, “Anthropic says it moved its Claude API from Python to Rust with no downtime”