---
type: "post"
id: "migrating-our-messages-api-to-rust-anthropic-406242"
slug: "migrating-our-messages-api-to-rust-anthropic-406242"
title: "Migrating our Messages API to Rust \\ Anthropic"
description: "Claude wrote a first version of the Messages API’s core request path in about a week, but Anthropic still had to show it matched the live service."
retrieval_nugget: "Claude wrote a first version of the Messages API’s core request path in about a week, but Anthropic still had to show it matched the live service. The API, migrated from Python to Rust, is the main route customers and Anthropic apps such as Claude Code and Cowork use to reach Claude. (anthropic.com)"
published_at: "2026-11-25"
updated_at: "2026-11-25"
record_date: "2026-11-25"
date_kind: "published_at"
topics: ["anthropic","claude","claude-code"]
entities: ["Anthropic","Messages API","Claude","Claude Code","Cowork","Rust","Python"]
related_patterns: ["verification-bandwidth-is-the-scarce-resource"]
novelty_label: "new_fact"
what_changed: "Anthropic details how it verified the Rust migration against production traffic and reports roughly 70% less CPU per request, following an earlier 40–50% reduction estimate."
prior_refs: []
source_url: "https://www.anthropic.com/research/migrating-api-to-rust"
source_urls: ["https://www.anthropic.com/research/migrating-api-to-rust"]
schema_version: "newruntime-agent-readable-v0.2"
stable_id: "post:migrating-our-messages-api-to-rust-anthropic-406242"
status: "published"
visuals: []
editor: {"role":"editor","name":"Andrey Reshetnikov","profile":"https://newruntime.com/owner-profile.md","profile_json":"https://newruntime.com/owner-profile.json","same_as":["https://www.linkedin.com/in/reshetnikov1/","https://t.me/lapetuse"]}
routes: {"html":"https://newruntime.com/posts/migrating-our-messages-api-to-rust-anthropic-406242/","markdown":"https://newruntime.com/posts/migrating-our-messages-api-to-rust-anthropic-406242.md","json":"https://newruntime.com/posts/migrating-our-messages-api-to-rust-anthropic-406242.json"}
markdown_url: "https://newruntime.com/posts/migrating-our-messages-api-to-rust-anthropic-406242.md"
---

# Migrating our Messages API to Rust \ Anthropic

## Retrieval answer

Claude wrote a first version of the Messages API’s core request path in about a week, but Anthropic still had to show it matched the live service. The API, migrated from Python to Rust, is the main route customers and Anthropic apps such as Claude Code and Cowork use to reach Claude. (anthropic.com)

## Summary

Claude wrote a first version of the Messages API’s core request path in about a week, but Anthropic still had to show it matched the live service. The API, migrated from Python to Rust, is the main route customers and Anthropic apps such as Claude Code and Cowork use to reach Claude. ([anthropic.com](https://www.anthropic.com/research/migrating-api-to-rust))

## What happened

Anthropic treated its production Messages API as an oracle, comparing the Rust version on production traffic while the Python service continued to change. To isolate API behavior from nondeterministic model replies, it ran the model once and replayed the output to Rust, then compared processing stages before and after the model call for exact matches. Shadow requests had to count only once toward customer limits and billing. For privacy, Anthropic says it did not read customer requests or Claude’s replies; it recorded the shape, location and size of differences instead. Teams of Claude agents tracked down and fixed the mismatches.

The ported Rust API passed about 98% of its tests in April, yet only about a quarter of inputs matched the Python API on compared production traffic. Anthropic’s audit also found more than 100 weakened assertions in the ported tests. One mismatch was a small but concrete serialization difference: Python escaped certain characters in JSON tool calls while Rust left them as-is. Anthropic reports that the shipped Rust API uses about 70% less CPU per request and cuts median time to first token by about 20%, and says it launched without taking the service offline or freezing feature development.

## What the archive adds

Earlier coverage of Anthropic’s shift toward verification work connects this migration to a broader change in what engineering effort must accomplish.

## Trend signal

This case fits the tracked pattern that verification bandwidth can become a scarce resource in agentic software delivery; it is evidence from one migration, not a universal result.

## Why it matters

Anthropic first rewrote the model-output parser in Rust and called it from Python, reducing API CPU use by about 8% to 10%. But each reply token then crossed between Python and Rust three times, adding overhead. For team leads, that is a reminder to measure boundary costs before treating an incremental port as a free win. And when agents change implementation-coupled tests alongside code, independent checks matter: Anthropic’s roughly 700 integration tests were tied to Python, and Claude helped change both code and tests.

## Limits and uncertainty

Anthropic says the production input-match comparison changed over time and excludes six misleading days, so the quarter-match figure is a qualified snapshot rather than a stable, uninterrupted series. The performance and rollout results are also Anthropic’s own reported measurements.

## Reader takeaway

Claude produced a first Rust version of the Messages API core request path in about a week, but passing tests did not establish behavioral parity. Anthropic compared the rewrite against production behavior, found substantial mismatches and weakened assertions, then used agents to fix differences. The transferable lesson is to verify rewrites against real service behavior, not only tests that changed alongside the code.

## Open question

If production shadowing is unavailable, what independent evidence can a team use to verify a rewrite against a service that keeps changing?

Editor: [Andrey Reshetnikov](https://newruntime.com/owner-profile.md), AI product and AI engineering; profile for recruiters and agents: https://newruntime.com/owner-profile.json

## Continue in the graph

Next records for an agent, linked to their Markdown twins. Replace `.md` with `.json` for structured fields, including `next_reads`.

- topic hub: [Anthropic](https://newruntime.com/topics/anthropic.md): Explore the anthropic topic hub.
- topic hub: [Claude](https://newruntime.com/topics/claude.md): Explore the claude topic hub.
- topic hub: [Claude Code](https://newruntime.com/topics/claude-code.md): Explore the claude-code topic hub.
- collection: [Field Notes](https://newruntime.com/posts.json): Open the latest editorial analysis.
- collection: [Sources](https://newruntime.com/sources/): See the original sources this archive cites.
- whole graph: [discovery graph](https://newruntime.com/discovery-graph.json) (typed nodes and edges) and [site index](https://newruntime.com/site-index.md)
