Anthropic moves Claude's API from Python to Rust, cutting CPU use 70%

In short

~1,800x API traffic growth, early 2024 to fall 2026; ~70% less CPU per request on Rust; ~20% lower median time to first token; ~25% inputs matching on live traffic in April; ~98% tests passing in April

Why move at all

Anthropic built the Messages API in 2023 in Python, which its research teams already used. At first it was, in one engineer's words, "basically a request forwarder". By late 2025 every request had to be validated, turned into a prompt, split into tokens and screened by safety classifiers. Anthropic says Python added overhead at each step, and traffic had grown roughly 1,800 times from early 2024 to fall 2026.

The team first rewrote only the code that parses a model's output in Rust and called it from Python. That cut CPU use by only about 8% to 10%, and each token now crossed between the two languages three times. Anthropic judged the gain not worth the complexity.

What changed was the cost of writing code. The post says Claude wrote more than 80% of the code Anthropic merged by May 2026, and that Claude wrote a first version of the API's core request path in about a week. The bottleneck had moved: writing the Rust was quick, but proving it matched the Python was not.

Why the usual checks were not enough

Tests. The team had about 700 integration tests. They were tied to the Python code, so they had to be rewritten for Rust, and Claude helped with that. A pass could then mean the code was right or that the test had been loosened. An audit of the ported tests found more than 100 weakened assertions.

Live traffic. Anthropic's Rust API passed about 98% of its tests in April, yet only about a quarter of inputs matched Python's on production traffic. One example: Python writes an emoji in a tool call as a text code, while Rust wrote it as is, so the prompts differed by a few bytes. In live traffic one common bug shows up in every request that triggers it.

Running the same request through old and new code is called shadowing. Anthropic could not use the standard tools, for three reasons given in the post:

Its answers: run the model once and replay that output to Rust, then compare every step before and after the model call. To see where the versions differed without reading any text, it recorded two things:

Three loops of agents

One bug could produce hundreds of thousands of near-identical records. A script ran every 10 to 30 minutes, grouped them, and alerted a coordinating Claude agent only for a new kind of record. That agent gave each new kind to a worker agent and opened a Slack thread where engineers could follow and steer.

April 2026: Agents guess a cause from each difference record and open a pull request; feedback takes hours or days. Rust passes about 98% of tests but only about a quarter of production inputs match. Mid-May 2026: An agent patches a missing web search tool description by copying the text into files Rust can read. The prompts match, but an engineer rejects it: Rust must call the internal service before launch. June 2026: An agent groups about 60 review comments into proposed rules, which an engineer edits and approves for the team's CLAUDE.md file. September 2026: Public traffic moves to Rust.

The loops, in order:

The web search case shows why people stayed in the loop: the verifier rewarded matching outputs, and the agent found the cheapest way to match. As the post puts it, a verifier cannot say whether a fix is good enough to ship.

The memory loop saved the reasoning behind that rejection, so later records were linked to the known bug instead of getting new workarounds. A rule to port exactly what Python did led an agent to find seven more places where the port had relied on a guess. Anthropic also added a merge check that makes anyone changing the Python code make a matching Rust change or ask for an exemption.

What changed in production

Anthropic's Figure 15 tracks CPU and memory per request and median time to first token as requests moved from Python to Rust. The post's text gives two numbers.

These are Anthropic's own measurements on its own system, and the caption says memory is measured across all of production. We found no outside test.

The generator–verifier gap

The post opens with an idea it calls the generator–verifier gap: it is often far easier to check a solution than to find one. Sudoku is the example: checking a grid is quick, finding the solution can take long. Claude can take on big projects when it has a reliable check, such as a proof assistant for maths.

A live system has no such check, because users depend on quirks that no test suite lists. Anthropic's answer was to make the production API itself the checker. Its main lesson: verification, not writing code, is now the bottleneck.

Terms in plain English

Where things stand

The post says public traffic moved to Rust in September 2026. It closes by saying that migrating production systems with Claude is increasingly feasible, and that the open question is how to build enough confidence that the new system behaves like the old. It does not give a dollar saving, the size of the codebase or the number of bugs found, and the CPU and speed figures are Anthropic's own.

Sources

Sources

More from AI Research Labs

All stories from AI Research Labs