Skip to main content

Installation

npm install chromadb
The TypeScript SDK also has multiple extensions for popular embedding providers. See the full list on the integrations page.

Clients

ChromaClient

Main client class for interacting with ChromaDB. Provides methods for managing collections and performing operations on them.
host
string | undefined
The host address of the Chroma server. Defaults to ‘localhost’
port
number | undefined
The port number of the Chroma server. Defaults to 8000
ssl
boolean | undefined
Whether to use SSL/HTTPS for connections. Defaults to false
tenant
string | undefined
The tenant name in the Chroma server to connect to
database
string | undefined
The database name to connect to
headers
Record<string, string> | undefined
Additional HTTP headers to send with requests
fetchOptions
RequestInit | undefined
Additional fetch options for HTTP requests
path
string | undefined
auth
Record<string, string> | undefined

CloudClient

ChromaDB cloud client for connecting to hosted Chroma instances. Extends ChromaClient with cloud-specific authentication and configuration.
apiKey
string
host
string
port
number
tenant
string
database
string
fetchOptions
RequestInit

AdminClient

Administrative client for managing ChromaDB tenants and databases. Provides methods for creating, deleting, and listing tenants and databases.
host
string
required
The host address of the Chroma server
port
number
required
The port number of the Chroma server
ssl
boolean
required
Whether to use SSL/HTTPS for connections
headers
Record<string, string> | undefined
Additional HTTP headers to send with requests
fetchOptions
RequestInit | undefined
Additional fetch options for HTTP requests

Client Methods

heartbeat

Sends a heartbeat request to check server connectivity. Returns: Promise resolving to the server’s nanosecond heartbeat timestamp

listCollections

Lists all collections in the current database.
limit
number
required
offset
number
required
Returns: Promise resolving to an array of Collection instances

countCollections

Gets the total number of collections in the current database. Returns: Promise resolving to the collection count

createCollection

Creates a new collection with the specified configuration.
name
string
required
configuration
CreateCollectionConfiguration
metadata
CollectionMetadata
embeddingFunction
EmbeddingFunction | null
schema
Schema
Returns: Promise resolving to the created Collection instance

getCollection

Retrieves an existing collection by name.
name
string
required
embeddingFunction
EmbeddingFunction
Returns: Promise resolving to the Collection instance

getOrCreateCollection

Gets an existing collection or creates it if it doesn’t exist.
name
string
required
configuration
CreateCollectionConfiguration
metadata
CollectionMetadata
embeddingFunction
EmbeddingFunction | null
schema
Schema
Returns: Promise resolving to the Collection instance

deleteCollection

Deletes a collection and all its data.
name
string
required

reset

Resets the entire database, deleting all collections and data. Returns: Promise that resolves when the reset is complete

version

Gets the version of the Chroma server. Returns: Promise resolving to the server version string

Admin Client Methods

createTenant

Creates a new tenant.
name
string
required

getTenant

Retrieves information about a specific tenant.
name
string
required
Returns: Promise resolving to the tenant name

createDatabase

Creates a new database within a tenant.
name
string
required
tenant
string
required

getDatabase

Retrieves information about a specific database.
name
string
required
tenant
string
required
Returns: Promise resolving to database information

deleteDatabase

Deletes a database and all its data.
name
string
required
tenant
string
required

listDatabases

Lists all databases within a tenant.
args
ListDatabasesArgs
required
Listing parameters including tenant and pagination
Returns: Promise resolving to an array of database information

Collection Methods

count

Gets the total number of records in the collection

add

Adds new records to the collection.
ids
string[]
required
embeddings
Embeddings
metadatas
Metadata[]
documents
string[]
uris
string[]

get

Retrieves records from the collection based on filters.
ids
string[]
where
Where
limit
number
offset
number
whereDocument
WhereDocument
include
Include[]
Returns: Promise resolving to matching records

peek

Retrieves a preview of records from the collection.
limit
number
Returns: Promise resolving to a sample of records

query

