Anthropic says its Messages API, the route customers and its own Claude Code and Cowork apps use to reach Claude, now runs on Rust instead of Python. In an engineering post published on 25 November (US), the company reports about 70% less CPU per request and a median time to first token, the wait before the first word of a reply appears, that’s about 20% lower. It says it got there without taking the service offline or freezing feature development.
The reusable part is how Anthropic checked the port. Claude wrote a first version of the core request path in about a week, the company says, but trusting it took much longer. Anthropic ran the live Python API beside the Rust one, compared every step on production traffic, and sent agents after each difference. I covered the wider move in why Bun, GitHub, Ubuntu and Cloudflare moved to Rust; this one comes from the company that builds the model the API serves.
1,800x
API traffic growth, early 2024 to fall 2026
98%
of tests passed in April
99.6%
of live inputs matched by August
Why Anthropic moved
Anthropic built the Messages API in 2023 in Python, which its research teams already used. One engineer at the time called it “basically a request forwarder”, the post says. It then picked up shared dependencies on Python libraries owned by the research and inference teams, so a change of language meant rebuilding logging, metrics and tooling.
By late 2025 every request had to be validated, turned into the prompt, tokenised and screened by safety classifiers, and every reply had to be sorted as it streamed into text, thinking and tool calls. Anthropic says Python added overhead at each of those steps, and traffic had grown roughly 1,800 times since early 2024.
We are not rewriting the API in go or rust!
An Anthropic engineer in 2024, as quoted in Anthropic’s post
Anthropic’s first answer was the standard one: rewrite only the slow part. In March 2026 it rewrote the code that parses a model’s output in Rust and called it from Python, which cut CPU use by about 8% to 10%. Each token then crossed between the two languages three times, and the company judged the gain too small for the added complexity.
What changed its mind was the cost of writing code. By May 2026 Claude was writing more than 80% of the code Anthropic merged, the company says, so a full rewrite no longer needed years of engineer time. Checking the result, not producing it, became the hard part.
Why 98% of tests passing wasn’t enough
Anthropic started with about 700 existing integration tests and found two problems. They ran the Python API inside the test’s own process and mocked services such as billing and rate limiting in Python’s memory, so the tests had to change along with the code, and Claude helped change both. An audit of the ported tests turned up more than 100 weakened assertions, which meant a pass could show the code was right or that the test had been loosened.
The tests were also incomplete. The Messages API has dozens of features, and Anthropic says 20 on/off options alone make over a million combinations, or 12 days of tests at one second each for a single model.
The gap showed up fast. The Rust API passed about 98% of its tests in April, yet only about a quarter of inputs matched Python on production traffic. Anthropic’s chart has the match rate starting at 24%, dropping to 6.5% in early May and reaching 99.6% by August; the comparison began on Anthropic’s own traffic and moved to a wider sample.

Production traffic exposed cases the tests never covered. When Python writes JSON tool calls, it replaces certain characters, an emoji for example, with text codes; Rust wrote them as they were, so the two prompts differed by a few bytes. Production also weights bugs differently. A test counts a bug once, but live traffic counts it in every request that triggers it, so one common bug can cause a huge number of mismatches.
How the live API became the checker
Running requests through old and new code and comparing the results is called shadowing. Anthropic says the usual shadowing tools assume a request can safely run twice and that the service gives the same answer each time. Neither holds for the Messages API: a request must count once toward a customer’s limits and bill, and Claude can reply differently to the same input.
So Anthropic ran the model once and replayed its output to Rust, then compared every stage before and after the model call. That matters because Claude accepts almost any prompt. A small deviation doesn’t cause an error; it quietly changes the reply.

Anthropic says it couldn’t read customer requests or Claude’s replies, so it recorded the shape of each difference instead. Two techniques did the work.
- Checkpointing. Both versions handle a request in the same steps: accept or reject it, resolve its settings, build the prompt. Anthropic compared the result of each step, and the prompt piece by piece. The first place they differ shows roughly where the Rust code departs from production.
- Fingerprints. Anthropic recorded where in the prompt a difference starts and how far the lengths differ. One bug tends to leave the same fingerprint on every request it affects, so hundreds of thousands of near-identical records collapse into one bug. Fixing the biggest fingerprint can reveal older ones hiding behind it.
The output of that system is a small record with no customer text in it. Here’s Anthropic’s example, which it says uses made-up values:
step: build prompt ← where in the code
piece: 2 ← where in the prompt
first diff: byte 17 ← fingerprint
python: 190 bytes ← fingerprint
rust: 190 bytes ← fingerprint
Three loops of agents
A single bug could produce hundreds of thousands of records, so Anthropic didn’t send each one to an agent. A script ran every 10 to 30 minutes, grouped records by which fields differed, and alerted a coordinating Claude agent only when it saw a new kind. The coordinator gave each new kind to a worker agent and opened a thread in a shared Slack channel where engineers could follow along and steer.
The inner loop is the fast one. In April, agents guessed a root cause from a record, opened a pull request and waited for a deployment to staging, so feedback took hours or days. Anthropic moved them into cloud sandboxes holding both codebases, with local checks. The input check builds the prompt each version would send and shows the difference without calling the model, so it takes under a second. Anthropic later added an output check that runs both versions against a fake model with a scripted reply, such as a tool call.
Because agents only saw fingerprints, each one wrote its own request to try to reproduce a difference. If both versions matched, the guess was wrong. If they differed the way the record said, the agent edited the Rust until they matched and added a test that failed on the old code. Fixes crossed into the next loop only after human review of the pull request.
The outer loop is the slow one. Once a fix was deployed, shadowed live traffic showed whether its fingerprint disappeared. Anthropic logged non-text facts about each request, such as the model and features used (prompt caching, tools, extended thinking), so agents could compare requests of the same kind on builds with and without the fix.

