RAG Pipeline
The simplest way to build a full agent RAG pipeline in TypeScript
Mastra handles the complete RAG pipeline and enhances LLM outputs by incorporating relevant context from your own data sources. As a dedicated RAG platform, it replaces the need to stitch together chunking, embedding, storage and retrieval across separate tools 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, making it a complete RAG service for production use.
Chunking and Embedding
Split documents and transform into vectors
Vector Database
Choose from supported vector store providers
Retrieval
Retrieve using advanced metadata filtering
Give agents knowledge of your data
Mastra RAG gives agents access to relevant context from your own data sources at query time. Connect your vector store to an agent and Mastra retrieves semantically similar chunks to include in the LLM prompt, grounding agent responses in real information. This RAG platform makes it straightforward to build agents that stay accurate.
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 full documents
Frequently asked questions
How does RAG work in Mastra?
What vector databases does Mastra RAG support?
What chunking strategies does Mastra RAG support?
How does Mastra RAG integrate with agents?
What is ReAG and how does Mastra support it?
Ship better agents
Build production RAG pipelines on the open-source framework for AI agents