Clients
EphemeralClient
Creates an in-memory instance of Chroma. This is useful for testing and development, but not recommended for production use.The tenant to use for this client. Defaults to the default tenant.
The database to use for this client. Defaults to the default database.
PersistentClient
Creates a persistent instance of Chroma that saves to disk. This is useful for testing and development, but not recommended for production use.The directory to save Chroma’s data to. Defaults to ”./chroma”.
The tenant to use for this client. Defaults to the default tenant.
The database to use for this client. Defaults to the default database.
HttpClient
Creates a client that connects to a remote Chroma server. This supports many clients connecting to the same server, and is the recommended way to use Chroma in production.The hostname of the Chroma server. Defaults to “localhost”.
The port of the Chroma server. Defaults to 8000.
Whether to use SSL to connect to the Chroma server. Defaults to False.
A dictionary of headers to send to the Chroma server. Defaults to {}.
A dictionary of settings to communicate with the chroma server.
The tenant to use for this client. Defaults to the default tenant.
The database to use for this client. Defaults to the default database.
AsyncHttpClient
Creates an async client that connects to a remote Chroma server. This supports many clients connecting to the same server, and is the recommended way to use Chroma in production.The hostname of the Chroma server. Defaults to “localhost”.
The port of the Chroma server. Defaults to 8000.
Whether to use SSL to connect to the Chroma server. Defaults to False.
A dictionary of headers to send to the Chroma server. Defaults to {}.
A dictionary of settings to communicate with the chroma server.
The tenant to use for this client. Defaults to the default tenant.
The database to use for this client. Defaults to the default database.
CloudClient
Creates a client to connect to a tenant and database on Chroma cloud.The tenant to use for this client. Optional. If not provided, it will be inferred from the API key if the key is scoped to a single tenant. If provided, it will be validated against the API key’s scope.
The database to use for this client. Optional. If not provided, it will be inferred from the API key if the key is scoped to a single database. If provided, it will be validated against the API key’s scope.
The api key to use for this client.
AdminClient
Creates an admin client that can be used to create tenants and databases.Client Methods
heartbeat
Get the current time in nanoseconds since epoch. Used to check if the server is alive. Returns: The current time in nanoseconds since epochlist_collections
List all collections.The maximum number of entries to return. Defaults to None.
The number of entries to skip before returning. Defaults to None.
count_collections
Count the number of collections. Returns: The number of collections.create_collection
Create a new collection with the given name and metadata.The name of the collection to create.
Optional metadata to associate with the collection.
Optional function to use to embed documents.
Uses the default embedding function if not provided.
Optional function to use to load records (documents, images, etc.)
If True, return the existing collection if it exists.
- ValueError: If the collection already exists and get_or_create is False.
- ValueError: If the collection name is invalid.
get_collection
Get a collection with the given name.The name of the collection to get
Optional function to use to embed documents.
Uses the default embedding function if not provided.
Optional function to use to load records (documents, images, etc.)
- ValueError: If the collection does not exist
get_or_create_collection
Get or create a collection with the given name and metadata. Args: name: The name of the collection to get or create metadata: Optional metadata to associate with the collection. If the collection already exists, the metadata provided is ignored. If the collection does not exist, the new collection will be created with the provided metadata. embedding_function: Optional function to use to embed documents data_loader: Optional function to use to load records (documents, images, etc.) Returns: The collection Examples:delete_collection
Delete a collection with the given name.The name of the collection to delete.
- ValueError: If the collection does not exist.
reset
Resets the database. This will delete all collections and entries. Returns: True if the database was reset successfully.get_version
Get the version of Chroma. Returns: The version of Chromaget_settings
Get the settings used to initialize. Returns: The settings used to initialize.get_max_batch_size
Return the maximum number of records that can be created or mutated in a single call.Admin Client Methods
create_tenant
Create a new tenant. Raises an error if the tenant already exists.get_tenant
Get a tenant. Raises an error if the tenant does not exist.create_database
Create a new database. Raises an error if the database already exists.get_database
Get a database. Raises an error if the database does not exist.The tenant of the database to get.
delete_database
Delete a database. Raises an error if the database does not exist.The tenant of the database to delete.
list_databases
List all databases for a tenant. Raises an error if the tenant does not exist.The tenant to list databases for.