Claude produced the first version of Anthropic’s new API request path in about a week. Getting that code ready for millions of real customer requests took months.
Anthropic announced Nov. 25 that it had completed the migration of its Messages API from Python to Rust. The company reports approximately 70% less CPU use per request and a 20% reduction in median time to first token, the wait before a model begins responding.
The performance gains are substantial, but Anthropic’s account of the project reveals a harder problem with AI-generated software: Writing working code is one thing. Proving that it behaves correctly under real-world conditions is another.
Why Anthropic rebuilt its Messages API in Rust
The Messages API handles requests from Anthropic’s customers and products such as Claude Code and Cowork.
According to Anthropic’s engineering report, traffic through the service grew roughly 1,800-fold between early 2024 and fall 2026.
The original Python implementation had become expensive to run. Each request involved validation, tokenization, safety checks, and processing model responses, with Python adding computational overhead throughout the process.
Anthropic initially tried replacing only the code that processed model output with Rust. That reduced CPU usage by approximately 8% to 10%.
But the hybrid design introduced another problem: Each generated token had to cross between Python and Rust three times, adding complexity and overhead.
The company ultimately decided to rebuild the entire request path.
Rust offers low-level performance and memory-safety features, making it increasingly attractive for demanding software infrastructure. It also led planned language adoption in the 2026 JetBrains developer survey.
Claude made the larger rewrite more practical. Anthropic says the model produced an initial working implementation of the core request path in roughly a week.
By May 2026, Claude was also writing more than 80% of the code Anthropic merged across the company. That figure describes its broader development work, not specifically the Rust migration.
The completed API uses approximately 70% less CPU per request and more than 80% less memory per request, according to Anthropic.
Median time to first token also fell by roughly 20%. However, the measurements have different scopes: CPU results came from one region, while the response-time improvement was measured using Claude Code requests over a shorter period.
Anthropic completed the migration without taking the service offline or stopping feature development.
Why passing 98% of tests wasn’t enough
By April 2026, Anthropic’s Rust API was passing approximately 98% of its integration tests.
That sounded reassuring until engineers compared it against the Python API on production traffic.
Only about a quarter of real customer inputs initially produced matching results between the two versions.
One problem involved something as small as character encoding. Python escaped certain characters in JSON tool calls, while Rust sometimes preserved them directly. Both implementations could produce valid outputs, but the differences could change what the model received.
Anthropic also found more than 100 weakened assertions among approximately 700 integration tests that had been ported from Python.
Some tests had changed in ways that made incorrect behavior easier to overlook.
That’s an uncomfortable possibility for teams using AI coding agents: An agent can modify an implementation and its tests, leaving a passing test suite that no longer checks everything the original did.
The problem grows with complexity. Anthropic noted that just 20 binary configuration options produce more than one million possible combinations.
Testing every combination would take roughly 12 days at one second per test, before accounting for different prompts.
The company needed a way to compare the new system against real customer activity without exposing private requests or charging customers twice.
How Claude agents checked the Rust rewrite
Anthropic’s solution was to use the existing Python API as a reference.
Both implementations processed the same requests, while the actual AI model ran only once. Its output was then replayed through the Rust system.
That allowed engineers to compare behavior without confusing normal variations in Claude’s responses with programming errors.
They also checked how each version handled requests, built prompts, processed tool calls, and calculated usage.
Instead of exposing private customer messages, the system recorded information about where differences occurred and how large they were.
Claude agents received those records, investigated possible causes, and proposed fixes.
The process operated through three connected checks:
- Fast local testing: Agents recreated problems in isolated environments and checked potential fixes in less than a second.
- Production verification: Approved changes were compared against live traffic to confirm that the original problem had disappeared.
- Continuous learning: Repeated mistakes became new tests, coding rules, and instructions for future agent work.
Human engineers still reviewed proposed changes before deployment.
That oversight caught an especially revealing mistake. When the Rust implementation failed to retrieve a web search tool description, an agent proposed copying the missing text into local files.
The outputs matched, and the automated check passed.
But an engineer rejected the change because Rust still needed to retrieve the description from the original service. The shortcut satisfied the test without properly fixing the system.
What development teams can learn from Anthropic’s migration
Anthropic’s results offer a useful example for organizations considering AI-assisted rewrites, but the company’s performance figures aren’t a guarantee that another Python application will see similar gains.
Before attempting a comparable migration, development teams should consider four steps:
- Measure the existing bottleneck. Profile CPU, memory, latency, and operating costs before choosing a language. Rewriting code that isn’t causing significant overhead may create unnecessary work.
- Test against real behavior. Run the old and new implementations against representative requests. Compare errors, response formats, tool handling, and edge cases, not just whether both versions return successfully.
- Keep verification independent. Review tests modified by AI agents. If the same agent can change both the implementation and the checks, an incorrect result may still appear to pass.
- Make human approval meaningful. Require reviewers to evaluate whether a proposed fix is maintainable and architecturally sound, not simply whether it satisfies an automated comparison.
For a smaller team, that might mean rewriting one API endpoint, comparing both implementations against recorded test requests, and checking the results before expanding.
A full migration may still make sense, but its cost includes validation infrastructure, engineering reviews, and the work of keeping two implementations aligned during the transition.
Anthropic’s experience also shows that AI agents can help automate that verification work once developers establish reliable checks.
The company’s production traffic had fully moved to Rust by September 2026. Its November engineering report puts numbers behind the outcome: lower computing costs, faster responses, and a migration completed without taking the API offline.
Claude made writing the replacement code faster. The months spent checking that code are what made it possible to put the new system into production.
Also read: Claude’s new desktop-app feature lets users turn AI-generated tools into applications for Mac and Windows, with new permissions and oversight considerations.