CPU use down about 70%, time to first token down about 20%

Anthropic said on Nov. 25 (Nov. 26 Japan time) on its engineering blog how it migrated the "Messages API," used to access Claude from outside, from the Python programming language to Rust. The Messages API is the primary way customers, as well as the company's own apps such as "Claude Code" and "Cowork," reach Claude.

According to the company, the Rust API uses about 70% less CPU per request and cuts the median time until the first token (unit of text) of a reply arrives by about 20%. It said it made the move without ever taking the service offline or freezing feature development. According to a figure caption in the blog, public traffic moved to the Rust version in September 2026.

Anthropic's official account @AnthropicAI announced the blog post on X at 1:26 a.m. Nov. 26 Japan time.

We recently migrated our Messages API from Python to Rust. On our engineering blog, we share how we used the existing service to verify the new one, with teams of Claude agents tracking down and fixing differences between the two versions.

Traffic grew about 1,800 times, and a partial rewrite was not enough

The Messages API was built in Python in 2023. At first it simply passed requests to the model and returned the results, and an engineer at the time called it "basically a request forwarder." As features were added, it came to share dependencies with Python libraries owned by the research and inference teams, which made it hard to move to another language.

By late 2025, each request had to be validated, converted into a prompt (the instructions to the AI), split into tokens and screened by safety classifiers, and Python added overhead at each of those steps. The company said API traffic grew roughly 1,800 times from early 2024 to fall 2026.

The company first rewrote only the slow parts in Rust. It rewrote the code that parses the model's output in Rust and called it from Python, reducing the API's CPU usage by about 8% to 10%. But each token now crossed between Python and Rust three times, and the gains did not justify the added complexity, it said. The blog also recounts that in 2024, after one engineer suggested moving to Go or Rust, another settled the question for the time being by replying, "We are not rewriting the API in go or rust!"

Behind the decision to do a full rewrite was Claude's growing capability. According to the company, by May 2026 Claude was writing more than 80% of the code Anthropic merged. Claude also wrote the first version of the Rust API's core request path in about a week.

Tests passed about 98%, but only about a quarter of inputs matched in production

While writing code had become faster, it was hard to verify that the new API behaved the same as the original. There were about 700 existing integration tests, but they were written around the Python API's implementation. The tests had to be rewritten along with the code, and an audit of the ported tests found more than 100 places where assertions had been weakened.

Testing every combination is also hard. The company said just 20 on-off settings make more than a million combinations, which would take 12 days for a single model at one second per test.

In fact, while the Rust version passed about 98% of its tests in April, the input sent to the model matched on only about a quarter of production traffic. For example, when Python wrote JSON tool calls it replaced certain characters such as emoji with text codes, while the Rust version wrote them as is, so the prompts differed by a few bytes. In production, a single common bug also causes a mismatch on every request where it is triggered, which added to the gap with the tests, the company said.

Running Python version as "correct," without reading users' text

The company therefore used the running Python API itself as the reference for correct behavior. This is a method called "shadowing," in which the same production requests are processed by both the old and new versions and the results are compared.

Processing the same request twice, however, risks counting it twice toward usage limits and billing. Claude can also return different replies to the same input. So the company ran the model only once, replayed its output to the Rust version, and checked whether the results of every step before and after the model call matched exactly.

The company said it made the comparison without reading users' requests or Claude's replies. Instead of the text, it recorded at which step of processing, in which part of the prompt and by how much a difference occurred. Because each bug leaves the same "fingerprint," the records could be grouped to tell bugs apart, it said.

Teams of agents traced causes, and humans reviewed

A single bug could produce hundreds of thousands of difference records. Every 10 to 30 minutes, a script grouped the records by kind and alerted a coordinating Claude agent when a new kind appeared. The coordinator assigned a worker agent to each kind and opened a thread in a shared Slack channel so engineers could follow along and steer.

Fixes were checked in three "loops." In the inner loop, each agent worked in an isolated cloud environment (sandbox), wrote its own requests matching its hypothesis about the cause, and ran them through both versions to reproduce the difference. Because the input comparison does not call the model, it took under a second, shortening checks that had initially taken hours or days. In the outer loop, engineers reviewed and approved fixes, and builds with and without each fix were compared on production traffic to confirm whether the difference had disappeared.

As a reason for making human review a gate, the company cited an example from mid-May. The description of the web search tool was missing from the Rust version's prompts. An agent proposed a shortcut fix that copied the description into files for the Rust version to read, and it passed verification, but an engineer rejected it as throwaway code. The correct fix was to have the Rust version call the internal service that supplies the description, which took weeks to build. The company said a verifier can tell an agent whether the outputs matched, but not whether a fix is good enough to ship.

In the third, "memory" loop, comments from reviews were recorded and applied to every agent that followed. After one agent ported Python's behavior based on a guess, an engineer made it a rule to port exactly what Python did, and another agent checked the existing code against that rule and found seven more places that relied on a guess. In June an agent grouped about 60 of the team's review comments into proposed rules, which an engineer edited and added to "CLAUDE.md." A merge check was also added requiring anyone changing the Python code to make a matching change in Rust or request an exemption.

Company says verification is the new constraint

As a lesson, the company said that once writing code is no longer the constraint, work such as large migrations depends on how quickly the results can be verified. When tests or formal verification are not enough, a production system itself can also serve as the reference, it said. The engineers' role started with chasing differences themselves and gradually shifted to writing the rules and checks the agents work within, it said.

The blog was written by six people, including Lance Martin and Jake Eaton. All performance figures are Anthropic's own, and the period and conditions of the measurements were not given. The blog does not say whether the API's pricing or specifications will change.