chroma Documentation

Search infrastructure for AI

29,042 stars Rust Rust 1 file ยท ~7,916 tokens #agents#ai#ai-agents#database#rust#rust-lang
RAW Doc

Docker & Self-Hosted Deployment Verified OCI

Deploy chroma on any server, homelab, or cloud container platform.

1-Click Terminal Command
bash (docker run)
docker run -d --name chroma -p 8000:8000 --restart always ghcr.io/chroma-core/chroma:${ChromaVersion}
Configured Services & Ports
โš™๏ธ server
image: ghcr.io/chroma-core/chroma:${ChromaVersion}
๐Ÿ”Œ Ports: 8000:8000
docker-compose.yml
yaml (docker-compose.yml)
version: '3.9'

networks:
  net:
    driver: bridge

services:
  server:
    image: ghcr.io/chroma-core/chroma:${ChromaVersion}
    volumes:
      - index_data:/index_data
    ports:
      - 8000:8000
    networks:
      - net

volumes:
  index_data:
    driver: local
  backups:
    driver: local

1. Project Overview & Quickstart (chroma-core/chroma)

File: README.md

bash
pip install chromadb # python client
# for javascript, npm install chromadb!
# for client-server mode, chroma run --path /chroma_db_path

Chroma Cloud

Our hosted service, Chroma Cloud, powers serverless vector, hybrid, and full-text search. It's extremely fast, cost-effective, scalable and painless. Create a DB and try it out in under 30 seconds with $5 of free credits.

Get started with Chroma Cloud

API

The core API is only 4 functions (run our ๐Ÿ’ก Google Colab):

python
import chromadb
# setup Chroma in-memory, for easy prototyping. Can add persistence easily!
client = chromadb.Client()

# Create collection. get_collection, get_or_create_collection, delete_collection also available!
collection = client.create_collection("all-my-documents")

# Add docs to the collection. Can also update and delete. Row-based API coming soon!
collection.add(
    documents=["This is document1", "This is document2"], # we handle tokenization, embedding, and indexing automatically. You can skip that and add your own embeddings as well
    metadatas=[{"source": "notion"}, {"source": "google-docs"}], # filter on these!
    ids=["doc1", "doc2"], # unique for each doc
)

# Query/search 2 most similar results. You can also .get by id
results = collection.query(
    query_texts=["This is a query document"],
    n_results=2,
    # where={"metadata_field": "is_equal_to_this"}, # optional filter
    # where_document={"$contains":"search_string"}  # optional filter
)

Learn about all features on our Docs

Get involved

Chroma is a rapidly developing project. We welcome PR contributors and ideas for how to improve the project.

Release Cadence
We currently release new tagged versions of the pypi and npm packages on Mondays. Hotfixes go out at any time during the week.

License

Apache 2.0


File: chromadb/telemetry/README.md

Telemetry

This directory holds all the telemetry for Chroma.

  • product/ contains anonymized product telemetry which we, Chroma, collect so we can
    understand usage patterns. For more information, see https://docs.trychroma.com/telemetry.
  • opentelemetry/ contains all of the config for Chroma's OpenTelemetry
    setup. These metrics are not sent back to Chroma -- anyone operating a Chroma instance
    can use the OpenTelemetry metrics and traces to understand how their instance of Chroma
    is behaving.

File: chromadb/utils/embedding_functions/schemas/README.md

Embedding Function Schemas

This directory contains JSON schemas for all embedding functions in Chroma. The purpose of having this schema is to support cross language compatibility, and to validate that changes in one client library do not accidentally diverge from others.

Schema Structure

Each schema follows the JSON Schema Draft-07 specification and includes:

  • version: The version of the schema
  • title: The title of the schema
  • description: A description of the schema
  • properties: The properties that can be configured for the embedding function
  • required: The properties that are required for the embedding function
  • additionalProperties: Whether additional properties are allowed (always set to false to ensure strict validation)

Usage

The schemas can be used to validate the configuration of embedding functions using the validate_config function:

python
from chromadb.utils.embedding_functions.schemas import validate_config

# Validate a configuration
config = {
    "api_key_env_var": "CHROMA_OPENAI_API_KEY",
    "model_name": "text-embedding-ada-002"
}
validate_config(config, "openai")

Adding New Schemas

To add a new schema:

  1. Create a new JSON file in this directory with the name of the embedding function (e.g., new_function.json)
  2. Define the schema following the JSON Schema Draft-07 specification
  3. Update the embedding function to use the schema for validation

Schema Versioning

Each schema includes a version number to support future changes to embedding function configurations. When making changes to a schema, increment the version number to ensure backward compatibility.


