Thursday, November 26, 2026 · Goiânia 29°C

Anthropic Swaps Python for Rust in Claude API, Cuts Per-Request CPU Usage by 70%

Claude wrote the first version of the new code in a week, but verifying it did the same as the old one took months

By gnews Newsroom 3 min read

Illustration with repeated gridded colorful circles in two halves on a green background
Anthropic illustration for the Messages API migration report Photo: Divulgação/Anthropic

Anthropic announced this Wednesday (25) that it rewrote the Claude API, known as the Messages API, in Rust, replacing the previous Python implementation. According to the company, the new version uses about 70% less processing power and over 80% less memory per request. Most of the code was written by Claude itself, and public traffic was migrated to the new system in September without any downtime.

The Messages API is the gateway to the model. It handles requests from businesses and developers who use Claude in their products, as well as from Anthropic's own applications, such as Claude Code and Cowork.

Why Anthropic switched languages

The API was created in 2023, when an engineer described it as a simple request forwarder. From early 2024 to this fall in the Northern Hemisphere, traffic volume grew about 1,800 times, according to the company. With that growth, Python added overhead at every step of each request, from input validation to usage tracking for billing.

The first attempt was partial. In March, the team rewrote only the part that interprets the model's response in Rust and called it from Python. The gain was between 8% and 10% in CPU usage, but each piece of text had to cross between the two languages three times. The conclusion was that a full rewrite would be more worthwhile.

Writing was fast, verification took months

Claude produced the first version of the new system's core in about a week. The challenge was proving it behaved exactly like the old one. By April, the Rust version passed about 98% of roughly 700 integration tests, but only a quarter of real requests produced the same result in both versions. An audit also found more than 100 tests that had been weakened during the adaptation.

The solution was to use the Python service itself as a reference. Since calling the model twice per request would double billing and rate limits, the response was generated once and fed to both versions, which had to match at every stage. Anthropic says it did not read customer content: each discrepancy was logged only by format, such as the stage and the first differing byte.

Claude agents received each new type of discrepancy, fixed the Rust code, and created a test, and engineers reviewed the changes before going to production. The rate of identical requests, which reached 6.5% in early May, climbed to 99.6% by August. In one example cited by the company, an agent tried to resolve a difference by copying text to local files, and an engineer rejected the fix as a temporary workaround.

"Verification, not generation, had become the bottleneck," sums up the Anthropic engineering team's post.

What changes for Claude users

In addition to hardware savings, the company measured a roughly 20% drop in median time to first byte for Claude Code requests. For developers using the API in Brazil, the report mentions no change in pricing or in the way the service is called. The Next Web notes that the API experienced outages this year, making the new system's stability a point of attention.

Anthropic says that since May, Claude has written more than 80% of the code the company incorporates into its systems, and uses this case to argue that the challenge now is verifying what AI produces.

Sources: Anthropic (engenharia), The Next Web

Frequently asked questions

Why did Anthropic switch from Python to Rust for the Claude API?

Traffic grew about 1,800 times since early 2024, and Python added overhead at every request step. With Rust, per-request CPU usage dropped about 70%.

Who wrote the new API code?

Most was written by Claude agents, with Anthropic engineers reviewing each change before production.

Did the Claude API experience downtime during the switch?

No. According to Anthropic, users were gradually migrated in September without taking the service offline.

Read also