Anthropic Used Claude AI Agents to Rewrite Its Messages API in Rust
Anthropic completed a migration of its core Messages API from Python to Rust in September 2026, using Claude AI agents to write and verify the new code. The migration cut CPU usage per request by about 70 percent and improved median time to first token by 20 percent. The project took five months and was completed without service downtime.

Anthropic completed a migration of its core Messages API from Python to Rust in September 2026, using Claude AI agents to write and verify the new code. The company published details of the project on November 25, 2026.
The Messages API serves as the primary gateway for Claude and associated applications including Claude Code and Cowork. Traffic on the API grew 1,800-fold between early 2024 and fall 2026, making the performance overhead of the original Python-based service unsustainable.
Claude wrote the initial version of the Rust API core in approximately one week. By May 2026, Claude was responsible for writing over 80 percent of the code merged at Anthropic.
The verification process used three nested loops. An inner loop ran agents in a sandbox to debug discrepancies and propose fixes in seconds. An outer loop validated fixes against production traffic to catch edge cases missed in the sandbox. A memory loop encoded lessons from human reviews into rules that guided subsequent agent behavior.
Traditional testing proved insufficient. While the Rust version passed 98 percent of existing tests in April 2026, only about 25 percent of inputs matched production traffic parity. An audit found over 100 weakened assertions in the ported tests.
Anthropic solved this by running requests through both the Python and Rust APIs simultaneously, comparing responses while recording only the fingerprint of discrepancies to protect user privacy.
The final results: approximately 70 percent less CPU usage per request, more than 80 percent less memory usage, and a 20 percent improvement in median time to first token. The migration was completed without service downtime or feature freezes.

