Skip to content
Docs

ChromaDB Vector Store Provider

The ChromaDB provider implements the vectorstore.VectorStore interface using ChromaDB’s REST API. ChromaDB is an open-source embedding database with a simple API, supporting multi-tenant deployments.

Choose ChromaDB for its simplicity and ease of setup. ChromaDB is straightforward to run locally with Docker and requires minimal configuration, making it a good choice for prototyping and small-to-medium workloads. Its multi-tenant support (tenants and databases) allows data isolation without separate deployments.

Terminal window
go get github.com/lookatitude/beluga-ai/rag/vectorstore/providers/chroma

Start ChromaDB locally:

Terminal window
docker run -p 8000:8000 chromadb/chroma
package main
import (
"context"
"log"
"github.com/lookatitude/beluga-ai/config"
"github.com/lookatitude/beluga-ai/rag/vectorstore"
"github.com/lookatitude/beluga-ai/schema"
_ "github.com/lookatitude/beluga-ai/rag/vectorstore/providers/chroma"
)
func main() {
store, err := vectorstore.New("chroma", config.ProviderConfig{
BaseURL: "http://localhost:8000",
Options: map[string]any{
"collection": "my_documents",
},
})
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
docs := []schema.Document{
{ID: "doc1", Content: "Go is a statically typed language", Metadata: map[string]any{"lang": "en"}},
}
embeddings := [][]float32{make([]float32, 1536)}
err = store.Add(ctx, docs, embeddings)
if err != nil {
log.Fatal(err)
}
}
ParameterTypeDefaultDescription
BaseURLstring(required)ChromaDB server URL
Options["collection"]string(none)Collection name
Options["tenant"]stringdefault_tenantTenant name
Options["database"]stringdefault_databaseDatabase name

The provider automatically creates collections via get_or_create semantics. You can also explicitly ensure a collection exists:

import (
chromastore "github.com/lookatitude/beluga-ai/rag/vectorstore/providers/chroma"
)
store := chromastore.New("http://localhost:8000",
chromastore.WithCollection("my_collection"),
)
err := store.EnsureCollection(ctx)
if err != nil {
log.Fatal(err)
}
store := chromastore.New("http://localhost:8000",
chromastore.WithCollection("my_collection"),
chromastore.WithTenant("my_tenant"),
chromastore.WithDatabase("my_database"),
)

If you already know the collection ID, skip the resolution step:

store := chromastore.New("http://localhost:8000",
chromastore.WithCollectionID("abc-123-def-456"),
)

ChromaDB supports metadata filtering with its $eq operator:

results, err := store.Search(ctx, queryVec, 10,
vectorstore.WithFilter(map[string]any{
"lang": "en",
}),
)

ChromaDB returns distances (lower = more similar). The provider converts them to similarity scores using the formula 1 / (1 + distance):

results, err := store.Search(ctx, queryVec, 10,
vectorstore.WithThreshold(0.5),
)

ChromaDB supports multi-tenant deployments via the tenant and database parameters:

store, err := vectorstore.New("chroma", config.ProviderConfig{
BaseURL: "http://localhost:8000",
Options: map[string]any{
"collection": "shared_docs",
"tenant": "org_123",
"database": "prod",
},
})