
DSPy vs Mastra: Which is Better in 2026?
DSPy and Mastra are both Agent Framework tools, made for different people. DSPy is for teams with an evaluation set who want to optimize prompts and LLM pipelines against a metric instead of hand-tuning them. Mastra is for TypeScript teams that want agents, workflows, memory, evals and observability in one framework instead of assembling them.
Quick verdict
There’s no single winner; pick on your constraint. Choose DSPy if you have examples and a metric, and want prompts tuned automatically. Choose Mastra if you work in TypeScript and want workflows, memory and evals included.
DSPy vs Mastra: Side by Side
| DSPy | Mastra | |
|---|---|---|
| Category | Agent Framework | Agent Framework |
| What it is | Code library: framework for optimizing prompts and LLM programs | Code library: TypeScript agent framework with workflows |
| Languages | Python | TypeScript |
| Licence | MIT | Apache 2.0 core; enterprise features under a separate licence |
| Managed / paid option | None | Mastra Cloud: free Starter, Teams $250/month |
| Project status | Active; 3.x | Active; 1.x |
| Pricing | Free | Free · then usage-based |
| Starting price | Free tier available | Free tier available |
| Free tier | ||
| Rating | 4.2 | 4.6 |
| Best for | Agent Framework: prompt optimization, evaluation-driven, research-backed | Agent Framework: TypeScript agents, workflows and memory, batteries included |
Ratings are App Stack Builder’s editorial score out of 5, not an average of user reviews.
Pros & Cons
- Replaces prompt tinkering with measurable optimisation
- Strong research backing (Stanford)
- Composes well with any model provider
- A genuinely different mental model to learn
- Optimisation runs cost tokens
- Built for TypeScript teams
- Batteries-included (agents, workflows, memory, evals)
- From the experienced Gatsby team
- Strong observability & MCP support
- Younger than Python frameworks
- TypeScript-only ecosystem
Key Features Compared
DSPy
- Signatures and modules replace hand-written prompts
- Optimizers, including GEPA, that tune prompts against your metric
- Works with most model providers
- From Stanford NLP
- MIT licence
Mastra
- Agents, a graph-based workflow engine and memory in one package
- Built-in evals and observability
- MCP support for sharing tools
- Mastra Cloud: free Starter, Teams at $250 a month, Enterprise on quote
- Apache 2.0 core; enterprise features under a separate Mastra Enterprise Licence
Choose DSPy if…
- You have examples and a metric, and want prompts tuned automatically.
- Your pipeline keeps breaking when you switch models, and you want to re-optimize instead of rewriting prompts.
Choose Mastra if…
- You work in TypeScript and want workflows, memory and evals included.
- You want an optional managed cloud from the same team.
- You want MCP tool sharing built in.
Frequently Asked Questions
Is DSPy better than Mastra?⌄
There’s no single winner; pick on your constraint. Choose DSPy if you have examples and a metric, and want prompts tuned automatically. Choose Mastra if you work in TypeScript and want workflows, memory and evals included.
What is the difference between DSPy and Mastra?⌄
What it is. DSPy: Code library: framework for optimizing prompts and LLM programs. Mastra: Code library: TypeScript agent framework with workflows. Languages. DSPy: Python. Mastra: TypeScript. Licence. DSPy: MIT. Mastra: Apache 2.0 core; enterprise features under a separate licence. Managed / paid option. DSPy: None. Mastra: Mastra Cloud: free Starter, Teams $250/month. Project status. DSPy: Active; 3.x. Mastra: Active; 1.x.
DSPy vs Mastra: which is cheaper?⌄
DSPy pricing: Free. Mastra pricing: Free · then usage-based. Confirm current pricing on each tool's official site, as plans change.
Which is rated higher, DSPy or Mastra?⌄
On our editorial score, DSPy is 4.2 out of 5 and Mastra is 4.6 out of 5, so Mastra is slightly ahead. This is our own score, not an average of user reviews.
When should I skip both DSPy and Mastra?⌄
Skip DSPy if you don’t have an evaluation set yet. DSPy’s optimizers need one to work. Skip Mastra if your team writes Python. LangGraph or CrewAI fit better.
Sources · tool facts checked October 2026
See more options in our guide to the best agent framework tools for startups.
Still not sure which to pick?
Get a free, AI-powered tech stack, including the best agent framework pick for your budget and team, in 60 seconds.