Anthropic Ports Claude API From Python to Rust Using Production Traffic as the Test
Anthropic says it rewrote its Messages API from Python to Rust without downtime, cutting CPU use by about 70%. The main challenge was verifying the new code, which it did by comparing live traffic against the old service.

TL;DR
- Anthropic moved its Messages API from Python to Rust without taking the service offline or pausing feature work.
- The new version reportedly uses about 70% less CPU per request, 80% less memory, and about 20% lower median time to first token.
- The hard part was not writing the code but proving it behaved like the old system, so the team used shadowing and AI agents to find and fix differences.
Why the Python service had to change
Anthropic launched the Messages API in 2023 as a simple Python request forwarder. It is the main route both external customers and Anthropic's own internal apps use to reach Claude. According to the company's engineers, API traffic grew more than 1,800 times from early 2024 to fall 2026. By late 2025, each request had to be validated, turned into a prompt, tokenized, and screened by safety classifiers, and the replies had to be sorted into text, thinking, and tool calls. Python added overhead at each of these steps.
The team first rewrote only the slowest parts. As InfoWorld reported, the gains in CPU usage were too small to justify the extra complexity, so a full migration was considered.
Why verification became the bottleneck
By May 2026, Claude was writing more than 80% of the code Anthropic merged, which made a full rewrite far cheaper to produce. The problem shifted to checking the result. Live systems are hard to verify: the Python code kept changing, privacy limits restricted what could be inspected, and model replies are nondeterministic. As the engineers put it, "Verification, not generation, had become the bottleneck."
The team already had about 700 integration tests. They proved inadequate, since they were incomplete and tied to the Python implementation, and some tests passed when they should not have.
Shadowing and a three-loop setup
Instead of relying only on tests, Anthropic ran each request through both the old and new code and compared the outputs. Each difference was recorded as a compact diff record that described what differed and where, without storing customer content. A single bug could generate hundreds of thousands of nearly identical records, so the team used fingerprints to tell separate bugs apart.
The fixes were handled by three nested loops. A fast inner loop gave agents a sandbox to test hypotheses and propose fixes in under a second, though only on requests the agents had written themselves. A slower outer loop checked each fix against production-like Rust deployments, with and without the change. A memory loop stored mistakes and reviewer decisions so later agents could apply them. In one example, an engineer rejected a web search shortcut, and the agent saved a note explaining why and what the correct fix was.
What the team concluded
Anthropic's write-up lists several lessons. Verification is now the constraint on large migrations, not the effort of writing code. When tests are not enough, the production system itself can serve as the verifier, but it needs signals that locate each difference in the code. Humans were kept for defining what counts as correct, while agents chose which hypotheses to test and how to fix bugs. The engineers moved from working inside the loop, to steering agents, to writing rules and checks. In their words, the work moved "from directing Claude to Claude directing itself, relying on humans mainly for important judgment calls."
The reported performance figures come from Anthropic's own account, as covered by InfoWorld. Outside reviewers have not published independent measurements in the sources available here.
Why it matters
For developers, the main takeaway is about the cost of large rewrites. If code generation is cheap, the planning effort shifts to defining correct behavior and building a way to check it against real traffic. Teams considering a language migration need to invest in shadow comparison, clear diff signals, and a shared record of decisions before they trust automated fixes. Developers who want background on Rust's recent language changes can read our post on Rust stabilising the never type and a core allocator API.
Sources
This article was written by Blozhik from the reporting below. Read the originals for full detail.
InAnthropic says it moved its Claude API from Python to Rust with no downtimeInfoWorldKeep reading


