EphemeralClient#
Creates an in-memory instance of Chroma. This is useful for testing and development, but not recommended for production use.
PersistentClient#
Creates a persistent instance of Chroma that saves to disk. This is useful for testing and development, but not recommended for production use.
Arguments:
path
- The directory to save Chroma's data to. Defaults to "./chroma".
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.
Arguments:
host
- The hostname of the Chroma server. Defaults to "localhost".port
- The port of the Chroma server. Defaults to "8000".ssl
- Whether to use SSL to connect to the Chroma server. Defaults to False.headers
- A dictionary of headers to send to the Chroma server. Defaults to {}.
Client#
Return a running chroma.API instance
Client Methods#
heartbeat#
Get the current time in nanoseconds since epoch. Used to check if the server is alive.
Returns:
int
- The current time in nanoseconds since epoch
list_collections#
List all collections.
Returns:
Sequence[Collection]
- A list of collections
Examples:
create_collection#
Create a new collection with the given name and metadata.
Arguments:
name
- The name of the collection to create.metadata
- Optional metadata to associate with the collection.embedding_function
- Optional function to use to embed documents. Uses the default embedding function if not provided.get_or_create
- If True, return the existing collection if it exists.
Returns:
Collection
- The newly created collection.
Raises:
ValueError
- If the collection already exists and get_or_create is False.ValueError
- If the collection name is invalid.
Examples:
get_collection#
Get a collection with the given name.
Arguments:
name
- The name of the collection to getembedding_function
- Optional function to use to embed documents. Uses the default embedding function if not provided.
Returns:
Collection
- The collection
Raises:
ValueError
- If the collection does not exist
Examples:
get_or_create_collection#
Get or create a collection with the given name and metadata.
Arguments:
name
- The name of the collection to get or createmetadata
- Optional metadata to associate with the collectionembedding_function
- Optional function to use to embed documents
Returns:
The collection
Examples:
delete_collection#
Delete a collection with the given name.
Arguments:
name
- The name of the collection to delete.
Raises:
ValueError
- If the collection does not exist.
Examples:
count_collections#
Count the number of collections.
Returns:
int
- The number of collections.
Examples:
reset#
Resets the database. This will delete all collections and entries.
Returns:
bool
- True if the database was reset successfully.
get_version#
Get the version of Chroma.
Returns:
str
- The version of Chroma
get_settings#
Get the settings used to initialize the client.
Returns:
Settings
- The settings used to initialize the client.
get_max_batch_size#
Get the maximum batch size.
Returns:
int
- The maximum number of records that can be created or mutated in a single call.