File: clients/python/README.md

bash
pip install chromadb-client # python http-client only library

To connect to your server and perform operations using the client only library, you can do the following:

python
import chromadb
# Example setup of the client to connect to your chroma server
client = chromadb.HttpClient(host="localhost", port=8000)

collection = client.create_collection("all-my-documents")

collection.add(
    documents=["This is document1", "This is document2"],
    metadatas=[{"source": "notion"}, {"source": "google-docs"}], # filter on these!
    ids=["doc1", "doc2"], # unique for each doc
    embeddings = [[1.2, 2.1, ...], [1.2, 2.1, ...]]
)

results = collection.query(
    query_texts=["This is a query document"],
    n_results=2,
    # where={"metadata_field": "is_equal_to_this"}, # optional filter
    # where_document={"$contains":"search_string"}  # optional filter
)

License

Apache 2.0


File: clients/js/examples/node/README.md

Node Example

This is an example of how to use ChromaDB with Node.js.

Getting Started

  1. Make sure you have Chroma running locally at http://localhost:8000
  2. Run pnpm install to install dependencies
  3. Run one of the following commands:
  • pnpm dev - Run the example with the default bundled package
  • pnpm dev:bundled - Run the example with the bundled chromadb package
  • pnpm dev:client - Run the example with the chromadb-client package (peer dependencies)

Package Options

This example demonstrates both ChromaDB package options:

  1. chromadb (Bundled Package): Includes all embedding libraries as dependencies.

    • Good for simple projects or when you want everything included.
    • Import with: const chroma = require("chromadb");
  2. chromadb-client (Client Package): Uses peer dependencies.

    • Good for projects that already use specific versions of embedding libraries.
    • Keeps your dependency tree lean if you only need specific embedding libraries.
    • Import with: const chroma = require("chromadb-client");

Both packages provide identical functionality and API.


File: clients/js/examples/README.md

ChromaDB Examples

This directory contains examples for using both ChromaDB package options:

  1. chromadb: Bundled package with all dependencies included
  2. chromadb-client: Package with peer dependencies that you install separately

Node.js Example

The Node.js example demonstrates how to use ChromaDB in a Node.js environment.

bash
cd node
pnpm install

# Run with the default bundled package
pnpm dev

# Run with the bundled package explicitly
pnpm dev:bundled

# Run with the client package (peer dependencies)
pnpm dev:client

Browser Example

The browser example demonstrates how to use ChromaDB in a browser environment.

bash
cd browser
pnpm install

# Run with the default bundled package
pnpm dev

# Run with the bundled package explicitly
pnpm dev:bundled

# Run with the client package (peer dependencies)
pnpm dev:client

Differences Between Package Options

  • The bundled package (chromadb) includes all embedding libraries as dependencies, making it easier to get started.
  • The client package (chromadb-client) uses peer dependencies, giving you more control over which versions of embedding libraries you use. It also keeps your dependency tree leaner if you only need specific embedding libraries.

Both packages offer identical functionality and API.


File: clients/js/packages/chromadb-core/src/generated/README.md

API

This generator creates TypeScript/JavaScript client that utilizes Fetch API. The generated Node module can be used in the following environments:

Environment

  • Node.js
  • Webpack
  • Browserify

Language level

  • ES5 - you must have a Promises/A+ library installed
  • ES6

Module system

  • CommonJS
  • ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via package.json. (Reference)

Building

To build an compile the typescript sources to javascript use:

text
npm install
npm run build

Publishing

First build the package then run npm publish

Consuming

Navigate to the folder of your consuming project and run one of the following commands:

shell
npm install PATH_TO_GENERATED_PACKAGE --save

File: clients/js/packages/chromadb-client/README.md

ChromaDB Client

Chroma is the open-source data infrastructure for AI. Chroma makes it easy to build LLM apps by making knowledge, facts, and skills pluggable for LLMs.

Note: JS client version 3._ is only compatible with chromadb v1.0.6 and newer or Chroma Cloud. For prior version compatiblity, please use JS client version 2._.

This package provides embedding libraries as peer dependencies, allowing you to manage your own versions of embedding libraries and keep your dependency tree lean by not bundling dependencies you don't use. For a thick client with bundled embedding functions, install chromadb.

Features

  • โœ… Complete TypeScript support
  • โœ… Embedding libraries as peer dependencies for a smaller package size
  • โœ… Works in both Node.js and browser environments
  • โœ… Only install the embedding libraries you need

Installation

bash
# npm
npm install chromadb-client

# pnpm
pnpm add chromadb-client

