Anthropic moves Claude backend from Python to Rust to deliver massive CPU and memory savings
AI company Anthropic has greatly reduced the computer resources needed to run one of its most important services. In a recent engineering blog post, the company said it moved its Messages API from Python to Rust. This cut CPU use per request by about 70% and memory use per request by more than 80%. Anthropic also relied heavily on its own AI model, Claude, to help make the change.
The Messages API is the main way developers use Claude and add it to their apps. Anthropic's own products, including Claude Code and Cowork, also use it. The API was first built with Python in 2023, when it had a fairly simple job.
But from early 2024 to fall 2026, traffic to Anthropic's API grew by about 1,800 times. New features also made the API do much more work for every request. Because of this, the original Python version became less efficient.
Porting Claude from Python to Rust
Anthropic first tried to solve the problem by rewriting only some parts of the API in Rust. This lowered CPU use by about 8% to 10%. But the company found that keeping a system that constantly switched between two programming languages made things more complicated. So Anthropic eventually decided to move the whole API to Rust.
Claude wrote the first version of the API's main request-processing code in about a week. But making sure the new system worked exactly as it should was much harder.
For example, in April, the Rust API passed about 98% of its tests. However, during testing with real-world data, only about one quarter of the inputs produced results that matched the existing Python version.
To fix this, Anthropic ran the Python and Rust versions at the same time and compared how they handled real API traffic. When the two versions behaved differently, Claude agents were asked to find the problem and create a fix. Human engineers checked the suggested changes before they were released. More checks were then used to make sure the fixes worked in real-world conditions.
Besides greatly lowering CPU and memory use, the move to Rust also cut the median time to first token by about 20% for the Claude Code requests that Anthropic measured. Put simply, users began getting responses sooner. Using fewer computer resources also means Anthropic can handle more requests with the same amount of hardware. Anthropic completed the move without taking the service offline or stopping work on new features.
Discord is also making a major change to its desktop app. It is moving away from Electron and working on a new client built with Rust. A leaked build of Discord Phoenix shows a very large improvement in how many computer resources it uses.
