TL;DR
A hands-on look at Mastra, the open source TypeScript framework for building production-ready AI agents and workflows -- with verified setup commands, honest tradeoffs, and current pricing.
Read next
Four mature, production-ready TypeScript frameworks have made building agents genuinely enjoyable. Here is how to pick the right one - and how they fit together.
10 min readEvery major AI coding tool just went through a pricing shift. Here are the exact numbers for Cursor, GitHub Copilot, Claude Code, Windsurf/Devin, and the Anthropic API - verified from live pricing pages on June 10, 2026.
9 min readFactory AI's Droid agent surfaces a new competitive front in coding tools: cost-per-completed-task. Here's what their architecture reveals about where the whole industry is heading.
8 min readThe TypeScript AI agent ecosystem has been moving fast, and Mastra has quietly become one of the more serious options for developers who want something beyond a thin wrapper around an LLM API. It is an open source framework built around the idea that agents and workflows are fundamentally different things that deserve different primitives -- and that both should feel native in a modern TypeScript project.
If you have spent time fighting with untyped prompt glue code, wondering where to put memory, or trying to reason about multi-step agent processes through a wall of nested async functions, Mastra is worth a close look.
Last updated: June 10, 2026
Mastra is a TypeScript framework for building AI-powered applications. The core primitives are agents, workflows, tools, and memory. Agents handle open-ended tasks where the steps are not known in advance -- the agent decides which tools to invoke and when to stop. Workflows handle predetermined multi-step processes with explicit typed control flow, including support for suspension, resumption, and parallelism.
The framework ships with a local development UI called Mastra Studio (runs at localhost:4111) that lets you test agents, inspect tool calls, and run workflows without building a frontend first. That alone removes a significant amount of friction from the early build-and-test loop.
Mastra also provides a model router that exposes over 3,000 models from providers including OpenAI, Anthropic, Groq, Google, Cerebras, and Mistral. You reference models as provider/model-name strings in your agent configuration, which means switching providers is a one-line change rather than a dependency swap.
The verified create command from the docs is:
npm create mastra@latest
Or with flags to skip the interactive wizard:
npm create mastra@latest my-agent-app --default --llm openai
Equivalent commands for other package managers:
pnpm create mastra
yarn create mastra
bunx create-mastra
The wizard scaffolds a src/mastra directory with a weather agent example, a tool, a workflow, and a scorer. Once setup finishes, start the dev server and open Studio:
npm run dev
# Studio opens at http://localhost:4111
Mastra requires Node.js v22.13.0 or later. It also runs on Bun, Deno, and Cloudflare Workers.
Agents are instances of the Agent class from @mastra/core/agent. The minimal setup looks like this:
import { Agent } from '@mastra/core/agent'
export const myAgent = new Agent({
id: 'my-agent',
name: 'My Agent',
instructions: 'You are a helpful assistant.',
model: 'openai/gpt-4o',
})
Register it in your root Mastra instance to give it access to shared memory, logging, and the agent registry:
import { Mastra } from '@mastra/core'
import { myAgent } from './agents/my-agent'
export const mastra = new Mastra({
agents: { myAgent },
})
From there, you can call agent.generate() for a full response or agent.stream() to get a token stream. The docs note that you should retrieve agents via mastra.getAgentById() rather than importing them directly, so that the agent gets access to instance-level shared services.
Beyond the basics, agents support structured output (typed objects instead of plain text), guardrails, per-request dynamic configuration, voice input and output, and message processors that transform content before and after generation. Multi-agent systems are supported through a supervisor pattern where one agent routes tasks to specialized subagents.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
From the archive
Jun 10, 2026 • 7 min read
Jun 10, 2026 • 7 min read
Jun 10, 2026 • 8 min read
Jun 10, 2026 • 9 min read
Workflows are the other main primitive, and the distinction the docs draw is important: use agents when the steps are unknown, use workflows when they are defined upfront. Workflows give you fine-grained control over how data flows between steps, what runs in parallel, and how errors are handled.
Steps are created with createStep() using Zod (or Valibot or ArkType) schemas for input and output:
import { createStep, createWorkflow } from '@mastra/core/workflows'
import { z } from 'zod'
const formatStep = createStep({
id: 'format',
inputSchema: z.object({ message: z.string() }),
outputSchema: z.object({ formatted: z.string() }),
execute: async ({ inputData }) => ({
formatted: inputData.message.toUpperCase(),
}),
})
Workflows support suspension and resumption, which is useful for human-in-the-loop patterns where you need to pause execution, wait for approval, and then continue. For production workloads that need managed infrastructure, Mastra integrates with Inngest as a workflow runner, adding automatic retries and step memoization on top of the built-in engine.
Memory is a separate package (@mastra/memory) that you install alongside a storage provider. The default quickstart uses @mastra/libsql for local SQLite-backed storage:
npm install @mastra/memory@latest @mastra/libsql@latestMastra supports four memory modes: message history (plain conversation storage), observational memory (a background agent that distills message history into a dense observation log as it grows), working memory (persistent structured user data like preferences and goals), and semantic recall (retrieves past messages by semantic similarity rather than recency). These can be combined and filtered with memory processors when the combined context approaches the model's limit.
The observational memory mode is particularly useful for long-running assistants where raw message history would quickly fill the context window.
Mastra applications can be deployed to any Node.js-compatible environment. The mastra build command compiles your application, and the output can be deployed to any VM, container, or PaaS. First-party deployers for Vercel, Netlify, and Cloudflare automate the build and deployment process. Deployment guides also exist for Amazon EC2, AWS Lambda, Azure App Services, and DigitalOcean.
The Mastra Platform is a hosted option that adds observability (searchable traces, logs, and metrics), a hosted Studio, and a managed server deployment target. This is separate from the open source framework and has its own pricing tier.
Mastra's core framework is Apache 2.0 licensed and free to use. The Mastra Platform -- which adds hosted observability, Studio, and server deployment -- has the following tiers as of the time this was verified:
If you are self-hosting everything and only using the open source framework, the cost is zero.
Mastra is a good fit for teams building TypeScript applications where AI is a first-class concern. It is less appropriate in a few situations:
If your team is primarily Python-based, the ecosystem fit is poor. Mastra is TypeScript-first by design, and using it from Python would require running a separate Node.js service.
If you need a simple single-turn classification or extraction pipeline with no memory, no multi-step logic, and no UI, the framework is heavier than necessary. A direct SDK call to your model provider will be less code and easier to reason about.
If your deployment target does not support Node.js v22 or later, you will hit runtime compatibility issues early. Cloudflare Workers are supported, but the constraint still narrows your options compared to lighter frameworks.
Finally, if your team is not already comfortable with TypeScript generics and schema validation with Zod or similar, the typed step definitions in workflows can feel like a lot of ceremony before you get anything running.
All commands, API shapes, and pricing figures were verified against live documentation on June 10, 2026.
Yes. The core framework is released under the Apache 2.0 license, which permits commercial use without restriction. The Mastra Platform (hosted observability, Studio, and server deployment) is a separate commercial product with a free tier and paid plans starting at $250 per month. Enterprise self-hosted features have custom pricing and keep all data within your own VPC.
Mastra's model router provides access to models from OpenAI, Anthropic, Groq, Google, Cerebras, Mistral, and others -- over 3,000 models in total as of the docs at time of writing. You reference models as provider/model-name strings, so switching providers does not require changing your import structure or reinstalling packages.
Mastra is TypeScript-native and designed around typed primitives (agents, workflows, steps with Zod schemas). LangChain's JS port covers similar ground but carries architectural decisions inherited from the Python original. Mastra's workflow primitive is more opinionated about control flow and data typing, which trades flexibility for predictability. For teams starting fresh in TypeScript, Mastra is generally easier to reason about at scale.
Yes. Run mastra init in an existing project instead of using create mastra. Mastra also integrates with Next.js, React (Vite), Astro, Express, SvelteKit, and Hono. In these setups, Mastra lives alongside your existing application and deploys using the framework's standard deployment process.
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
TypeScript-first AI agent framework. Agents, tools, memory, workflows, RAG, evals, tracing, MCP, and production deployme...
View ToolThe TypeScript toolkit for building AI apps. Unified API across OpenAI, Anthropic, Google. Streaming, tool calling, stru...
View ToolFrontend stack for agent-native apps. React hooks, prebuilt copilot UI, AG-UI runtime, frontend tools, shared state, and...
View ToolLLM data framework for connecting custom data sources to language models. Best-in-class RAG, data connectors, and query...
View ToolStep-by-step guide to building an MCP server in TypeScript - from project setup to tool definitions, resource handling, testing, and deployment.
AI AgentsConfigure Claude Code for maximum productivity -- CLAUDE.md, sub-agents, MCP servers, and autonomous workflows.
AI AgentsSet up Codex Chronicle on macOS, manage permissions, and understand privacy, security, and troubleshooting.
Getting StartedFour mature, production-ready TypeScript frameworks have made building agents genuinely enjoyable. Here is how to pick t...
Every major AI coding tool just went through a pricing shift. Here are the exact numbers for Cursor, GitHub Copilot, Cla...
Factory AI's Droid agent surfaces a new competitive front in coding tools: cost-per-completed-task. Here's what their ar...
Security researchers showed a €0.02 bank transfer could compromise a banking AI assistant. Here is the exact attack chai...
Claude Managed Agents is in public beta with solid sandboxing and session persistence - but the headline orchestration f...
Both Mastra and LangGraph.js are serious TypeScript agent frameworks - but they start from opposite philosophies. Here i...

New tutorials, open-source projects, and deep dives on coding agents - delivered weekly.