Skip to content
Apixo
Blog
news· 4 min read· via InfoWorld AI

Anthropic Rewrites Claude Messages API in Rust Using AI Verification Loops

Anthropic ported its Messages API from Python to Rust without downtime using Claude and verification loops, cutting memory usage by 80% and CPU usage by 70%.

Anthropic Rewrites Claude Messages API in Rust Using AI Verification Loops

Anthropic has completed a full migration of its core Messages API from Python to Rust, leveraging its own Claude AI model to write the new codebase in approximately one week. The primary engineering challenge, however, was not code generation but proving that the Rust implementation performed identically to the legacy system. By using its live production environment as an automated verifier, Anthropic completed the transition without taking the API offline or freezing ongoing feature development. The resulting Rust infrastructure now consumes about 70% less CPU per request, reduces memory usage by 80%, and cuts the median time to first token by roughly 20%.

The Messages API was originally introduced in 2023 as a basic Python request forwarder, serving as the main entryway for both external customers and Anthropic's internal applications. Between early 2024 and fall 2026, API traffic expanded by more than 1,800 times. As functionality expanded, every incoming request required validation, prompt conversion, tokenization, and safety screening, while output tokens had to be split into text, thinking, and tool calls. Python's overhead across these steps created performance bottlenecks. As Anthropic engineers noted, "Traffic eventually grew far beyond what the initial Python service was built for, and we quickly needed to find a way to make the service much more efficient."

Scaling traffic and the verification bottleneck

By May 2026, Claude was generating more than 80% of the code merged across Anthropic, making a full system rewrite feasible. Yet validating the new Rust system presented significant hurdles. Standard testing methods proved insufficient: the engineering team found its existing suite of roughly 700 integration tests incomplete and tightly coupled to Python implementation details. Furthermore, live production outputs were difficult to compare directly due to non-deterministic responses, ongoing feature updates, and strict privacy constraints.

To solve this, engineers turned to traffic shadowing, routing live requests through both the legacy Python and new Rust implementations to compare outputs. Differences were recorded as sanitized diff logs stripped of customer content. Because a single bug could generate hundreds of thousands of nearly identical diff entries, Anthropic built automated verification loops to reconcile discrepancy records.

Autonomous verification loops

The team constructed three distinct verification feedback loops to resolve discrepancies:

  • Inner loop: A fast, local sandbox running in less than a second, allowing Claude agents to test hypotheses, debug differences, and propose code fixes safely.
  • Outer loop: A production-level validation phase comparing Rust API deployments with and without each proposed fix to capture issues missed in the sandbox.
  • Memory loop: A system recording reviewer decisions and agent actions, storing notes so future agents could avoid repeating past mistakes.

This multi-layered setup enabled agents to work with minimal direct supervision. Over time, human engineers shifted from chasing individual code diffs in the inner loop to managing the outer loop via Slack, before eventually stepping back to construct high-level rules and validation checks at the system edge. As the team observed, "As Claude grew more intelligent (and as we grew more intelligent at working with it), we evolved from directing Claude to Claude directing itself, relying on humans mainly for important judgment calls."

What it means for developers

Anthropic's migration highlights a fundamental shift in software engineering when applying large language models to complex infrastructure projects. As AI models handle the bulk of code creation, code generation ceases to be the primary constraint in system development. Instead, the primary bottleneck shifts to verification—designing reliable, automated systems capable of confirming that synthetic code operates correctly without introducing silent regressions.

For engineering teams looking to integrate AI into their operational workflows, Anthropic's experience demonstrates that live production environments themselves can serve as effective validation mechanisms when traditional test suites fall short. Teams can build feedback loops where models systematically isolate bugs and self-correct based on structured diff signals.

Developers interested in building with high-performance LLMs can try top AI models cheaply through one API at https://apixoai.online. As system migration risks decrease through automated verification architectures, developers can focus less on manual code refactoring and more on defining precise evaluation boundaries and systemic rules for autonomous AI agents.


Source: Anthropic says it moved its Claude API from Python to Rust with no downtime — InfoWorld AI. Written by the Apixo team from that report.

#ai-news#anthropic#claude#rust#python#api
Try it with your own tools

One key for Claude, GPT, GLM, DeepSeek and more. Pay per token with crypto.

Get your API key

Keep reading