examples/basics/rag/insert-embedding-in-chroma/README.md
This example demonstrates how to store embeddings in Chroma using Mastra. It shows how to:
Clone the repository and navigate to the project directory:
git clone https://github.com/mastra-ai/mastra
cd examples/basics/rag/insert-embedding-in-chroma
Install dependencies:
pnpm install
Copy the environment variables file and add your OpenAI API key:
cp .env.example .env
Then edit .env and add your OpenAI API key:
OPENAI_API_KEY=sk-your-api-key-here
If you want to use Chroma Cloud, add your Chroma Cloud API Key, tenant, and database. When you install your dependencies, you get the Chroma CLI, which can output these variables for you with chroma db connect [DB-NAME] --env-file
CHROMA_API_KEY=your-chroma-cloud-api-key
CHROMA_TENANT=your-tenant-id
CHROMA_DATABASE=your-database-name
Set up your Chroma server.
chroma run. See more configurations on the Chroma docs.ChromaVector instantiation with your specific connection requirements.Run the example:
pnpm start
The example:
This example also demonstrates features specific to ChromaDB:
Document Storage: Along with embeddings and metadata, you can store the original text documents in Chroma. This is useful for retrieving the full text during queries without needing a separate document store.
The stored embeddings and documents can then be used for similarity search and retrieval in your RAG applications.