Chroma
The Chroma plugin registers retrievers and indexers backed by a Chroma server (v2 REST API) for Retrieval-Augmented Generation.
Installation
Section titled “Installation”<dependency> <groupId>com.google.genkit</groupId> <artifactId>genkit-plugin-chroma</artifactId> <version>1.0.0-SNAPSHOT</version></dependency>Requirements
Section titled “Requirements”- A running Chroma server (
docker run -p 8000:8000 chromadb/chroma) - Java 21+
- An embedder (e.g. from the Google GenAI plugin)
ChromaPlugin registers a retriever and indexer named chroma/<collectionName> for each configured collection.
import com.google.genkit.plugins.chroma.ChromaCollectionConfig;import com.google.genkit.plugins.chroma.ChromaPlugin;
Genkit genkit = Genkit.builder() .plugin(GoogleGenAIPlugin.create(apiKey)) .plugin( ChromaPlugin.builder() .url("http://localhost:8000") // default .addCollection( ChromaCollectionConfig.builder() .collectionName("films") .embedderName("googleai/gemini-embedding-001") .distance(ChromaCollectionConfig.Distance.COSINE) .createCollectionIfNotExists(true) // default .build()) .build()) .build();
// Index and retrievegenkit.index("chroma/films", documents);List<Document> results = genkit.retrieve("chroma/films", "a Christopher Nolan sci-fi film");Configuration
Section titled “Configuration”Tune per-collection settings with ChromaCollectionConfig:
collectionName— the Chroma collection name (required)embedderName— the embedder used to vectorize documents and queries (required)distance—COSINE(default),L2, orINNER_PRODUCTcreateCollectionIfNotExists— auto-create the collection (defaulttrue)addAdditionalMetadata(key, value)— metadata merged into every indexed document
Plugin-level tenant and database default to default_tenant / default_database.
Sample
Section titled “Sample”See the chroma sample.