Editorial illustration for Anthropic Swaps Python for Rust in Messages API, Cutting CPU Use 70%
Anthropic Swaps Python for Rust in Messages API, Cutting...
Anthropic has rewritten the Messages API, the plumbing that routes every Claude request, from Python into Rust. The company says the swap cut CPU usage per request by about 70% and memory consumption by more than 80%, numbers it laid out in an engineering blog post detailing the project, which wrapped up in September.
The rewrite wasn't optional. Anthropic says traffic on the API grew roughly 1,800 times between early 2024 and autumn 2026, and the original Python service, built back in 2023 as a bare-bones request forwarder, had long since outgrown that job. By the time engineers started pulling it apart, every single request was triggering input validation, prompt construction, tokenization, and safety classification, on top of parsing model outputs, splitting out text, thinking, and tool calls, streaming responses, and logging usage for billing and rate limits. Python's overhead in object creation and memory handling made all of that expensive at scale.
Rebuilding that infrastructure in Rust meant touching the path that Claude Code, Cowork, and every paying customer runs through. Anthropic leaned on AI-generated code to speed up the port, a decision that produced its own complications once the new system met live traffic.
Anthropic reported a roughly 70% reduction in CPU usage per request in one production region and more than 80% lower memory consumption per request across production.
Why this matters
This is a reminder that the stack you pick for an MVP isn't the stack you keep once traffic hits production scale. Anthropic's 1,800x growth over two years broke a Python service that was never designed to do heavy processing, it was designed to forward requests. The partial rewrite, parsing-only code moved to Rust first, shows a sensible migration path: isolate the hottest code path, measure the gain, then decide whether the full rewrite is worth the engineering cost.
For founders building on top of Claude or similar APIs, the 70% CPU and 80% memory reduction is a useful data point on what "scaling pains" actually look like at the infrastructure layer, even if your product never touches Rust directly. For developers choosing languages for inference-adjacent services, this is more evidence that Python's convenience tax (object creation, garbage collection, memory overhead) becomes real money at volume. Worth watching: whether other labs follow with their own language migrations, and whether Anthropic open-sources any of the Rust tooling it built along the way.
Further Reading
- Migrating our Messages API to Rust - Anthropic
- Anthropic’s Rust Rewrite Shows Where the Real Work in AI-Driven Migrations Lives - DevOps.com
- Anthropic Messages API Rust rewrite: 70% less CPU, with caveats - The Terminal
- Anthropic Rust Rewrite: How Claude Agents Cut API CPU 70% - Van Data Team
- Anthropic Messages API Rust Migration: What Changed for Claude API Users - Apidog