Anthropic Used Claude Agents to Rewrite Its Messages API in Rust

Anthropic Used Claude Agents to Rewrite Its Messages API in Rust

Anthropic says it has finished an Anthropic Rust migration of its Messages API, the service that powers Claude for developers and for its own apps like Claude Code. In a research post published November 25, 2026, the company explains that Claude wrote much of the new code, while a team of AI agents hunted down mismatches between the old Python version and the new Rust one. The result, according to Anthropic, is an API that uses about 70% less CPU per request and cuts median time to first token by about 20%.

Why Anthropic Moved Its API to Rust

The Messages API started in 2023 as a fairly simple Python service. Anthropic says one engineer once called it basically a request forwarder. Over time it took on much more work, including validating requests, building prompts, tokenizing them and running safety classifiers.

Traffic is the bigger story here. Anthropic says API traffic grew roughly 1,800 times from early 2024 to fall 2026. Python added overhead to every step of every request, so the company needed a far more efficient service.

A first attempt only rewrote the part that parses model output, then called it from Python. That cut CPU use by about 8% to 10%, but each token had to cross between the two languages three times. Anthropic decided the extra complexity was not worth it and went for a full rewrite instead.

Claude wrote the first draft fast

According to the post, Claude produced a first version of the API’s core request path in about a week. Anthropic also says that by May 2026, Claude was writing more than 80% of the code the company merged. Writing code was no longer the hard part.

How the Rust Migration Was Verified

The real challenge was proving the new version behaved exactly like the old one. The existing 700 or so integration tests were tied to the Python code, and Anthropic found more than 100 weakened assertions when it audited the ported tests. In April, the Rust API passed about 98% of tests, yet only about a quarter of inputs matched on real production traffic.

To close that gap, the team turned the live Python API into a kind of answer key. It ran production requests through both versions, but only called the model once and replayed the output to Rust, so customers were never billed twice. To protect privacy, engineers never read the actual requests or replies.

Instead, they recorded the shape of each difference. Two ideas did most of the work:

  • Checkpointing compared each step, like accepting a request or building the prompt, to find where the versions first split.
  • Fingerprints logged where a difference began and how big it was, so one bug could be told apart from another.
  • A script grouped new kinds of records every 10 to 30 minutes and alerted a coordinating Claude agent.
  • That coordinator assigned a worker agent to each bug and opened a Slack thread so engineers could follow along.

Inside the Agent Loops Behind the Rewrite

Anthropic describes three loops that kept the work moving. Each one handled a different job, and humans sat mostly at the boundaries.

LoopWhat it didSpeed
Inner loopAgents reproduced bugs in a cloud sandbox and edited the Rust code until outputs matchedSeconds per test
Outer loopReviewed fixes were checked against shadowed production trafficSlower, build by build
Memory loopLessons from reviews became notes, rules and permanent checks for future agentsOngoing

Human review still mattered. In one case, an agent “fixed” a missing web search tool description by copying the text into local files. The outputs matched, but an engineer rejected it because the real fix was to have Rust call the internal service, and the agent saved that lesson to memory.

Engineers also turned recurring review comments into rules in a CLAUDE.md file. Later, a merge check required any change to the Python code to get a matching change in Rust.

The results Anthropic reports

Anthropic says the service moved to Rust without being taken offline and without freezing feature work. Here is what the company claims the switch delivered:

  1. About 70% less CPU used per request.
  2. About 20% faster median time to first token.
  3. No downtime during the move, with traffic shifted over gradually.

What This Means for You

If you call Claude through the API, you may already be using the Rust version. Faster first tokens mean replies should start streaming a bit sooner, which helps chat apps and tools built on Claude AI models.

For developers, the bigger lesson is about method. Anthropic argues that verification, not code generation, is now the bottleneck for large rewrites. If you are planning to use Claude Code agents on an old system, a few takeaways stand out:

  • Decide how you will prove the new code is correct before you start writing it.
  • Give agents a fast, safe sandbox to test guesses, and keep humans on reviewing fixes.
  • Save corrections as rules, so you never have to explain the same mistake twice.

If you are new to working with agents on code, our guide on explaining legacy codebases is a good starting point. You can also tune Claude Code permissions for longer runs.

Our takeaway: AI can now write a full rewrite in days, but the teams that win will be the ones that can check that work just as quickly.

For more updates like this, browse our latest AI news.

Sources

Primary source: Anthropic’s research post on migrating the Messages API to Rust.

Conclusion

Anthropic’s move to Rust is a useful look at how a major AI lab now builds its own software. Claude drafted the new API in about a week, but most of the effort went into proving it matched the old one on live traffic. The company says the payoff was a service that uses about 70% less CPU and starts replies about 20% faster. It also offers a clear message for every engineering team: as AI writes more code, careful verification is what turns speed into something you can trust.

Newsletter

New AI tools in your inbox

The best new tools and the AI news that matters, in one short email. Unsubscribe any time.

Free · No spam · Unsubscribe any time

✓ Looks like you’re subscribed

Loading Google’s sign-up form…

Looks like you’re already subscribed

Thanks for reading! New AI tools and the AI news that matters will land in your inbox.

Not subscribed yet? Refresh the page to load the sign-up form.

The sign-up form couldn’t load. If you use an ad or content blocker, allow news.google.com and reload the page.

Free instant check before you pay. Takes a few seconds.

Scroll to Top