Client Constructors
EphemeralClient()
Create an in-memory client for testing and development.Settings
Optional settings to override defaults.
str
default:"default_tenant"
Tenant name to use for requests.
str
default:"default_database"
Database name to use for requests.
ClientAPI
A configured client instance that stores all data in memory.
Data in EphemeralClient is not persisted to disk and will be lost when the client is closed.
PersistentClient()
Create a persistent client that stores data on disk.str | Path
default:"./chroma"
Directory to store persisted data.
Settings
Optional settings to override defaults.
str
default:"default_tenant"
Tenant name to use for requests.
str
default:"default_database"
Database name to use for requests.
ClientAPI
A configured client instance that persists data to disk.
HttpClient()
Create a client that connects to a Chroma server over HTTP.str
default:"localhost"
Hostname of the Chroma server.
int
default:"8000"
HTTP port of the Chroma server.
bool
default:"false"
Whether to enable SSL for the connection.
Dict[str, str]
Optional headers to send with each request.
Settings
Optional settings to override defaults.
str
default:"default_tenant"
Tenant name to use for requests.
str
default:"default_database"
Database name to use for requests.
ClientAPI
A configured client instance connected to a Chroma server.
ValueError
If settings specify a different host or port.
CloudClient()
Create a client for Chroma Cloud.str
Tenant name, or None to infer from
CHROMA_TENANT environment variable.str
Database name, or None to infer from
CHROMA_DATABASE environment variable.str
API key for Chroma Cloud. If not provided, inferred from
CHROMA_API_KEY environment variable.Settings
Optional settings to override defaults.
ClientAPI
A configured client instance for Chroma Cloud.
ValueError
If no API key is provided or available in the environment.
AsyncHttpClient()
Create an async client that connects to a Chroma HTTP server.str
default:"localhost"
Hostname of the Chroma server.
int
default:"8000"
HTTP port of the Chroma server.
bool
default:"false"
Whether to enable SSL for the connection.
Dict[str, str]
Optional headers to send with each request.
Settings
Optional settings to override defaults.
str
default:"default_tenant"
Tenant name to use for requests.
str
default:"default_database"
Database name to use for requests.
AsyncClientAPI
A configured async client instance.
RustClient()
Create a client using Rust bindings for improved performance. Can be ephemeral or persistent.This client uses the Rust implementation for better performance. It’s useful for testing and development but not recommended for production use.
str
Optional directory to save Chroma’s data to. If None, the client is ephemeral (in-memory).
Settings
Optional settings to override defaults.
str
default:"default_tenant"
Tenant name to use for requests.
str
default:"default_database"
Database name to use for requests.
ClientAPI
A configured Rust-backed client instance.
AdminClient()
Create an admin client for tenant and database management operations.Settings
required
Settings for connecting to the Chroma server.
AdminAPI
An admin client for tenant and database management.
create_tenant(name)- Create a new tenantget_tenant(name)- Get tenant informationlist_tenants()- List all tenantscreate_database(name, tenant)- Create a database in a tenantget_database(name, tenant)- Get database informationlist_databases(tenant)- List databases in a tenant
Global Configuration
configure()
Override Chroma’s default settings globally.chroma_api_impl- API implementation to usechroma_server_host- Server hostnamechroma_server_http_port- Server portanonymized_telemetry- Enable/disable telemetry
get_settings()
Get the current global settings.Settings
The current global Settings object.
Collection Management
create_collection()
Create a new collection.str
required
Collection name.
Schema
Optional collection schema for indexes and encryption.
CollectionMetadata
Optional collection metadata.
EmbeddingFunction
Optional embedding function for the collection. Defaults to
DefaultEmbeddingFunction().DataLoader
Optional data loader for documents with URIs.
bool
default:"false"
Whether to return an existing collection if present.
Collection
The created collection.
ValueError
If the collection already exists (when
get_or_create=False) or if the embedding function conflicts with configuration.get_collection()
Get an existing collection by name.str
required
Collection name.
EmbeddingFunction
Optional embedding function for the collection. Defaults to
DefaultEmbeddingFunction().DataLoader
Optional data loader for documents with URIs.
Collection
The requested collection.
ValueError
If the collection does not exist or if the embedding function conflicts with configuration.
get_or_create_collection()
Get an existing collection or create a new one.str
required
Collection name.
Schema
Optional collection schema. Ignored if the collection already exists.
CollectionMetadata
Optional collection metadata. Ignored if the collection already exists.
EmbeddingFunction
Optional embedding function for the collection. Defaults to
DefaultEmbeddingFunction().DataLoader
Optional data loader for URI-backed data.
Collection
The existing or newly created collection.
ValueError
If the embedding function does not match the collection’s embedding function.
If the collection already exists, the
schema, metadata arguments are ignored.list_collections()
List all collections in the current database.int
Maximum number of collections to return.
int
Number of collections to skip before returning.
Sequence[Collection]
Collection objects for the current tenant and database.
delete_collection()
Delete a collection by name.str
required
Collection name to delete.
Client Utilities
heartbeat()
Check if the server is running and return the server time.int
Server time in nanoseconds since epoch.
get_version()
Get the Chroma server version.str
The Chroma version string.
close()
Close the client and release all resources.This is particularly important for
PersistentClient to avoid SQLite file locking issues. Use context managers (with statement) for automatic cleanup.Settings
Configure Chroma behavior withSettings.
Common Settings
anonymized_telemetry(bool): Enable/disable anonymized telemetry. Default:Trueallow_reset(bool): Allow resetting the database. Default:Falsechroma_server_host(str): Chroma server hostnamechroma_server_http_port(int): Chroma server HTTP portchroma_server_ssl_enabled(bool): Enable SSL for server connectionschroma_server_headers(Dict[str, str]): Headers to send with requestspersist_directory(str): Directory for persistent storageis_persistent(bool): Enable persistence