Skip to main content

Class: ChromaClient

Constructorsโ€‹

constructorโ€‹

โ€ข new ChromaClient(params?)

Creates a new ChromaClient instance.

Example

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

Parametersโ€‹

NameTypeDescription
paramsObjectThe parameters for creating a new client
params.path?stringThe base path for the Chroma API.

Methodsโ€‹

createCollectionโ€‹

โ–ธ createCollection(params): Promise<Collection>

Creates a new collection with the specified properties.

Throws

If there is an issue creating the collection.

Example

const collection = await client.createCollection({
name: "my_collection",
metadata: {
description: "My first collection"
}
});

Parametersโ€‹

NameTypeDescription
paramsObjectThe parameters for creating a new collection.
params.embeddingFunction?IEmbeddingFunctionOptional custom embedding function for the collection.
params.metadata?CollectionMetadataOptional metadata associated with the collection.
params.namestringThe name of the collection.

Returnsโ€‹

Promise<Collection>

A promise that resolves to the created collection.


deleteCollectionโ€‹

โ–ธ deleteCollection(params): Promise<void>

Deletes a collection with the specified name.

Throws

If there is an issue deleting the collection.

Example

await client.deleteCollection({
name: "my_collection"
});

Parametersโ€‹

NameTypeDescription
paramsObjectThe parameters for deleting a collection.
params.namestringThe name of the collection.

Returnsโ€‹

Promise<void>

A promise that resolves when the collection is deleted.


getCollectionโ€‹

โ–ธ getCollection(params): Promise<Collection>

Gets a collection with the specified name.

Throws

If there is an issue getting the collection.

Example

const collection = await client.getCollection({
name: "my_collection"
});

Parametersโ€‹

NameTypeDescription
paramsObjectThe parameters for getting a collection.
params.embeddingFunction?IEmbeddingFunctionOptional custom embedding function for the collection.
params.namestringThe name of the collection.

Returnsโ€‹

Promise<Collection>

A promise that resolves to the collection.


getOrCreateCollectionโ€‹

โ–ธ getOrCreateCollection(params): Promise<Collection>

Gets or creates a collection with the specified properties.

Throws

If there is an issue getting or creating the collection.

Example

const collection = await client.getOrCreateCollection({
name: "my_collection",
metadata: {
description: "My first collection"
}
});

Parametersโ€‹

NameTypeDescription
paramsObjectThe parameters for creating a new collection.
params.embeddingFunction?IEmbeddingFunctionOptional custom embedding function for the collection.
params.metadata?CollectionMetadataOptional metadata associated with the collection.
params.namestringThe name of the collection.

Returnsโ€‹

Promise<Collection>

A promise that resolves to the got or created collection.


heartbeatโ€‹

โ–ธ heartbeat(): Promise<number>

Returns a heartbeat from the Chroma API.

Example

const heartbeat = await client.heartbeat();

Returnsโ€‹

Promise<number>

A promise that resolves to the heartbeat from the Chroma API.


listCollectionsโ€‹

โ–ธ listCollections(): Promise<CollectionType[]>

Lists all collections.

Throws

If there is an issue listing the collections.

Example

const collections = await client.listCollections();

Returnsโ€‹

Promise<CollectionType[]>

A promise that resolves to a list of collection names.


resetโ€‹

โ–ธ reset(): Promise<Reset200Response>

Resets the state of the object by making an API call to the reset endpoint.

Throws

If there is an issue resetting the state.

Example

await client.reset();

Returnsโ€‹

Promise<Reset200Response>

A promise that resolves when the reset operation is complete.


versionโ€‹

โ–ธ version(): Promise<string>

Returns the version of the Chroma API.

Example

const version = await client.version();

Returnsโ€‹

Promise<string>

A promise that resolves to the version of the Chroma API.