Performs similarity search on the collection.
queryEmbeddings
Embeddings
queryTexts
string[]
queryURIs
string[]
ids
string[]
nResults
number
where
Where
whereDocument
WhereDocument
include
Include[]
Returns: Promise resolving to similar records ranked by distance

modify

Modifies collection properties like name, metadata, or configuration.
name
string
metadata
CollectionMetadata
configuration
UpdateCollectionConfiguration

update

Updates existing records in the collection.
ids
string[]
required
embeddings
Embeddings
metadatas
Metadata[]
documents
string[]
uris
string[]

upsert

Inserts new records or updates existing ones (upsert operation).
ids
string[]
required
embeddings
Embeddings
metadatas
Metadata[]
documents
string[]
uris
string[]

delete

Deletes records from the collection based on filters.
ids
string[]
where
Where
whereDocument
WhereDocument
Performs hybrid search on the collection using expression builders.
searches
SearchLike | SearchLike[]
required
Single search payload or array of payloads
readLevel
ReadLevel
Returns: Promise resolving to column-major search results

Embedding Functions

EmbeddingFunction

Interface for embedding functions. Embedding functions transform text documents into numerical representations that can be used for similarity search and other vector operations. Properties
name
string | undefined
Optional name identifier for the embedding function
Methods buildFromConfig(), defaultSpace(), generate(), generateForQueries(), getConfig(), supportedSpaces(), validateConfig(), validateConfigUpdate()

SparseEmbeddingFunction

Interface for sparse embedding functions. Sparse embedding functions transform text documents into sparse numerical representations where only non-zero values are stored, making them efficient for high-dimensional spaces. Properties
name
string | undefined
Optional name identifier for the embedding function
Methods buildFromConfig(), generate(), generateForQueries(), getConfig(), validateConfig(), validateConfigUpdate()

Types

CollectionMetadata

Metadata that can be associated with a collection. Values must be boolean, number, or string types. Record< string, boolean | number | string | SparseVector | null >

Metadata

Metadata that can be associated with individual records. Values must be boolean, number, or string types. Record< string, boolean | number | string | SparseVector | null >

Where

Where clause for filtering records based on metadata. Supports field equality, comparison operators, and logical operators. { [key: string]: LiteralValue | OperatorExpression } | { $and: Where[] } | { $or: Where[] }

WhereDocument

Where clause for filtering based on document content. Supports text search operators and logical combinations. { $contains: string } | { $not_contains: string } | { $matches: string } | { $not_matches: string } | { $regex: string } | { $not_regex: string } | { $and: WhereDocument[] } | { $or: WhereDocument[] }

GetResult

Result class for get operations, containing retrieved records. Properties
documents
(string | null)[]
embeddings
Embeddings
ids
string[]
include
Include[]
metadatas
(TMeta | null)[]
uris
(string | null)[]

QueryResult

Result class for query operations, containing search results. Properties
distances
(number | null)[][]
documents
(string | null)[][]
embeddings
(Embedding | null)[][]
ids
string[][]
include
Include[]
metadatas
(TMeta | null)[][]
uris
(string | null)[][]

ReadLevel

"index_and_wal" | "index_only"

IncludeEnum

Enum specifying which fields to include in query results. "distances" | "documents" | "embeddings" | "metadatas" | "uris"

Search

Select

Knn

Properties
query
string | SparseVector | IterableInput<number>
key
string | Key | undefined
limit
number | undefined
default
number | null | undefined
returnRank
boolean | undefined

Rrf

Properties
ranks
RankInput[]
k
number | undefined
weights
Embedding | undefined
normalize
boolean | undefined

SearchResult

Properties
ids
string[][]
documents
((string | null)[] | null)[]
embeddings
((Embedding | null)[] | null)[]
metadatas
((Metadata | null)[] | null)[]
scores
((number | null)[] | null)[]
select
Key[][]

Schema

Collection schema for configuring indexes and encryption. The schema controls how data is indexed and can optionally specify customer-managed encryption keys (CMEK) for data at rest. Properties
defaults
ValueTypes
keys
Record<string, ValueTypes>
cmek
Cmek | null