# yarn
yarn add chromadb-client

You'll need to install any required embedding libraries separately. For example:

bash
# For OpenAI embeddings
npm install chromadb-client openai

# For default embeddings
npm install chromadb-client chromadb-default-embed

# For Cohere embeddings
npm install chromadb-client cohere-ai

Getting Started

Chroma needs to be running in order for this client to talk to it. Please see the Usage Guide to learn how to quickly stand this up.

js
import { ChromaClient } from "chromadb-client";

// Initialize the client
const chroma = new ChromaClient({ path: "http://localhost:8000" });

// Create a collection
const collection = await chroma.createCollection({ name: "my-collection" });

// Add documents to the collection
await collection.add({
  ids: ["id1", "id2"],
  embeddings: [
    [1.1, 2.3, 3.2],
    [4.5, 6.9, 4.4],
  ],
  metadatas: [{ source: "doc1" }, { source: "doc2" }],
  documents: ["Document 1 content", "Document 2 content"],
});

// Query the collection
const results = await collection.query({
  queryEmbeddings: [1.1, 2.3, 3.2],
  nResults: 2,
});

Using Embedding Functions

Make sure to install the necessary peer dependencies before using embedding functions:

js
// First install: npm install chromadb-client openai
import { ChromaClient, OpenAIEmbeddingFunction } from "chromadb-client";

const embedder = new OpenAIEmbeddingFunction({
  openai_api_key: "your-api-key",
  model_name: "text-embedding-ada-002",
});

const chroma = new ChromaClient({ path: "http://localhost:8000" });
const collection = await chroma.createCollection({
  name: "my-collection",
  embeddingFunction: embedder,
});

// Now you can add documents without providing embeddings
await collection.add({
  ids: ["id1"],
  documents: ["Document content"],
});

// And query with text
const results = await collection.query({
  queryTexts: ["similar document"],
  nResults: 2,
});

Available Embedding Functions

This package supports multiple embedding providers as peer dependencies:

  • OpenAI (openai)
  • Cohere (cohere-ai)
  • Default embeddings (chromadb-default-embed)
  • Google Generative AI (@google/generative-ai)
  • Xenova Transformers (@xenova/transformers)
  • Voyage AI (voyageai)
  • Ollama (ollama)

Why choose chromadb-client?

  • Smaller package size: Only install the dependencies you need
  • Flexible dependency versions: Manage your own versions of embedding libraries
  • Less bloat: Ideal for production environments where you only use specific embedding providers
  • Same functionality: Provides identical features as the main chromadb package

Additional Resources

License

Apache 2.0


File: clients/js/packages/chromadb/README.md

ChromaDB JavaScript Client

Chroma is the open-source data infrastructure for AI. Chroma makes it easy to build LLM apps by making knowledge, facts, and skills pluggable for LLMs.

This package includes all embedding libraries as bundled dependencies, providing a simple installation experience without worrying about dependency management. For a thin client, install chromadb-client

Features

  • โœ… Complete TypeScript support
  • โœ… All embedding libraries included as bundled dependencies
  • โœ… Works in both Node.js and browser environments
  • โœ… Simple installation with no peer dependency requirements

Installation

bash
# npm
npm install chromadb

# pnpm
pnpm add chromadb

# yarn
yarn add chromadb

Getting Started

Chroma needs to be running in order for this client to talk to it. Please see the Usage Guide to learn how to quickly stand this up.

js
import { ChromaClient } from "chromadb";

// Initialize the client
const chroma = new ChromaClient({ path: "http://localhost:8000" });

// Create a collection
const collection = await chroma.createCollection({ name: "my-collection" });

// Add documents to the collection
await collection.add({
  ids: ["id1", "id2"],
  embeddings: [
    [1.1, 2.3, 3.2],
    [4.5, 6.9, 4.4],
  ],
  metadatas: [{ source: "doc1" }, { source: "doc2" }],
  documents: ["Document 1 content", "Document 2 content"],
});

// Query the collection
const results = await collection.query({
  queryEmbeddings: [1.1, 2.3, 3.2],
  nResults: 2,
});

Using Embedding Functions

This package includes all embedding libraries as bundled dependencies, so you can use them directly:

js
import { ChromaClient, OpenAIEmbeddingFunction } from "chromadb";

const embedder = new OpenAIEmbeddingFunction({
  openai_api_key: "your-api-key",
  model_name: "text-embedding-ada-002",
});

const chroma = new ChromaClient({ path: "http://localhost:8000" });
const collection = await chroma.createCollection({
  name: "my-collection",
  embeddingFunction: embedder,
});

