Anthropic has detailed how it migrated the Messages API — the primary way customers and its own apps, including Claude Code and Cowork, reach Claude — from Python to Rust, reporting that the new service uses about 70% less CPU per request and cuts median time to first token by about 20%, all without taking the API offline or freezing feature development. All performance figures come from the company's own engineering post; no independent measurements have been published.
The context explains the urgency. Anthropic built the Messages API in 2023 in Python, and one engineer described the original service as "basically a request forwarder." By late 2025 it had grown into a pipeline that validated every request, built the prompt, tokenized it and screened it with safety classifiers, then sorted each reply's token stream into text, thinking and tool calls — with Python overhead at every step. From early 2024 to fall 2026, the company says API traffic grew roughly 1,800 times.
The first attempt was the textbook approach: rewrite only the slow parts. Anthropic moved the model-output parser to Rust and called it from Python. That cut CPU usage by only about 8 to 10 percent, because each token of a reply crossed the Python-Rust boundary three times. What changed the calculation was the falling cost of writing code: by May 2026, the company says, Claude was writing more than 80% of the code Anthropic merged, and Claude produced a first version of the new API's core request path in about a week.
The hard part was not writing the Rust but proving it behaved like production. Parity was a moving target because the Python API kept changing. Claude replies nondeterministically, so a difference between two outputs did not necessarily mean a bug. And Anthropic could not read customer requests, so it could not easily see where the versions diverged. Its existing suite of about 700 integration tests turned out to be a poor judge: the tests were coupled to the Python implementation, and an audit found more than 100 weakened assertions introduced during porting.
Anthropic's answer was to make the running production API itself the verifier. The team tested the Rust version against live production traffic, found where the two diverged, and automatically dispatched Claude agents to track down and fix the differences. The company frames the result as a general lesson: with code generation cheap, verification becomes the bottleneck, and a production system can serve as the oracle when no test suite is thorough enough.
For an industry wondering what agents can safely be trusted to rewrite, the post is one of the clearest data points yet. The caveat stands: the 70% and 20% numbers are the migrating team grading its own homework. But the pattern — keep the old system running as the judge, let agents close the gap, then move passengers over a few at a time — is likely to be copied well beyond one API.
Comments (0)
Log in to join the discussion
Log InNo comments yet