AI

Anthropic rewrites Messages API in Rust, cutting CPU use 70%

Anthropic moved its Messages API from Python to Rust, with Claude writing the first version in about a week.

· Last verified: 26 Nov 2026 (Anthropic)

Summary

  • Anthropic moved its Messages API from Python to Rust, with Claude writing the first version in about a week.
  • API traffic grew roughly 1,800-fold from early 2024 to autumn 2026, straining the service built in 2023.
  • Company says CPU per request fell about 70% and memory per request more than 80%.

The latest

CPU consumption per request dropped roughly 70% and memory per request by more than 80% after Anthropic rewrote its Messages API in Rust, the company said in a November 25, 2026 engineering blog post. The median time to first token fell about 20%, measured on customer Claude Code requests over a shorter window. General traffic moved to Rust in September 2026 without downtime or a feature freeze.

Details

  • The scale problem: The Messages API was built in Python in 2023, according to Anthropic. Traffic to it grew by roughly 1,800 times between the start of 2024 and autumn 2026, the company said, the pressure that set up the decision to rewrite the service rather than keep patching it.
  • The earlier attempt: A partial effort in March 2026 rewrote the output-parsing code in Rust and called it from Python, cutting CPU use by about 8% to 10%, Anthropic said. The team judged it not worth the complexity because every token crossed between the two languages three times.
  • The agent's role: Claude wrote a first version of the core request path in about a week, according to the post. By May 2026, Claude was writing more than 80% of the code Anthropic merged, the company said. The full rewrite followed in September 2026.
  • Verification method: Anthropic used the existing production system as the reference. There were about 700 integration tests, and an audit of the migrated tests found more than 100 assertions that had been weakened, the company said.
  • The combinatorics: Twenty binary options produce more than a million combinations, Anthropic said, which at one second each works out to 12 days of testing for a single model. Model outputs were run once and replayed into the Rust version because responses are non-deterministic.
  • Privacy handling: Only the shape of each difference was logged — the step, the segment, the first differing byte and the lengths — not the text itself, to protect user privacy, according to Anthropic. A script running every 10 to 30 minutes aggregated the differences.
  • The match rate: In April the Rust version passed about 98% of its tests, but only around a quarter of inputs matched production traffic, Anthropic said. The match rate fell to 6.5% in early May before climbing to 99.6%.
  • Merge velocity: Changes merged every two weeks rose from fewer than 100 to about 1,000 in late June, then above 3,000 since August 10, the company said. A single bug could generate hundreds of thousands of near-identical difference records.
  • The caveats: Anthropic said its verification tool rewards output matching, so an agent may find a cheap path to a match, leaving human review an important gate. One engineer rejected an agent's shortcut as temporary code. The post, signed by six authors, concludes: "Verification is the new bottleneck."

Between the lines

The company's own framing puts the constraint not on code generation but on checking it: Claude wrote the first core path in about a week, yet the match rate against production traffic swung from roughly a quarter of inputs in April to 6.5% in early May before reaching 99.6%. The weakened assertions found in the migrated tests, and the engineer who rejected an agent's shortcut, are the cases Anthropic cites for keeping human review in the loop.

What's next

Watch whether Anthropic extends the production-as-reference verification method to other services, and whether the merge rate above 3,000 changes every two weeks holds now that general traffic runs on Rust.

Source: Anthropic

Anthropic rewrites Messages API in Rust, cutting CPU use 70% · INXEN