Skip to main content
Back to News
news/AI Infrastructure

Anthropic Rebuilt Claude's Messages API in Rust With Claude

Anthropic moved Claude's Messages API from Python to Rust with help from Claude agents: 70% less CPU, 20% faster first tokens and no downtime.

Stefan Trbojevic

Stefan Trbojevic

27 November 20262 min read
LinkedIn
Three frosted glass server blades on a dark navy backdrop

The takeaway

Anthropic turned its own production API into a verifier, then let agent loops fix the differences. For builders, the lesson is blunt: writing the rewrite is now cheap, verification is the real bottleneck.

Why it matters for builders

Anthropic turned its own production API into a verifier, then let agent loops fix the differences. For builders, the lesson is blunt: writing the rewrite is now cheap, verification is the real bottleneck.

Anthropic Rebuilt Claude's Messages API in Rust With Claude

Anthropic published the engineering story behind one of the biggest live migrations in AI infrastructure this year: its Messages API, the path every Claude API call, Claude Code session and Cowork task takes into the model, now runs on Rust instead of Python. The company says the new service uses about 70% less CPU per request and cuts median time to first token by about 20%, with no maintenance window and no feature freeze.

Claude wrote a first version of the core request path in about a week; the months after went into proving it matched the old service.

What happened

Anthropic built the Messages API in 2023 in Python, the language most of its research code used. From early 2024 to fall 2026, API traffic through it grew roughly 1,800 times, and it now carries the Claude API, Claude Code and Cowork. That load made CPU per request the real constraint.

The Rust service covers the input path (validation, prompt construction, tokenization, safety classifiers) and the output path (streaming, tool calls, usage accounting). Public traffic moved to Rust in September 2026, seven months after the port started, according to Anthropic.

Three frosted glass server blades on a dark navy backdrop, representing the Rust rewrite of the Messages API

The verification problem

The port was the easy part. Anthropic had about 700 integration tests, and the Rust API passed roughly 98% of them by April. On real production traffic, only about a quarter of inputs matched Python's output.

Two things broke the tests as a safety net: they were coupled to the Python implementation, so a pass could mean the code was right or the test had been weakened (an audit found more than 100 weakened assertions), and they were incomplete, since 20 binary options alone produce over a million combinations.

So the team turned the running Python API into the oracle. They shadowed live traffic, ran the model once and replayed the same output into both versions, then compared every step before and after the model call. Because they refused to read customer prompts or replies, they compared only the shape of each difference: which step, which prompt piece, byte offsets and lengths. Those fingerprints let them tell one bug from hundreds of thousands of near-identical records.

Why it matters for builders

The migration ran on three loops: a fast inner loop where agents tested hypotheses in a sandbox in under a second, a slower outer loop that checked fixes against shadowed production traffic, and a memory loop that turned engineer corrections into rules in CLAUDE.md, new tests and lints.

Any team shipping agents can copy that pattern. A coordinator agent grouped diff records every 10 to 30 minutes, opened a Slack thread and assigned worker agents; humans reviewed fixes at the seam, not the guesses. Anthropic's conclusion: verification is the new bottleneck. If agents can already produce the rewrite, the limit is how fast you can prove it is correct. Treat your legacy system as the answer key.

Share𝕏

The Automation Brief

Read 5 AI stories instead of 50.

The essential moves in AI agents, models, automation and infrastructure — filtered for builders and operators, with the part that actually matters.

No noise. Unsubscribe anytime.

Editorial notes

Reported by

Stefan Trbojevic

Edited by

n8n Lab Editorial

Published

27 November 2026

Updated

27 November 2026

AI disclosure: AI assisted with research and drafting. Factual claims are reviewed by an editor.

n8n Lab is an independent service provider. We are not affiliated with, endorsed by, or sponsored by n8n GmbH. “n8n” is a trademark of n8n GmbH and is used here only to describe the platform-specific implementation and automation services we provide.