Mastra RAG

Full RAG pipeline for AI agents

Mastra handles the complete RAG pipeline and enhances LLM outputs by incorporating relevant context from your own data sources. Retrieval without a standardized pipeline means stitching together chunking, embedding, storage and retrieval across separate tools. Mastra covers the full pipeline and gives agents accurate, grounded responses.

Build your full RAG pipeline

Mastra provides standardized APIs for every step of the RAG pipeline in a single framework. Chunk documents using recursive or sliding window strategies, generate embeddings, store them in your preferred vector database and retrieve relevant context at query time. Mastra includes observability for tracking embedding and retrieval performance.

.embed()

.query()

.rerank()

Embed, query and rerank

Transform document chunks into vector embeddings using your preferred embedding model, retrieve semantically similar chunks from your vector store at query time and rerank retrieved results for more accurate and context-aware responses

Give agents knowledge of your data

When agents need answers grounded in your data, Mastra RAG incorporates relevant context from your own sources into every LLM response. Control how documents are chunked, choose your embedding strategy and store vectors in the database you prefer. Use filters for precise retrieval tailored to your pipeline.

Advanced RAG techniques

Mastra goes beyond standard retrieval with context engineering techniques for more accurate, grounded responses. ReAG enables models to reason directly over your documents rather than retrieving pre-embedded chunks. Graph RAG and agentic RAG extend context engineering with structured knowledge and agent-driven retrieval.

Reasoning-Augmented Generation

Reason directly over documents for more accurate, context-aware answers with ReAG

Advanced Context Engineering

Shape context using memory, history and RAG for results grounded in real information

Python trains,
TypeScript ships.