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.