Skip to main content

ChromaClient

The main client for interacting with Chroma. Manages collections and provides access to the database.

Constructor

Parameters:
ChromaClientParams
Client configuration options
Example:

Collection Methods

createCollection

Creates a new collection with the specified properties.
Parameters:
CreateCollectionParams
required
Returns: Promise resolving to the created Collection instance Throws:
  • ChromaConnectionError - If unable to connect to the server
  • ChromaServerError - If there is an issue creating the collection
Example:

getCollection

Gets an existing collection with the specified name.
Parameters:
GetCollectionParams
required
Returns: Promise resolving to the Collection instance Throws: Error if the collection does not exist or there is an issue getting it Example:

getOrCreateCollection

Gets or creates a collection with the specified properties.
Parameters:
GetOrCreateCollectionParams
required
Same as CreateCollectionParams
Returns: Promise resolving to the got or created Collection instance Throws: Error if there is an issue getting or creating the collection Example:

deleteCollection

Deletes a collection with the specified name.
Parameters:
DeleteCollectionParams
required
Returns: Promise that resolves when the collection is deleted Throws: Error if there is an issue deleting the collection Example:

listCollections

Get all collection names.
Parameters:
ListCollectionsParams
Returns: Promise resolving to a list of collection names Example:

listCollectionsAndMetadata

List collection names, IDs, and metadata.
Parameters:
ListCollectionsParams
Same as listCollections
Returns: Promise resolving to a list of collection names, IDs, and metadata Example:

countCollections

Counts all collections.
Returns: Promise resolving to the number of collections Example:

Utility Methods

version

Returns the version of the Chroma API.
Returns: Promise resolving to the version of the Chroma API Throws: ChromaConnectionError if unable to connect to the server Example:

heartbeat

Returns a heartbeat from the Chroma API.
Returns: Promise resolving to the heartbeat in nanoseconds Throws: ChromaConnectionError if unable to connect to the server Example:

reset

Resets the state of the database.
Returns: Promise that resolves when the reset operation is complete Throws:
  • ChromaConnectionError - If unable to connect to the server
  • ChromaServerError - If the server experienced an error
Example:

CloudClient

A client for connecting to Chroma Cloud. Extends ChromaClient with cloud-specific configuration.

Constructor

Parameters:
CloudClientParams
required
Throws: Error if no API key is provided and CHROMA_API_KEY environment variable is not set Example:
CloudClient inherits all methods from ChromaClient. See the ChromaClient documentation above for available methods.

AdminClient

A client for administrative operations like managing tenants and databases.

Constructor

Parameters:
object
Example:

Tenant Methods

createTenant

Creates a new tenant.
Parameters:
string
required
The name of the tenant to create
Returns: Promise resolving to the created tenant Throws: Error if there is an issue creating the tenant Example:

getTenant

Gets a tenant by name.
Parameters:
string
required
The name of the tenant to get
Returns: Promise resolving to the tenant Throws: Error if there is an issue getting the tenant Example:

setTenant

Sets the tenant and database for the client.
Parameters:
object
required
Returns: Promise that resolves when complete Throws: Error if there is an issue Example:

Database Methods

createDatabase

Creates a new database.
Parameters:
object
required
Returns: Promise resolving to the created database Throws: Error if there is an issue creating the database Example:

getDatabase

Gets a database by name.
Parameters:
object
required
Returns: Promise resolving to the database Throws: Error if there is an issue getting the database Example:

deleteDatabase

Deletes a database.
Parameters:
object
required
Returns: Promise that resolves when complete Throws: Error if there is an issue deleting the database Example:

listDatabases

Lists databases for a specific tenant.
Parameters:
object
required
Returns: Promise resolving to a list of databases Throws: Error if there is an issue listing the databases Example:

setDatabase

Sets the database for the client.
Parameters:
string
The name of the database
Returns: Promise that resolves when complete Throws: Error if there is an issue Example: