Skip to main content
Chroma is an AI-native open-source vector database that simplifies building LLM apps by providing tools for storing, embedding, and searching embeddings with a focus on simplicity and speed. It supports both local deployment and cloud hosting through ChromaDB Cloud.

Usage

import os
from mem0 import Memory

os.environ["OPENAI_API_KEY"] = "sk-xx"

config = {
    "vector_store": {
        "provider": "chroma",
        "config": {
            "collection_name": "test",
            "path": "db",
            # Optional: ChromaDB Cloud configuration
            # "api_key": "your-chroma-cloud-api-key",
            # "tenant": "your-chroma-cloud-tenant-id",
        }
    }
}

m = Memory.from_config(config)
messages = [
    {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
    {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."},
    {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
    {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
]
m.add(messages, user_id="alice", metadata={"category": "movies"})
import { Memory } from 'mem0ai/oss';

// The Node.js client connects to a running Chroma server.
// Start one locally with: chroma run --host localhost --port 8000
const config = {
  vectorStore: {
    provider: 'chroma',
    config: {
      collectionName: 'memories',
      host: 'localhost',
      port: 8000,
      // Optional: ChromaDB Cloud configuration
      // apiKey: 'your-chroma-cloud-api-key',
      // tenant: 'your-chroma-cloud-tenant-id',
    },
  },
};

const memory = new Memory(config);
const messages = [
    {"role": "user", "content": "I'm planning to watch a movie tonight. Any recommendations?"},
    {"role": "assistant", "content": "How about thriller movies? They can be quite engaging."},
    {"role": "user", "content": "I’m not a big fan of thriller movies but I love sci-fi movies."},
    {"role": "assistant", "content": "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future."}
]
await memory.add(messages, { userId: "alice", metadata: { category: "movies" } });
The Node.js SDK uses the chromadb v3 client, which talks to a Chroma server over HTTP (local server or ChromaDB Cloud). Install it with npm install chromadb. Mem0 supplies the embeddings, so the collection is created without an embedding function.

Config

Here are the parameters available for configuring Chroma:
ParameterDescriptionDefault Value
collection_nameThe name of the collectionmem0
clientCustom client for ChromaNone
pathPath for the Chroma databasedb
hostThe host where the Chroma server is runningNone
portThe port where the Chroma server is runningNone
api_keyChromaDB Cloud API key (for cloud usage)None
tenantChromaDB Cloud tenant ID (for cloud usage)None