// Now you can add documents without providing embeddings
await collection.add({
  ids: ["id1"],
  documents: ["Document content"],
});

// And query with text
const results = await collection.query({
  queryTexts: ["similar document"],
  nResults: 2,
});

Additional Resources

License

Apache 2.0


File: clients/js/README.md

chromadb

Chroma is the open-source data infrastructure for AI. Chroma makes it easy to build LLM apps by making knowledge, facts, and skills pluggable for LLMs.

This package gives you a JS/TS interface to talk to a backend Chroma DB over REST.

Note: JS client version 3._ is only compatible with chromadb v1.0.6 and newer or Chroma Cloud. For prior version compatibility, please use JS client version 2._.

Learn more about Chroma

Package Options

There are two packages available for using ChromaDB in your JavaScript/TypeScript projects:

  1. chromadb: Includes all embedding libraries as bundled dependencies.

    • Use this if you want a simple installation without worrying about dependency management.
    • Install with: npm install chromadb or pnpm add chromadb
  2. chromadb-client: Provides embedding libraries as peer dependencies.

    • Use this if you want to manage your own versions of embedding libraries, or embed outside of Chroma.
    • Keeps your dependency tree lean by not bundling dependencies you don't use.
    • Install with: npm install chromadb-client or pnpm add chromadb-client
    • You'll need to install any required embedding libraries separately, e.g., npm install chromadb-client chromadb-default-embed

Both packages provide identical functionality, differing only in how dependencies are managed.

Getting started

Chroma needs to be running in order for this client to talk to it. Please see the ๐Ÿงช Usage Guide to learn how to quickly stand this up.

Small example

js
import { ChromaClient } from "chromadb"; // or "chromadb-client"
const chroma = new ChromaClient({ path: "http://localhost:8000" });
const collection = await chroma.createCollection({ name: "test-from-js" });
for (let i = 0; i < 20; i++) {
  await collection.add({
    ids: ["test-id-" + i.toString()],
    embeddings: [1, 2, 3, 4, 5],
    documents: ["test"],
  });
}
const queryData = await collection.query({
  queryEmbeddings: [1, 2, 3, 4, 5],
  queryTexts: ["test"],
});

Local development

View the Development Readme

License

Apache 2.0

2. Official Technical Reference & Guides (chroma-core/docs)

File: README.md

Deprecated

The docs are now in a monorepo with the rest of the codebase.

Read the new readme here:

https://github.com/chroma-core/chroma/tree/main/docs/docs.trychroma.com


Chroma docs

These docs are built using Docusaurus 2

Installation

text
$ yarn

Local Development

text
$ yarn start

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

Build

text
$ yarn build

This command generates static content into the build directory and can be served using any static contents hosting service.

Generating Python Docs

  1. Have chroma as a sibling to the the docs dir, eg
text
/docs
/chroma
  1. Update pydoc-markdown.yml if you need to expose more files other than Collection and Client

  2. Run yarn gen-python

Deployment

Vercel handles deploying main to https://docs.trychroma.com

Generating Javascript Docs

  1. Have chroma as a sibling to the the docs dir, eg
text
/docs
/chroma
  1. Update scripts/jsDocs.sh, sidebar.json if you need to expose more files other than Collection and Client

  2. Run yarn gen-js


File: docs/intro.md


Chroma

Chroma is the open-source embedding database. Chroma makes it easy to build LLM apps by making knowledge, facts, and skills pluggable for LLMs.


Chroma gives you the tools to:

  • store embeddings and their metadata
  • embed documents and queries
  • search embeddings

Chroma prioritizes:

  • simplicity and developer productivity
  • analysis on top of search
  • it also happens to be very quick

Chroma consists of a Python client SDK, JavaScript/TypeScript client SDK and a server application. Check out the Colab demo.(yes, it can run in a notebook ๐Ÿ˜„)

Chroma is licensed under Apache 2.0

Python

In Python, Chroma can run in-memory or in client/server (in alpha) mode.

bash
pip install chromadb

JavaScript

In JavaScript, Chroma runs in client/server mode and talks to a Python backend.

bash
npm install --save chromadb # yarn add chromadb

Continue with the full getting started guide.

๐Ÿ”‘ Getting started
๐Ÿงช Usage Guide
๐Ÿงฌ Embeddings
๐Ÿ“„ API Reference
๐Ÿ‘ฝ About

๐Ÿ’ฌ Join Community Discord
@trychroma


Language Support

