Anthropic’s Rust Migration Cut Messages API CPU Use Per Request by About 70%
Key point
Anthropic migrated its Messages API from Python to Rust, cutting CPU use per request by about 70% and median time to first token by about 20%.
Details
- Anthropic moved its Messages API from Python to Rust after API traffic grew roughly 1,800× from early 2024 to fall 2026; public traffic moved to Rust in September 2026, without taking the service offline or freezing feature development.
- The migration cut CPU use per request by about 70%, memory used per request by more than 80%, and median time to first token by about 20%. CPU was measured in one region, memory across production, and time to first token for customer Claude Code requests over a shorter period.
- Production shadowing exposed gaps that integration tests missed: the Rust API passed about 98% of its tests in April, while about a quarter of inputs initially matched on production traffic. The match rate fell to 6.5% in early May as the comparison scope changed, then reached 99.6% in August; six misleading days were excluded from the graph.
- Verification, not code generation, became the main challenge: integration tests were coupled to the Python implementation, and porting them weakened more than 100 assertions. Just 20 binary options create over 1 million combinations, or 12 days of testing at one second per combination for one model.
Verification loops
- Production requests counted toward limits and billing only once, and the model ran only once; its output was replayed through Rust. The team logged facts about compared requests, but not their text.
- Checkpoints located the first differing processing step or prompt fragment; fingerprints helped distinguish differences by stage, position, and byte or length changes. Scripts grouped logs every 10–30 minutes and alerted a coordinating Claude agent to new kinds of records.
- Agents used local checks that took under one second, then engineers reviewed fixes before they entered the slower shadow-testing loop, which could take hours to days. Human corrections were captured as rules and checks for later agents.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.