Anthropic migrated its Messages API from Python to Rust with Claude agents, cutting CPU use per request by about 70%
Anthropic described moving the Messages API, which Claude Code and Cowork also use, from Python to Rust; the hard part was verifying identical behavior.
Sources: Anthropic
In this story
Anthropic described how it moved the Messages API, which Claude Code and Cowork also use, from Python to Rust in an engineering blog post on Nov. 25. The Messages API is the main path through which customers, including Claude Code and Cowork, reach Claude. The company says API traffic grew roughly 1,800 times from early 2024 to fall 2026. Claude wrote a first version of the core request path in about a week. The hard part was verifying parity with the production Python API: the Python code kept changing, Claude’s output is not deterministic, and engineers could not read customer requests.
To handle this, Anthropic ran production traffic through both the Python and Rust versions with shadow comparison: it called the model once and replayed the output to both versions, compared intermediate checkpoints and “fingerprint” records, and had agents fix the differences it found. Progress figures from the company: in April, about 98% of tests passed while about a quarter of production inputs matched; by August, matching reached 99.6%. Reviewers found more than 100 weakened verifications across about 700 integration tests. A shortcut an agent proposed for the web search tool was rejected by an engineer. According to Anthropic, Claude wrote more than 80% of the code the company merged by May 2026, and public traffic moved to Rust in September 2026.
The new version uses about 70% less CPU and more than 80% less memory per request, and median time to first token fell by about 20%. These are Anthropic’s own measurements and their scopes differ: the CPU figure covers a single region, the memory figure all of production, and the time-to-first-token figure Claude Code requests over a shorter period. The post does not give line counts, team size or total duration. Anthropic stresses that engineers reviewed the fixes the agents proposed and rejected some.
Sources
1 source
- “Migrating our Messages API to Rust”Engineering post: traffic growth, verification method, CPU, memory and time-to-first-token results. · anthropic.com
About this story
- Written by
- Yiğit Kasap · JARRUS
- Story date
- On the site
- since Nov. 27, 2026
- Short link
thejarrus.com/en/messages-api-rust- Report an error
- Spotted an error in this story? [email protected] · Instagram