JS Client

Class: ChromaClient#

Constructors#

constructor#

new ChromaClient(params?)

Creates a new ChromaClient instance.

Example

javascript

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

javascript

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

javascript

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

javascript

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

javascript

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

javascript

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

javascript

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

javascript

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

javascript

Returns#

Promise<string>

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