Anthropic rebuilt the Claude Messages API in Rust — 70% less CPU

A computer monitor in a dark room showing lines of Python code with green syntax highlighting

Photo: Hippopx (public domain). Illustrative image.

The short version. Anthropic has rebuilt the Messages API — the main route through which customers, Claude Code and Cowork reach Claude — in Rust, replacing the Python service it was built on in 2023. Anthropic says the Rust version uses about 70% less CPU per request, uses more than 80% less memory, and cuts median time to first token by about 20%. Public traffic moved to the new version in September 2026, without the service going offline or feature work freezing. The performance figures are Anthropic’s own reported measurements, not independent benchmarks.

Why the move became unavoidable. When the API launched it was, in one engineer’s words, “basically a request forwarder”: a request went in, the model replied. By late 2025 every request had to be validated, converted into a prompt, tokenised and screened by safety classifiers, and every reply had to be sorted into text, thinking and tool calls as it streamed back. Python added overhead at each of those steps. Meanwhile traffic grew roughly 1,800 times from early 2024 to autumn 2026 — far beyond what the original Python service was built for. Anthropic first tried the cautious route, rewriting only the output-parsing code in Rust and calling it from Python; that cut CPU use by about 8% to 10%, but the gains did not justify tokens crossing between the two languages three times.

Claude wrote the first version in about a week. The full rewrite only became practical because Claude itself could do the generating: by May 2026, Anthropic says, Claude was writing more than 80% of the code the company merged. Claude produced a first version of the core request path in about a week. But generating the code was the easy part. Proving the new version behaved exactly like the old one — which kept changing as new models and features shipped — was the hard part.

The tests were not enough. Anthropic started with its roughly 700 integration tests, but two problems limited them. First, the tests were coupled to the Python implementation, so they had to be rewritten alongside the code — and an audit found more than 100 weakened assertions. Second, the tests were incomplete: with dozens of features, no test suite could cover production behaviour. The gap was stark. In April 2026 the Rust API passed about 98% of its tests, yet matched the Python API on only about a quarter of real production requests. One cause was mundane: Python escapes characters such as emoji in JSON tool calls, while Rust wrote them as-is, so the two prompts differed by a few bytes.

Production became the verifier. Anthropic’s answer was to turn the live Python API into an oracle. Real requests ran through the old API, and the model output was replayed to the Rust version, so every stage before and after the model call could be compared exactly — without any request counting twice towards a customer’s limits or bill. To protect privacy, the comparison never read request or reply text: it recorded only the shape of each difference, such as where it happened and how large it was. Differences were grouped by fingerprint, and Claude agents were dispatched to fix each new kind, with human engineers reviewing fixes at the boundary between a fast sandbox loop and a slower production loop. The system caught real errors, including a missing web-search tool description that an agent tried to patch with a shortcut an engineer rejected — a verifier can tell an agent whether outputs match, Anthropic notes, but not whether a fix is good enough to ship. For readers weighing what API calls actually cost, our guide explains how AI API pricing works.

What changes for users. In practice, little visibly changes: the API behaves the same, and the gain is speed and efficiency at Anthropic’s scale — cheaper requests to serve, and a faster first token for everyone calling the API. Anthropic’s deeper lesson is about verification itself: as AI writes more production code, the bottleneck moves from generating code to proving it correct. The company reached the same conclusion in a different setting this week, when its Siren sandbox-escape test put Claude’s safety checks through a live adversarial trial.

Sources

  • Anthropic
  • Claude
  • Rust
  • Messages API
  • AI infrastructure

Related articles

AI News

AI Chatbots Sent Shoppers to Fake Stores in Up to 15% of Answers, Study Finds

A study by brand-protection firm Podqi asked ChatGPT, Gemini and Perplexity shopping questions about 151 brands and collected 6,795 answers. Risky sites — fake stores, counterfeit sellers and dead domains — appeared in 15% of Perplexity's answers, 8% of ChatGPT's and 4% of Gemini's.

· AI chatbots, online shopping, ChatGPT, Perplexity, Gemini, scams, study