---
title: "Migrating our Messages API to Rust"
description: "Anthropic migrated its production Messages API from Python to Rust, using the live Python service as an oracle because tests were incomplete and the API kept changing."
url: "https://swe.quest/articles/migrating-our-messages-api-to-rust-9b451909ab785c36"
canonical: "https://www.anthropic.com/research/migrating-api-to-rust"
source: "Anthropic Engineering"
published: "2026-11-25"
difficulty: "medium"
kind: "Case study"
reading_minutes: 24
tags: ["rust","refactoring","performance","testing","ai-coding"]
---

# Migrating our Messages API to Rust

A post on [Anthropic Engineering](https://swe.quest/sources/anthropic.md), published 2026-11-25, 24 min read, Case study. Original: [https://www.anthropic.com/research/migrating-api-to-rust](https://www.anthropic.com/research/migrating-api-to-rust)

## Summary

Anthropic migrated its production Messages API from Python to Rust, using the live Python service as an oracle because tests were incomplete and the API kept changing. Rust passed about 98% of tests but initially matched only about 24% of production inputs, so they ran the model once and replayed its output to Rust, comparing every pre- and post-model checkpoint piece by piece. Privacy-safe fingerprints grouped differences and dispatched Claude agents to fix them. A partial Rust rewrite of output parsing cut CPU only 8–10% while adding cross-language overhead, so they completed the full rewrite; the Rust API now uses about 70% less CPU per request and cuts median time to first token by about 20%, with no service outage or feature freeze.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [AI for coding](https://swe.quest/tags/ai-coding.md) (AI & ML)

## Prerequisites

- API request handling
- Rust basics ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))

## Keywords

Messages API, Rust, Python, Claude

## Related posts

- [Rust at Scale: An Added Layer of Security for WhatsApp](https://swe.quest/articles/rust-at-scale-an-added-layer-of-security-for-whatsapp-fa325ff993e04dbf.md): Meta Engineering · 2026-01-27 · Easy · 5 min read · Memory safety, Rust, Application security, Communications, Mobile
  WhatsApp rewrote its cross-platform media consistency library, wamedia, from C++ to Rust and now ships it to billions of devices and browsers across Android, iOS, Mac, Web and wearables, which Meta calls the largest client-side Rust deployment it knows of.
- [Rocket Money x Hugging Face: Scaling Volatile ML Models in Production​](https://swe.quest/articles/rocket-money-x-hugging-face-scaling-volatile-ml-models-in-production-acc7e904259d3114.md): Hugging Face · 2023-09-19 · Easy · 8 min read · Inference & serving, ML platforms, Machine learning, Caching, Payments & fintech
  Rocket Money replaced a regex-and-decision-table merchant detector with a BERT-family transformer classifier spanning 4000+ classes, served through Hugging Face's hosted Inference API rather than an in-house MLOps stack.
- [Rewriting the CLI in Rust: Was It Worth It?](https://swe.quest/articles/rewriting-the-cli-in-rust-was-it-worth-it-da1e555358ca943e.md): Railway · 2023-03-10 · Medium · 9 min read · Rust, Developer tools, Refactoring & migrations, Go, GraphQL
  Railway rewrote its Go/Cobra CLI in Rust for v3 because the old codebase had untyped, string-defined GraphQL queries, dynamically registered flags that forced ~120 error guards, and assumptions predating multi-service projects.
- [Squeezing every millisecond: How we rebuilt the Datadog Lambda Extension in Rust](https://swe.quest/articles/squeezing-every-millisecond-how-we-rebuilt-the-datadog-lambda-extension-in-rust-c788e8ecc0f0b212.md): Datadog Engineering · 2025-04-09 · Medium · 9 min read · Serverless, Rust, Performance engineering, Observability, Refactoring & migrations
  Datadog rewrote its AWS Lambda Extension from a Go build of the full Datadog Agent into a purpose-built Rust sidecar (Project Bottlecap), cutting cold start overhead from about 450 ms to 70 ms, memory from 128 MiB to 77 MiB, and binary size from 55 MB to 7 MB.
- [Security Disclosure Recommendation: Check for Unexpected Anthropic Usage](https://swe.quest/articles/security-disclosure-recommendation-check-for-unexpected-anthropic-usage-e7cd891615bbdd91.md): Railway · 2026-10-22 · Medium · 2 min read · Incidents & postmortems, Security, Identity & auth
  Railway users whose Claude API key may have been exposed in the October 21, 2026 security disclosure should delete the key in the Claude Console, create a replacement and redeploy services with the updated Railway variable.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
