- Indexing — Chunk documents, embed them into vectors, and store them in a vector database.
- Retrieval + Generation — Embed the user’s query, retrieve the most similar documents, and include them in the prompt.
The three RAG primitives
Embedders
An embedder converts text (or other content) into a numeric vector for similarity search.Indexers
An indexer takes documents and stores them in a vector database.Retrievers
A retriever takes a query and returns the most relevant documents.Indexing documents
Useai.index() to store documents via any registered indexer:
Retrieving documents
Useai.retrieve() to fetch relevant documents at query time:
End-to-end RAG flow
Here is a complete example that combines indexing and retrieval into a working Q&A application:- TypeScript
- Go
- Python
docs option on generate() and let Genkit format them for you:Plugin-provided vector stores
In production you will use a plugin-provided indexer and retriever rather than hand-rolling one. Genkit plugins are available for the most popular vector stores:| Vector Store | Plugin | Notes |
|---|---|---|
| Firebase / Firestore | @genkit-ai/firebase | Serverless, no infrastructure to manage. |
| Vertex AI Vector Search | @genkit-ai/google-genai | Managed, high scale. |
| Pinecone | genkitx-pinecone | Fully managed vector database. |
| Chroma | genkitx-chromadb | Open-source, great for local dev. |
| Local dev store | @genkit-ai/dev-local-vectorstore | In-process, no setup needed for local testing. |
Example: local dev vector store
Example: Firebase Firestore vector store
Defining a simple retriever
If you already have data in a database and just need to map query results toDocument objects, defineSimpleRetriever is a convenient shorthand:
Next steps
Firebase Plugin
Firestore-backed vector store and Firebase deployment.
Vertex AI Plugin
Vertex AI Vector Search and Gemini embeddings.
Flows
Wrap RAG logic in traced, deployable flows.
Evaluation
Measure RAG pipeline quality with built-in evaluators.
