1. Project Overview & Quickstart (chroma-core/chroma)
File: README.md
pip install chromadb # python client
# for javascript, npm install chromadb!
# for client-server mode, chroma run --path /chroma_db_pathChroma 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.
API
The core API is only 4 functions (run our ๐ก Google Colab):
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.
- Join the conversation on Discord -
#contributingchannel - Review the ๐ฃ๏ธ Roadmap and contribute your ideas
- Grab an issue and open a PR -
Good first issue tag - Read our contributing guide
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
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 schematitle: The title of the schemadescription: A description of the schemaproperties: The properties that can be configured for the embedding functionrequired: The properties that are required for the embedding functionadditionalProperties: Whether additional properties are allowed (always set tofalseto ensure strict validation)
Usage
The schemas can be used to validate the configuration of embedding functions using the validate_config function:
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:
- Create a new JSON file in this directory with the name of the embedding function (e.g.,
new_function.json) - Define the schema following the JSON Schema Draft-07 specification
- 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
pip install chromadb-client # python http-client only libraryTo connect to your server and perform operations using the client only library, you can do the following:
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
File: clients/js/examples/node/README.md
Node Example
This is an example of how to use ChromaDB with Node.js.
Getting Started
- Make sure you have Chroma running locally at
http://localhost:8000 - Run
pnpm installto install dependencies - Run one of the following commands:
pnpm dev- Run the example with the default bundled packagepnpm dev:bundled- Run the example with the bundled chromadb packagepnpm dev:client- Run the example with the chromadb-client package (peer dependencies)
Package Options
This example demonstrates both ChromaDB package options:
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");
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:
chromadb: Bundled package with all dependencies includedchromadb-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.
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:clientBrowser Example
The browser example demonstrates how to use ChromaDB in a browser environment.
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:clientDifferences 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:
npm install
npm run buildPublishing
First build the package then run npm publish
Consuming
Navigate to the folder of your consuming project and run one of the following commands:
npm install PATH_TO_GENERATED_PACKAGE --saveFile: 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
# npm
npm install chromadb-client
# pnpm
pnpm add chromadb-client
# yarn
yarn add chromadb-clientYou'll need to install any required embedding libraries separately. For example:
# 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-aiGetting 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.
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:
// 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
chromadbpackage
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
# npm
npm install chromadb
# pnpm
pnpm add chromadb
# yarn
yarn add chromadbGetting 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.
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:
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._.
Package Options
There are two packages available for using ChromaDB in your JavaScript/TypeScript projects:
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 chromadborpnpm add chromadb
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-clientorpnpm 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
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
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
$ yarnLocal Development
$ yarn startThis command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
Build
$ yarn buildThis command generates static content into the build directory and can be served using any static contents hosting service.
Generating Python Docs
- Have chroma as a sibling to the the docs dir, eg
/docs
/chromaUpdate
pydoc-markdown.ymlif you need to expose more files other than Collection and ClientRun
yarn gen-python
Deployment
Vercel handles deploying main to https://docs.trychroma.com
Generating Javascript Docs
- Have chroma as a sibling to the the docs dir, eg
/docs
/chromaUpdate
scripts/jsDocs.sh,sidebar.jsonif you need to expose more files other than Collection and ClientRun
yarn gen-js
File: docs/intro.md
sidebar_position: 0 slug: / title: ๐ก Home hide_title: true
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.
pip install chromadbJavaScript
In JavaScript, Chroma runs in client/server mode and talks to a Python backend.
npm install --save chromadb # yarn add chromadbContinue 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
sidebar_position: 2 title: "๐ Getting Started"
๐ 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
pip install chromadbnpm install --save chromadb # yarn add chromadbYou will need to install the Chroma python package to use the Chroma CLI and backend server.
pip install chromadbAlternatively, you can use a Docker container to run the Chroma backend server.
2. Get the Chroma Client
import chromadb
chroma_client = chromadb.Client()Start the Chroma backend server:
chroma run --path /db_pathThen create a client which connects to it:
// 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:
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.
:::
// 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.
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.
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:
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"]
)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!
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.
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 (
pythonandjs), 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