Blog

A framework for the next million AI developers

Nov 20, 2024

Today we're excited to announce Mastra, a Typescript AI framework that Abhi Aiyer, Shane Thomas, and I are building.

Brief backstory: last year, after spending the better part of a decade building Gatsby, we joined Netlify. And earlier this year, we began building an AI-powered CRM called Kepler.

Building Kepler, we tried a few different frameworks for the AI bits. Each time, we ended up ripping out most of the code as we tried to make our pipelines more reliable. So we switched gears.

We wanted to create an AI framework that's fun to build toy projects with, but sturdy enough to take into production.

We wanted to build for product developers: frontend, fullstack, backend, the kinds of folks that had fun toying on their Gatsby blogs years and years ago. The kind of folks who will be (we think) the next million AI engineers.

We're launching today, and we're excited to share both our project and our principles:

Typescript-first, Typescript-only. Typescript is the language of product development. And these days "APIs are all you need" for AI development.

The Python tie-in of current AI frameworks is a legacy holdover. Sure, Pythonic frameworks have JS/TS ports, but they're an afterthought with a fraction of the features and docs/examples.

A great framework should be mono-lingual to work with language-specific package managers, testing tools, and ORMs. And Typescript developers want a great tool that's built for them.

Workflow graph based. LLM applications are non-deterministic pipelines. One emergent practice is defining discrete steps, logging inputs and outputs at each step of each run, and piping them into an observability tool.

Mastra includes a workflow graph that encapsulates loops, branching, waiting for human input, embedding other workflows, error handling, retries, and so on.

Domain-complete. Most developers prefer to use a framework that has opinions about all the key jobs-to-be-done in a domain. Kubernetes for running infra, Terraform for provisioning it, Next.js for websites.

Mastra has carefully curated top-level nouns for all the key concerns in AI engineering: LLMs, agents, workflows, RAG, observability, evals, integrations & syncs. But we don't want to reinvent the wheel, and in many cases choose to build on top of great libraries (AI SDK, autoevals).

Object-sparse, example-rich. Many frameworks hand users flat lists of dozens of classes. But more API surface area is a liability, not an asset. Objects should be scoped to the correct top-level concern. Integrations should be scoped to an appropriate provider model. A rich library of code examples should cover use-cases.

This one comes from painful experience: "too many, poorly organized APIs" was one of Gatsby's main weaknesses -- and a mistake we see AI frameworks making.

Domain-specific grammar. AI engineering is building production-ready ETL pipelines and should be described with dataflow nouns and verbs.

We prefer concrete nouns ("workflow", "step", "connection") to abstract nouns ("graph", "node", "edge") or adjectives ("runnable"). We prefer verbs ("extract") to agent nouns ("TextExtractor"). We prefer them because it's the proper way to write TypeScript. Frameworks are DSLs and need domain- and language-specific grammar.

Explicit, no indirection. Many framework APIs help people get started by hiding prompt engineering and retry logic in their APIs. These indirections speed up the "aha!" moment but are notoriously difficult to debug.

It's why many engineers (us included, when we were building Kepler) used frameworks for the first 90% of their project...then for the next 90% ripped and replaced them with vanilla model API calls.

(And anyway, Claude on Cursor is a good enough prompt engineer to get started.)

Deployable to a serverless or public cloud. It's 2024. You should be able to easily deploy agents and workflows to a serverless cloud and access them as API endpoints.

We're building examples and guides for you to deploy wherever you want. (We're also building a simple cloud-based agent/workflow runtime with a generous free tier.)

Let's build together

We're excited to see what you'll build. Please npm/pnpm/yarn install mastra and tell us everything you love or hate.

See you on Github :)

Author

SB

Sam Bhagwat

Share