# llm-recorder package in Mastra codebase.

> Source: <https://dev.to/ramunarasinga-11/llm-recorder-package-in-mastra-codebase-27g7>
> Published: 2026-12-01 13:12:50+00:00

**Key takeaway:** Mastra's internal _llm-recorder intercepts LLM HTTP calls via Mock Service Worker, matching requests by MD5 hash of URL plus body and replaying recorded SSE streams with original chunk timing, so agent tests run deterministically across OpenAI, Anthropic, Google and OpenRouter.

In this article, we review **recordings** folder found in core package in Mastra codebase. You will learn:

Mastra is a TypeScript framework for building AI agents and applications. Create your first agent with a single command and start building.

You can follow this [Quickstart guide](https://mastra.ai/docs#quickstart) to get started.

Following are the [usecases](https://mastra.ai/docs#use-cases) I found for this framework

Embed agents in your product

Customer-facing assistants

Software factories

Internal copilots

Regulated and back-office operations

Data analysis agents

Content automation

DevOps and engineering automation

Sales and go-to-market workflows

Learn more about these [usecases](https://mastra.ai/docs#use-cases).

I found a package named [_llm-recorder in Mastra codebase](https://github.com/mastra-ai/mastra/tree/c42d9b40ddcd7481d62f8e6b0a67aa1854e11969/packages/_llm-recorder). How? well, I first came across the folder named [**recordings** in the core package](https://github.com/mastra-ai/mastra/tree/main/packages/core/__recordings__). I searched for [**recording** across the entire codebase](https://github.com/search?q=repo%3Amastra-ai%2Fmastra+__recordings__&type=code) and found the below results:

This helped me locate this package, _llm-recorder.

LLM response recording and replay for tests. Works like test snapshots - auto-records on first run, replays deterministically thereafter.

This is currently an internal package in Mastra. It will become a public package in the future. I don't know when this will be a public package.

Recording/Replay: Record real LLM API responses and replay them in tests

MSW-based: Uses Mock Service Worker for reliable HTTP interception

Streaming Support: Captures and replays SSE streaming responses with chunk timing

Contract Validation: Detect API schema drift in nightly tests

Multi-provider: Supports OpenAI, Anthropic, Google, and OpenRouter APIs

Content-based Matching: Requests matched by MD5 hash of URL + body, not order

There are 4 usage examples provided in the [llm-recorder README](https://github.com/mastra-ai/mastra/blob/c42d9b40ddcd7481d62f8e6b0a67aa1854e11969/packages/_llm-recorder/README.md?plain=1#L57).

Suite-wide via Vite plugin

Per-file via enableAutoRecording()

Per-describe via useLLMRecording()

Per-test via withLLMRecording()

Hey, my name is Ramu Narasinga. I spent 4+ years studying OSS codebases and wrote 400+ articles on what makes the production-grade.

Need help with a project? drop me an email - [ramu.narasinga@gmail.com](mailto:ramu.narasinga@gmail.com) or [book a meeting](https://thinkthroo.com/contact).
