Anthropic Migrates Claude's Core API to Rust, Validating It Against the Live Python Service

On November 25, Anthropic described how it migrated Claude's Messages API from Python to Rust. The API is the primary gateway through which external developers use Claude, and Anthropic's Claude Code and Cowork products use it as well.
General user traffic moved to the Rust version in September 2026. In performance measurements published by the company, CPU usage per request fell by about 70% in one region from August through October 2026. Memory use per request, aggregated across the production environment, fell by more than 80%.
In a September 2026 measurement of customer Claude Code requests, median time to first token, a unit of text processed by the model, also decreased by about 20%.
Anthropic Messages API: Performance Improvements From Rust Migration (2026)
| Metric | Change | Measurement scope / period |
|---|---|---|
| CPU usage 1RequestPer | Reduced by about 70% | One region August–October |
| Memory usage 1RequestPer | Reduced by more than 80% | Entire production environment August–October |
| Time to first token Median latency | Reduced by about 20% | Claude Code CustomerRequest September |
When the Messages API was first developed in 2023, it was a relatively simple relay between requests to the model and its responses. Anthropic says API request volume, including internal use, grew about 1,800x from early 2024 through fall 2026.
By late 2025, the API needed to validate inputs, generate prompts for the model, perform safety checks, and separate model output into text, reasoning content, and tool calls. Creating and freeing Python objects also added overhead to each operation.
Anthropic initially rewrote only the model-output parsing process in Rust. This partial migration in March 2026 reduced API CPU use by about 8% to 10%. However, tokens making up a response then crossed the boundary between Python and Rust three times, creating new cross-language overhead.
After weighing the expected improvement against implementation complexity, Anthropic expanded the migration. Claude wrote an initial version of the main request-processing path in about one week. Making it usable as a real service required confirming that its behavior matched the Python version.
What happens when AI writes both code and tests
Anthropic had about 700 integration tests. They ran the Python API inside a test process and simulated billing and rate-limit handling. The tests also needed changes for the Rust migration.
Claude participated in modifying both the implementation and the tests. When Anthropic audited the migrated tests, it found that more than 100 assertions had been weakened.
Changing the program so that tests pass and loosening the tests' passing criteria to match the program are different actions. Delegating implementation and validation together creates a need for a process that distinguishes between them.
In Anthropic's April 2026 validation, the Rust version passed about 98% of the tests. Yet among compared production requests, only about one-quarter produced input-processing results that matched the Python version.
For example, in JSON data describing tool calls, the Python version escaped some characters such as emoji, replacing them with codes, while the Rust version wrote the characters directly. This created a difference of a few bytes in the prompt sent to the model. Even when processing succeeds, it can produce a different AI response.
Tests count each case once. In production, a defect in a frequently used feature can create differences across many requests. A test pass rate alone has limits as a measure of behavior in real use.
Anthropic Messages API: Migration and Validation From Python to Rust (2026)
| Stage | Comparison / task | Result /decision |
|---|---|---|
| Testing | About 700 integration tests | April: about 98% passed Found by audit WeakenedValidation conditions More than 100 |
| Comparison | Old and new versions in productionComparison Inference runs once Output reused Rate limits and billing countedOnce | April input processingMatch rate ComparisonTargetAbout one-quarter Without reading inputs or outputs Difference position and lengthRecorded |
| Reproduction | Isolated environment Claude reproduces and fixes | No model execution InputComparison: Less than one second Regression test added |
| Review | Before production validation Developer reviews proposed fix | Whether it can withstand real-world usedecision Example:ComparisonEven if it passesRejected |
| Verification | Check for the fix in productionComparison | If differences remain, return toBack |
| Sharing | RejectedReason and fix methodRecorded | Shared with subsequent AI Rules and testsUpdated |
Using the production Python version as the baseline
Anthropic performed shadow testing with the live Python version as its baseline. It processed real requests through both APIs and compared the results at each stage.
Claude can produce different responses even when given identical input. That makes it difficult to distinguish a difference in API processing from variation in the model's answer.
Anthropic therefore ran model inference only once and reused the resulting output in the Rust version. It also counted each request toward rate limits and billing only once. Every stage was compared precisely, from accepting input and determining the applicable settings through prompt generation, output classification, and usage recording.
To investigate differences without developers directly reading customer input or Claude responses, the system recorded where in the processing path a difference began, how much the data length differed, and similar characteristics. Grouping records with matching features allowed differences likely caused by the same defect to be classified together.
Developers judge the fixes selected by AI
Claude's worker agents inferred causes from difference records and created requests and mock responses to reproduce them in an isolated environment. A test comparing input processing without calling the model completed in less than one second. The agents also added regression tests that failed with the pre-fix Rust version and passed after the fix.
Proposed fixes proceeded to production-traffic validation after developer review. If differences remained after applying a fix, the process returned to investigation in the isolated environment.
In mid-May 2026, the Rust version omitted the description of the web search tool from its prompt. The Python version retrieved that description from an internal service. Claude proposed copying the text into a file and loading it from the Rust version, and the change passed the isolated comparison.
Developers rejected the proposal. Operating the real service required the Rust version to call the internal service as well. Producing matching comparison results does not by itself establish that an implementation is suitable for production.
The reason for rejection and the correct method were recorded and passed to later agents. Lessons from validation and review were also incorporated into rules and tests. Anthropic introduced a check requiring changes to the Python version to include corresponding Rust changes or an approved exception.
Delegating fixes to AI required both a validation environment capable of finding errors and developer judgment about what should be accepted as the correct implementation.
The scope of work that can be delegated to AI may depend not only on what AI can build, but also on how thoroughly the result can be verified.
KioskNews shows a cleaned-up reading view extracted from the publisher’s page — the original always lives on their site, not ours.