Anthropic has just completed one of the most unusual rewrites in recent software history: the Messages API, the service that powers Claude for millions of people, now runs on Rust. The Python code that carried it from a 2024 prototype to a production workload has been replaced — and most of the new code was written by Claude itself.
Anthropic says the result is cheaper to run and noticeably faster to answer: around 70% less CPU per request and a median time to first token about 20% shorter. The whole migration happened with no downtime, no API changes and no retraining. Here is what was rebuilt, what Anthropic verified, and why it matters for everyone who builds on the API.
The rewrite in numbers
- CPU per request: down roughly 70% — Anthropic is consolidating hundreds of servers.
- Time to first token: median down about 20%.
- First three API calls: time down about 30%.
- API calls: up 3.5x in one year, traffic up 1,800x since early 2024.
The Python service had kept working for two years because the Python layer was never the bottleneck: requests spent almost all their time waiting for model inference, so a typical request used about 3% CPU. The problem was scale. By 2026, inference had become cheaper and faster, and the Python overhead — about 500 servers' worth of it — was the thing worth fixing.
Claude wrote most of the code
Anthropic's own engineers wrote the design and the hardest pieces, but the rest — roughly 9 out of 10 lines — came from Claude. The model and product teams built custom "skills" for Claude Code: design documents, API guidelines and Rust patterns, so the rewrite produced code that looked like it came from an Anthropic engineer. There was a human in the loop throughout, and Anthropic says that was non-negotiable: the model could generate the code, but the verification was theirs.
Why Rust
Rust has no garbage collector, no runtime, and a borrow checker that enforces safe memory handling at compile time. Python's global interpreter lock had forced the old service to run many processes per machine; Rust's async model lets one process handle far more work with less memory and fewer servers. Anthropic considered Go and a C++ extension, but only a full Rust service removed the Python layer entirely.
What they verified
Anthropic's 700+ integration tests passed before any Rust traffic ran — and yet the team still found real problems when they compared the two implementations against live traffic:
- A Python client bug that made one user agent stop sending requests mid-stream.
- A Python retry loop that was hiding a bug.
- Missing request timeouts and token limits in places.
The new Rust code itself also needed rewrites for timeouts, retries, load shedding and streaming. Even after all that, a bad deploy exposed a bug in one service — caught by live-traffic verification before it reached customers. The lesson Anthropic drew from it: with AI-generated code, trust comes from testing and canary deploys, not from reading the code.
No downtime
The cutover happened live, with no downtime and no API changes for users. The API looks identical from the outside; only the cost and latency changed.
Why it matters
Anthropic believes the pattern will repeat: models will increasingly write the software that serves them, and the industry will have to verify AI-generated code the way Anthropic did here — with tests, traffic replay and canaries. The company is already talking about open-sourcing the verification patterns it used.
Originally published on Ai Game Changer Pro.