in-memory client
Python โœ… โœ… (by Chroma)
Javascript โž– โœ… (by Chroma)
Ruby โž– โœ… from @mariochavez
Java โž– โœ… from @t_azarov
Go โž– โœ… from @t_azarov
C# โž– โœ… from @microsoft
Rust โž– โœ… from @Anush008
Elixir โž– โœ… from @3zcurdia
Dart โž– โœ… from @davidmigloz
PHP โž– โœ… from @CodeWithKyrian
PHP (Laravel) โž– โœ… from @HelgeSverre
Other? โ“ โ“

We welcome contributions for other languages!

Learn more on the Community Discord.


File: docs/getting-started.md


๐Ÿ”‘ Getting started

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Select a language


Chroma is a database for building AI applications with embeddings. It comes with everything you need to get started built in, and runs on your machine. A hosted version is coming soon!

1. Install

py
pip install chromadb
sh
npm install --save chromadb # yarn add chromadb

You will need to install the Chroma python package to use the Chroma CLI and backend server.

sh
pip install chromadb

Alternatively, you can use a Docker container to run the Chroma backend server.

2. Get the Chroma Client

python
import chromadb
chroma_client = chromadb.Client()

Start the Chroma backend server:

sh
chroma run --path /db_path

Then create a client which connects to it:

js
// CJS
const { ChromaClient } = require("chromadb");

// ESM
import { ChromaClient } from 'chromadb'

const client = new ChromaClient();

3. Create a collection

Collections are where you'll store your embeddings, documents, and any additional metadata. You can create a collection with a name:

python
collection = chroma_client.create_collection(name="my_collection")

For this example, we want to generate embeddings from text. OpenAI's ada-002 model is popular, free, and a quick signup. Grab your API key and come back. Chroma's API is polymorphic (it can run in the browser or server-side), but OpenAIs is not. So run this example server-side.

:::caution
Please take steps to secure your API when interacting with frontend systems.
:::

js
// CJS
const { OpenAIEmbeddingFunction } = require("chromadb");

// ESM
import { OpenAIEmbeddingFunction } from 'chromadb'

const embedder = new OpenAIEmbeddingFunction({
  openai_api_key: "your_api_key",
});
const collection = await client.createCollection({
  name: "my_collection",
  embeddingFunction: embedder,
});

4. Add some text documents to the collection

Chroma will store your text, and handle tokenization, embedding, and indexing automatically.

python
collection.add(
    documents=["This is a document", "This is another document"],
    metadatas=[{"source": "my_source"}, {"source": "my_source"}],
    ids=["id1", "id2"]
)

Chroma will store your text, and handle tokenization, embedding, and indexing automatically.

js
await collection.add({
  ids: ["id1", "id2"],
  metadatas: [{ source: "my_source" }, { source: "my_source" }],
  documents: ["This is a document", "This is another document"],
});

If you have already generated embeddings yourself, you can load them directly in:

python
collection.add(
    embeddings=[[1.2, 2.3, 4.5], [6.7, 8.2, 9.2]],
    documents=["This is a document", "This is another document"],
    metadatas=[{"source": "my_source"}, {"source": "my_source"}],
    ids=["id1", "id2"]
)
js
await collection.add({
  ids: ["id1", "id2"],
  embeddings: [
    [1.2, 2.3, 4.5],
    [6.7, 8.2, 9.2],
  ],
  metadatas: [{ source: "my_source" }, { source: "my_source" }],
  documents: ["This is a document", "This is another document"],
});

5. Query the collection

You can query the collection with a list of query texts, and Chroma will return the n most similar results. It's that easy!

python
results = collection.query(
    query_texts=["This is a query document"],
    n_results=2
)

By default data stored in Chroma is ephemeral making it easy to prototype scripts. It's easy to make Chroma persistent so you can reuse every collection you create and add more documents to it later. It will load your data automatically when you start the client, and save it automatically when you close it. Check out the Usage Guide for more info.

Find chromadb on PyPI.

js
const results = await collection.query({
  nResults: 2,
  queryTexts: ["This is a query document"],
});

Find chromadb on npm.

๐Ÿ“š Next steps

  • Chroma is designed to be simple enough to get started with quickly and flexible enough to meet many use-cases. You can use your own embedding models, query Chroma with your own embeddings, and filter on metadata. To learn more about Chroma, check out the Usage Guide and API Reference.
  • Chroma is integrated in LangChain (python and js), making it easy to build AI applications with Chroma. Check out the integrations page to learn more.
  • You can deploy a persistent instance of Chroma to an external server, to make it easier to work on larger projects or with a team.

Coming Soon

  • A hosted version of Chroma, with an easy to use web UI and API
  • Multiple datatypes, including images, audio, video, and more