Anthropic moved its Messages API from Python to Rust, cutting CPU per request by about 70%
Anthropic says it migrated the Messages API, the primary way customers reach Claude, from Python to Rust. The Rust service uses about 70% less CPU per request and cuts median time to first token by about 20%, according to the company. Anthropic used the production Python API as a verifier for the migration.
Anthropic says the Rust version of its Messages API uses about 70% less CPU per request and cuts median time to first token by about 20%. In a post on its research site, the company describes migrating the API from Python to Rust without taking the service offline or freezing feature development. The Messages API is the primary way customers, and Anthropic's own apps such as Claude Code and Cowork, reach Claude.
Why Anthropic migrated
Anthropic built the Messages API in 2023 in Python, which was widely used internally for research code. It began as what one engineer called "basically a request forwarder." Over time it developed shared dependencies with Python libraries owned by the research and inference teams, which made it hard to move.
By late 2025, every request had to be validated, converted into the prompt, tokenized, and screened by safety classifiers. As each reply arrived, the token stream had to be sorted into text, thinking, and tool calls. Anthropic says Python added overhead at each of those steps. From early 2024 to fall 2026, API traffic grew roughly 1,800 times.
Incremental rewrite fell short
Anthropic first tried the standard approach: rewriting only the slow parts. It rewrote the code that parses model output in Rust and called it from Python. That reduced CPU usage by about 8% to 10%, but each token of a reply crossed between Python and Rust three times, adding overhead. The company concluded the gains did not justify the added complexity.
What changed the calculation, Anthropic says, was the falling cost of writing code. By May 2026, Claude was writing more than 80% of the code Anthropic merged. Claude wrote a first version of the API's core request path in about a week. The bottleneck became verification: proving the Rust API behaved like production.
Why verification was hard
Anthropic lists three obstacles:
- The Python API kept changing during the migration, so parity was a moving target.
- Claude can reply nondeterministically to the same request, so a difference between two outputs did not necessarily indicate a bug.
- Anthropic could not read customer requests, so it could not easily see where the two versions diverged.
The company's existing set of about 700 integration tests was not sufficient. The tests were coupled to the Python implementation: they ran the Python API inside the test process and mocked services such as billing and rate limiting in Python memory. Because tests had to change alongside the code, a pass could mean the code was right or that a test had been altered to let wrong code through. An audit of the ported tests found more than 100 weakened assertions.
The tests were also incomplete. Anthropic notes that 20 binary options produce over a million combinations, which it translates to 12 days of tests at one second each, for one model, before varying the prompts. It contrasts this with Bun's move from Zig to Rust, where an independent TypeScript test suite could judge both versions.
The approach: production as the verifier
Because neither a formal rule nor a test suite could define "correct," Anthropic used the existing Messages API as an oracle for parity. According to the company, it turned the production API itself into a verifier, used it to test the Rust version on production traffic, find where the two differed, and automatically dispatch agents to fix those differences.
Reported results
- About 70% less CPU per request on the Rust API.
- About 20% lower median time to first token.
- No service downtime and no freeze on feature development during the migration.
These figures come from Anthropic's own post. No independent measurements were cited.
What this means
Anthropic's account is an example of a team treating verification, not code generation, as the limiting step in an AI-assisted migration. Its tests were weakened during porting, which made them unreliable as a judge, so the company used its running production system as the reference instead. The failed partial rewrite is also a data point: moving only output parsing to Rust cut CPU by about 8% to 10%, well short of the roughly 70% reported for the full migration. For teams migrating live systems, the post's central claim is that a running production service can serve as the check when no external test suite is thorough enough.
Related Articles
Anthropic puts Skills over MCP in public beta in Claude and Claude Code; Tasks and Elicitation reach general availabilit
Anthropic announced on November 24, 2026 that Skills over MCP is in public beta in Claude and Claude Code. Tasks and Elicitation are generally available, and File Uploads will roll out soon.
Users report Claude Opus 5.6 quietly rolled out in Claude Code, citing 2 to 3 times Opus efficiency
Users say they were quietly switched to Claude Opus 5.6 inside Claude Code. They report faster responses, overall efficiency of about 2 to 3 times earlier Opus versions, and finer visual and 3D generation than Opus 5.5.
Anthropic adds "Install as app" beta to Claude, turning artifacts into Mac and Windows desktop apps
Anthropic has started rolling out an "Install as app" feature in beta in Claude for Mac and Windows. It lets users create, run and share desktop apps built from Claude artifacts, each with its own icon and window.
Anthropic launches Claude Ship, with PR Steward and Claude Approvals agents in beta for Team and Enterprise
Anthropic announced Claude Ship, a product that lets Claude review, fix, and approve pull requests. Its two new agents, PR Steward and Claude Approvals, launched in beta on November 23, 2026, for Claude Team and Enterprise customers using GitHub repositories.
Comments
Loading...