llm-recorder package in Mastra codebase.
In this article, we review recordings folder found in core package in Mastra codebase. You will learn:
- What is Mastra?
- llm-recorder package

What is Mastra?
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 to get started.
Following are the usecases 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.
llm-recorder package
I found a package named _llm-recorder in Mastra codebase. How? well, I first came across the folder named recordings in the core package. I searched for recording across the entire codebase and found the below results:

This helped me locate this package, _llm-recorder.
What is 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.
Features:
-
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
Usage
There are 4 usage examples provided in the llm-recorder README.
-
Suite-wide via Vite plugin
-
Per-file via enableAutoRecording()
-
Per-describe via useLLMRecording()
-
Per-test via withLLMRecording()
About me:
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 or book a meeting.