Skip to content
Economy Media Stay Informed Anytime, Anywhere
Tech

Anthropic Moves Its Messages API From Python to Rust

Anthropic says its Messages API now runs on Rust, using about 70% less CPU per request, after a migration largely written by Claude.

CAMPUS - Military Data Center
Photo: Welcome to Switzerland backstage! via Flickr, CC BY 2.0

Anthropic has moved its Messages API, the main way customers and its own apps reach the Claude AI models, from Python to Rust, the company said in an engineering post published Wednesday. Anthropic says the new version uses about 70% less CPU per request, and that Claude wrote much of the code.

What happened

According to Anthropic, the Messages API was built in 2023 in Python and also serves its own products, including Claude Code. The company said API traffic grew roughly 1,800 times from early 2024 to fall 2026, and that Python added overhead to each request, such as creating objects, freeing memory and handing off tasks.

Anthropic said it first tried a partial step in March 2026, rewriting only the output-parsing code in Rust and calling it from Python. That cut CPU use by about 8% to 10%, but the company said the gains did not justify the added complexity, because each token crossed between the two languages three times. It then pursued a full rewrite. The company said Claude wrote a first version of the core request path in about a week.

For the finished system, Anthropic reported about 70% less CPU per request, more than 80% less memory per request, and about 20% lower median time to first token, measured on customers’ Claude Code requests. It described moving public traffic to Rust in September 2026 as the endpoint of the project.

How Anthropic checked the new system

The central challenge, the company wrote, was proving the new API behaved like the old one. Anthropic said its roughly 700 integration tests were tied to the Python implementation, and that an audit of ported tests found more than 100 weakened assertions. The Rust version passed about 98% of tests in April, yet only about a quarter of inputs matched on production traffic.

So the team used the live Python service as a reference, comparing the two versions on shadowed production traffic. Because Claude’s output varies and requests must be billed once, the model was called a single time and its output replayed to both versions. Engineers could not read customer content; the system recorded only the shape of each difference, such as the step, position and length. Anthropic said the share of matching inputs rose from 24% in late April to 99.6% by August.

The company said AI agents grouped similar differences, investigated each new kind and proposed fixes, with human engineers reviewing them. It said a verifier can show whether outputs matched, but not whether a fix is good enough to ship, and that humans made those judgment calls. Anthropic also said Claude wrote more than 80% of the code it merged by May 2026.

What is not settled

Reporting by Crypto Briefing on Wednesday repeated Anthropic’s 70% figure but also cited an October 27 Latent Space podcast in which Anthropic staff reportedly gave lower estimates of a 40% to 50% CPU decrease and a 10% to 20% improvement in time to first token. Crypto Briefing noted the figures do not perfectly align. Anthropic’s own post gives the higher numbers, and the company has not publicly explained the difference. The performance figures come from Anthropic and have not been independently verified.

Why it matters

Anthropic’s account is one of the more detailed public descriptions of a large company rewriting a core production system with an AI model doing most of the coding. Its main lesson, in the company’s words, is that verification, not generation, had become the bottleneck. The post names its authors as Lance Martin, Jake Eaton, Arvin Aminpour, Emma Webb, Bharat Mediratta and Ravi Trivedi, and does not list their job titles. The company has not announced further migrations.