LangChain4j integration for Chroma embedding store enabling storage, retrieval, and similarity search of vector embeddings with metadata filtering support for both API V1 and V2.
—
Enum for specifying Chroma REST API version.
package dev.langchain4j.store.embedding.chroma;
public enum ChromaApiVersionV1Chroma API V1 - compatible with Chroma 0.5.16+.
Characteristics:
Usage:
ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V1)
.baseUrl("http://localhost:8000")
.collectionName("my-collection")
.build();V2Chroma API V2 - compatible with Chroma 0.7.0+ (1.1.0).
Characteristics:
Usage:
ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V2)
.baseUrl("http://localhost:8000")
.tenantName("my-tenant")
.databaseName("my-database")
.collectionName("my-collection")
.build();| Feature | V1 | V2 |
|---|---|---|
| Chroma Version | 0.5.16+ | 0.7.0+ (1.1.0) |
| Structure | Flat | Hierarchical |
| Tenant Support | No | Yes |
| Database Support | No | Yes |
| Default Tenant | N/A | "default" |
| Default Database | N/A | "default" |
| Auto-creation | Collection | Tenant, DB, Collection |
| Configuration | Simple | More options |
If not specified, ChromaEmbeddingStore defaults to V1:
// Defaults to V1
ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.baseUrl("http://localhost:8000")
.collectionName("my-collection")
.build();
// Equivalent to
ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V1) // Default
.baseUrl("http://localhost:8000")
.collectionName("my-collection")
.build();ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V1)
.baseUrl("http://localhost:8000")
.collectionName("documents")
.build();Configuration used:
Ignored parameters:
tenantName - not used in V1databaseName - not used in V1ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V2)
.baseUrl("http://localhost:8000")
.collectionName("documents")
.build();Configuration used:
ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V2)
.baseUrl("http://localhost:8000")
.tenantName("production")
.databaseName("main")
.collectionName("documents")
.build();Configuration used:
V2 enables organizing collections by tenant and database:
// Tenant 1, Database A
ChromaEmbeddingStore store1 = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V2)
.baseUrl("http://localhost:8000")
.tenantName("customer-1")
.databaseName("production")
.collectionName("embeddings")
.build();
// Tenant 1, Database B
ChromaEmbeddingStore store2 = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V2)
.baseUrl("http://localhost:8000")
.tenantName("customer-1")
.databaseName("staging")
.collectionName("embeddings")
.build();
// Tenant 2, Database A
ChromaEmbeddingStore store3 = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V2)
.baseUrl("http://localhost:8000")
.tenantName("customer-2")
.databaseName("production")
.collectionName("embeddings")
.build();These are completely isolated from each other.
ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.baseUrl("http://localhost:8000")
.collectionName("my-collection")
.build();ChromaEmbeddingStore store = ChromaEmbeddingStore.builder()
.apiVersion(ChromaApiVersion.V2) // Add this
.baseUrl("http://localhost:8000")
.tenantName("default") // Optional, defaults to "default"
.databaseName("default") // Optional, defaults to "default"
.collectionName("my-collection")
.build();See: Migration Guide for detailed migration instructions.
ChromaEmbeddingStore uses the configured API version for all operations. There is no automatic version detection or fallback.
Important: Ensure your Chroma server version matches the API version:
// Chroma 0.5.x/0.6.x → Use V1
.apiVersion(ChromaApiVersion.V1)
// Chroma 0.7.0+ (1.1.0) → Use V2
.apiVersion(ChromaApiVersion.V2)Install with Tessl CLI
npx tessl i tessl/maven-dev-langchain4j--langchain4j-chroma