The memory loop is where the lessons stuck. In mid-May one of the largest remaining differences came from web search. Production fetched the search tool’s description from an internal service that Rust didn’t call yet, so the text was missing from prompts. An agent copied the text into files Rust could read, the prompts matched and the local check passed. An engineer rejected the fix: Rust would have to call the service before launch, and the shortcut would be thrown away.
Anthropic’s reading is that the verifier rewarded matching outputs, and the agent found the cheapest way to produce them. The agent saved a note in memory with the decision and the right fix. Building that service call took weeks; in the meantime, other agents recognised related records, some with new fingerprints, and linked them to the known bug instead of writing another workaround.
Other corrections became rules. After an agent guessed at Python’s behaviour, an engineer made it a rule to port exactly what Python did, and an agent then found seven more places where the port had relied on a guess. In June an agent grouped about 60 review comments into proposed rules, which an engineer edited and approved for CLAUDE.md. Some lessons became permanent checks: tests that fail when Rust drifts from Python, lints that ban patterns reviewers kept flagging, and a merge check that makes anyone changing the Python code make a matching Rust change or ask for an exemption.
What changed in production
| Measure | Anthropic’s reported change | Scope Anthropic gives |
|---|---|---|
| CPU per request | About 70% lower | One region, August to October |
| Memory per request | More than 80% lower | All of production, August to October |
| Median time to first token | About 20% lower | Customers’ Claude Code requests, roughly 7 to 21 September |
Public traffic moved to Rust in September 2026. Anthropic says the fall in first-token time before the chart’s first marker came while almost all of those requests were still on Python. Merged changes to the Rust code rose from under 100 per two weeks in April to roughly 1,000 by late June, then to more than 3,000 in the fortnight starting 10 August, though Anthropic says not all of that is migration work.

How it compares with other Rust moves
Anthropic isn’t the first company to move a hot service to Rust, and the reasons differ. Each figure below is the company’s own.
| Project | The move | Reported result | What the source credits |
|---|---|---|---|
| Anthropic Messages API | Python to Rust; public traffic moved September 2026 | About 70% less CPU per request; median first token about 20% lower | Less per-request overhead, checked on shadowed live traffic |
| Cloudflare Pingora | NGINX and Lua proxy to Rust, September 2022 | About 70% less CPU and 67% less memory; over 1 trillion requests a day | Sharing connections across threads, so fewer new connections |
| Cloudflare FL2 | FL1, built on NGINX and LuaJIT, to Rust, September 2025 | Less than half the CPU, much less than half the memory, sites 10 ms faster at the median | One codebase, with each request running only the modules it needs |
| Discord Read States | Go to Rust, February 2020 | Go’s garbage collector caused latency spikes about every two minutes; cache raised to 8 million Read States | No garbage collector |
| Bun | Zig to Rust in 11 days, about US$165,000 at API pricing | 128 bugs fixed that reproduced in Bun 1.3.14, per Jarred Sumner | The existing test suite as judge |
| GitHub Copilot runtime | TypeScript on Node to Rust in 14.5 weeks | One turn 18 times faster; memory for ten clients down 91%, per Stephen Toub | An embeddable runtime, with end-to-end tests |
What sets Anthropic’s account apart is the checker. Discord’s 2020 launch relied on load testing and a single canary node, where it found a few missing edge cases before rolling out to the fleet. Bun had a test suite written in TypeScript that could judge both versions; Anthropic cites Bun’s move as the example, and Sumner has disclosed that Anthropic acquired Bun in December 2025. Anthropic had about 700 tests tied to its Python code, so it made production the oracle. It also says the common shadowing tools, GitHub’s Scientist and Twitter’s Diffy among them, didn’t fit a service that bills each request once and answers differently each time.
Anthropic’s examples of differences include a rejected field, a 1M limit read as 200K, a missing tool description, stripped newlines and missing usage fields. Those are logic gaps, not memory bugs, and Microsoft’s Stephen Toub reported the same kind in the Copilot runtime port: he said dozens of regressions all compiled and merged, and that “if it compiles, it’s correct” is useful only as a joke; the earlier report has the detail. Microsoft’s own Copilot Cowork move is another Python to Rust case.
What builders can take from it
- When tests can’t define “correct”, use the old system as the oracle and compare it with the new one on real traffic.
- If you can’t read the data, record the shape of each difference: the step, the piece and the byte where they first part ways.
- For a non-deterministic service, run the model once and replay its output to both versions.
- Keep a human at the seam between sandbox and production. A verifier says whether outputs matched, not whether the fix should ship.
- Write corrections down as rules, lints and merge checks, so nobody makes the same correction twice.
Anthropic says its engineers started inside the inner loop, chasing differences themselves, then moved to the seam to review fixes in Slack, and finally to writing the rules and checks the agents work within. Its first lesson is the line the post leads its list with: “Verification is the new bottleneck.”
Sources
- Anthropic, “Migrating our Messages API to Rust”, 25 November 2026
- Cloudflare, “How we built Pingora”, 14 September 2022
- Cloudflare, “Cloudflare just got faster and more secure, powered by Rust”, 26 September 2025
- Discord, “Why Discord is switching from Go to Rust”, 4 February 2020
- Bun, “Bun in Rust”
- Anthropic, Messages API documentation
Discover more from Sulat AI & Tech News
Subscribe to get the latest posts sent to your email.




