N環球 N GLOBE
US Technology

Anthropic moves Claude's API from Python to Rust: about 70% less CPU per request, with no downtime

· N GLOBE

Anthropic said on Wednesday (November 25) in an engineering blog post that it has moved the Messages API behind Claude from Python to Rust: public traffic switched in September 2026, with about 70% less CPU per request, more than 80% less memory per request and a median time to first token about 20% lower, all without ever taking the service offline or freezing feature development. The hard part was not getting Claude to write the new code, but proving the two versions behaved identically — the team turned the production system itself into a verifier, testing on shadowed real traffic, tracking each difference, and letting Claude agents fix them automatically.

Anthropic said on Wednesday (November 25) in an engineering blog post that it has moved the Messages API behind Claude from Python to Rust, with public traffic switching to the new service in September 2026. The Rust version uses about 70% less CPU per request and more than 80% less memory per request, and cuts the median time to first token by about 20%, all without ever taking the service offline or freezing feature development. The Messages API is the front door to every Claude request: customers as well as Anthropic's own apps, Claude Code and Cowork, reach the models through it. From early 2024 to fall 2026, API traffic grew roughly 1,800 times, turning the serving layer's language into a cost problem.

The hard part was not writing the code, but proving the two versions matched

The post says the real difficulty was not generating Rust code — Claude produced a first version of the core request path in about a week, and by May 2026 Claude was writing more than 80% of the code the company merged — but proving the new version behaved like the old one. Three obstacles: the Python version kept changing throughout the migration, with new models and features shipping regularly, so the definition of “correct” was a moving target; Claude answers the same request nondeterministically, so a different output did not necessarily mean a bug; and the team could not read customer requests, making it hard to locate where the two versions diverged.

The production system as verifier

Anthropic's answer was to turn the production Messages API itself into a verifier: the model was run once, then its output was replayed through both the Python and Rust paths for comparison; differences were tracked one by one using shadow traffic, checkpoints and fingerprints, then fixed automatically by Claude agents in three nested loops — an inner loop testing hypotheses in seconds in a sandbox, a middle loop checking fixes on shadowed production traffic, and an outer loop recording lessons as rules for later agents. In April, the Rust version already passed about 98% of roughly 700 integration tests, yet only about a quarter of real production inputs produced a byte-identical prompt, showing that passing tests is not the same as behaving identically. The team also notes the figures cover different scopes: the CPU number comes from a single region, the memory number covers all of production, and the latency number covers Claude Code requests from September 7 to 21.

An earlier partial rewrite saved only 8% of CPU

The team had first tried a partial rewrite: moving only the parsing of model output into Rust, called from Python. That cut CPU by only about 8% to 10%, while each token had to cross the Python-Rust boundary three times. The full rewrite changes the picture, but Anthropic did not say whether it shrank its server fleet or used the freed capacity to absorb traffic growth. Notably, in an October interview the head of platform engineering had cited a CPU reduction of roughly 40% to 50%; the official blog figure of about 70% is more ambitious. (Sources: Anthropic; InfoWorld)

💬 Comments

No comments yet. Be the first!