Anthropic rewrites the Claude API in Rust for 20% faster first tokens

Anthropic has moved the Claude Messages API, the interface that every developer request and the company's own apps pass through, from Python to Rust. In an engineering post published on November 25, 2026, the company said public traffic switched to the Rust service in September 2026 and reported about 70% less CPU per request, more than 80% less memory per request and roughly 20% lower median time to first token, the delay between sending a request and receiving the first streamed token of the reply.
The post, titled "Migrating our Messages API to Rust", describes a rewrite in which Claude wrote most of the new code while Anthropic engineers built the checks that decided whether that code was correct. The company's own production system served as the reference: every difference between the Python and Rust versions on live traffic was recorded, traced and fixed until the two produced the same result. Anthropic wrote that the goal was to ship the new API without ever taking the service offline.
The scale behind the decision is large. According to Anthropic, API traffic grew roughly 1,800 times between early 2024 and fall 2026, while the service itself was still the Python application first built in 2023. Claude Code and Claude Cowork reach the models through the same API, so the change affects first-party products as well as third-party applications built on the Claude Platform. The 20% latency figure was measured on customers' Claude Code requests over a shorter window than the other metrics.
··········
WHAT THE CLAUDE MESSAGES API DOES ON EVERY REQUEST.
Anthropic's description of the request path explains why the language of the serving layer had become a cost. Before the model writes anything, the API validates the request, converts it into a prompt the model can read, tokenizes that prompt and runs it through safety classifiers. While the model generates its answer one token at a time, the API sorts the output into text, thinking and tool calls, streams those pieces to the customer and counts usage for rate limits and billing.
Each of those steps adds a small amount of work per request and, during generation, per token. In Python that overhead accumulated across billions of requests. Anthropic said an earlier attempt to fix the problem piece by piece, rewriting only the output parser in Rust in March 2026, reduced CPU use by about 8% to 10%. The company judged the gain too small for the complexity it introduced, because each generated token crossed between Python and Rust three times. The post also recalls that in 2024 the suggestion of moving to Go or Rust had been rejected outright.
The full rewrite changed that calculation. According to the post, Claude produced the first version of the core request path in about a week, and by May 2026 Claude was writing more than 80% of the code Anthropic merged across the company. Writing the code was no longer the slow part of the project. Proving that the new service behaved exactly like the old one became the main engineering problem.
··········
HOW ANTHROPIC VERIFIED THE RUST VERSION OF THE CLAUDE API.
The existing test suite turned out to be a weak guide. Anthropic had about 700 integration tests, many of them coupled to details of the Python implementation, and an audit of the ported tests found more than 100 assertions that had been weakened along the way. The company also pointed to a combinatorial limit: 20 binary request options produce more than a million combinations, which would take about 12 days to test at one second per case for a single model.
The gap between tests and reality showed up quickly. In April 2026 the Rust API passed about 98% of its tests, yet when Anthropic began comparing it against production traffic in late April, only about 24% of inputs matched the Python output. The match rate then fell to 6.5% in early May as the comparison was widened to cover more of each request, before climbing to 99.6% by August.
Because Claude's replies are not deterministic, the team could not simply send the same request to both services and compare the answers. Anthropic ran the model once and replayed that single output through both versions, checking each stage before and after the model call, step by step and piece by piece within the prompt. A request also had to count only once toward a customer's limits and bill.
Anthropic said engineers could not read customer requests during this process. The comparison logged only the shape of each difference: the processing step, the piece of the prompt, the first byte that differed and the lengths of both versions, plus a fingerprint and metadata about which model and features were involved, such as prompt caching, tools or extended thinking. The example given in the post is a prompt-building difference in piece 2, first diverging at byte 17, with both versions 190 bytes long.
··········
THE CLAUDE AGENT LOOPS BEHIND THE RUST MIGRATION.
The verification work ran as three connected loops. In the inner loop, agents worked in cloud sandboxes with local checks that compared inputs and outputs of both versions. The input checks ran in under a second and never called the model, so an agent could form a hypothesis about a difference, write a request that triggered it and edit the Rust code until both versions agreed, then add a permanent test.
In the outer loop, approved fixes were deployed to production, where shadowed traffic showed whether each difference fingerprint disappeared. A script ran every 10 to 30 minutes and alerted the coordinating agent only when a new kind of difference appeared, a filter that Anthropic described as necessary because a single bug could generate hundreds of thousands of nearly identical records.
The third loop captured engineering judgment. Corrections from engineers were turned into shared rules, searches and tests. In one case, a single correction led an agent to find seven more places where the port relied on a guess. In June an agent condensed about 60 review comments into proposed rules for the project's CLAUDE.md file. Anthropic also described a limit of the approach: a verifier rewards matching outputs, so an agent once proposed a throwaway workaround for web search tool descriptions, which an engineer rejected.
........
Period (2026) | Merged changes per two weeks | Production input match |
Late April | Under 100 | About 24% |
Early May | Not stated | 6.5% |
Late June | About 1,000 | Not stated |
From August 10 | More than 3,000 | 99.6% by August |
Next two periods | Above 2,500 each | Not stated |
........
Anthropic noted that not every merged change in those counts was migration work, that some days were left out of its match-rate chart as misleading and that the scope of the comparison changed over the period.
··········
CLAUDE API PERFORMANCE BEFORE AND AFTER THE RUST SWITCH.
The headline results come with different measurement scopes, which Anthropic stated in its chart captions. The CPU figure comes from one region, the memory figure covers all of production, and the latency figure covers customers' Claude Code requests over a shorter period, around September 7 to 21.
........
Metric | Python API | Rust API | Scope stated by Anthropic |
CPU per request | Baseline | About 70% lower | One region |
Memory per request | Baseline | More than 80% lower | All production |
Median time to first token | Baseline | About 20% lower | Customers' Claude Code requests |
Earlier partial rewrite (March 2026) | Baseline | About 8% to 10% less CPU | Output parser only |
Public traffic | Python service since 2023 | Rust since September 2026 | All public API traffic |
........
Anthropic did not publish absolute values, so the post gives no millisecond figures for time to first token and no server counts. The 20% reduction concerns the median, and the company did not report tail latency. The improvement also applies to the work the API layer performs around the model; the time the model itself spends generating tokens is a separate component that the migration did not claim to change.
··········
WHAT THE RUST MIGRATION CHANGES FOR CLAUDE API DEVELOPERS.
For developers building on the Claude Platform, the migration is already in effect and required no action. Public traffic has run on the Rust service since September 2026, and the post describes no new endpoint, parameter, SDK version or migration step. The project was designed so that the Rust API produced the same prompts, tokenization and output handling as the Python one, which is why the team spent months matching production behavior byte by byte before the switch.
The post does not mention any change to prices, rate limits or usage accounting, and it states that each request had to count once toward a customer's limits and bill under both implementations. Nothing in it concerns Claude models served through Amazon Bedrock or Google Cloud Vertex AI, which the article does not mention. Developers who want the current model list, prices and limits can check our guide to Claude API models, pricing, context windows and rate limits, and the overview of Claude API endpoints, structured outputs and enterprise authentication covers the integration side.
The practical effect is felt most in streaming and agentic use. A coding agent or a multi-step workflow sends many requests in sequence, and the time before the first token arrives is paid on each of them, so a lower median wait shortens every turn of the loop. Applications that stream replies to users see the first words sooner. The lower CPU and memory cost per request also gives Anthropic more serving headroom on the same infrastructure, a relevant point for a service whose traffic grew about 1,800 times in under three years. Anthropic has recently been changing the API in the same direction, for example with the message threads beta that cuts request size in long agent loops.
........
Question | Answer from Anthropic's post |
Who is affected | All public Claude Messages API traffic, including Claude Code and Cowork |
Since when | September 2026 |
Action needed by developers | None described |
Pricing or rate-limit changes | None mentioned |
Measured latency gain | About 20% lower median time to first token (Claude Code requests) |
Bedrock and Vertex AI | Not mentioned |
........
··········
CLAUDE API RUST REWRITE: CONFIRMED RESULTS AND OPEN POINTS.
Anthropic has confirmed that the Claude Messages API now serves public traffic from a Rust implementation, that the switch happened in September 2026 without a service outage being described, and that it cut CPU per request by about 70% in one region and memory per request by more than 80% across production. Median time to first token on customers' Claude Code requests fell by about 20%. The company also documented a verification method that kept customer content unread while tracking the exact location of every difference between the two implementations.
Several points remain undisclosed. Anthropic did not give absolute latency or tail-latency figures, did not say which Claude model wrote the code or how many engineers worked on the project, and did not state whether any Python serving code is still running in production, although the post describes a merge check that required Python changes to have matching Rust changes during the migration. The match-rate data covers inputs; the post gives no equivalent match rate for replies.
The engineering conclusion Anthropic draws is specific to how the project ran. Claude wrote the bulk of a production rewrite in a fraction of the time such a project would normally take, and the scarce resource became the signals that showed whether the code was right. Production traffic, replayed model outputs and difference fingerprints served as those signals, while engineers concentrated on rules, tests and judgment calls such as rejecting the web search workaround.
··········
FOLLOW US FOR MORE.
·····
DATA STUDIOS
·····
datastudios.org




