Skip to main content
The Client API provides the main entry point for interacting with Chroma. Use client constructors to create connections and client methods to manage collections.

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.
For production use, prefer a server-backed Chroma instance using HttpClient() or CloudClient().

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.
Parameters:
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.
Returns:
ClientAPI
A configured Rust-backed client instance.

AdminClient()

Create an admin client for tenant and database management operations.
Parameters:
Settings
required
Settings for connecting to the Chroma server.
Returns:
AdminAPI
An admin client for tenant and database management.
Admin Operations:
  • create_tenant(name) - Create a new tenant
  • get_tenant(name) - Get tenant information
  • list_tenants() - List all tenants
  • create_database(name, tenant) - Create a database in a tenant
  • get_database(name, tenant) - Get database information
  • list_databases(tenant) - List databases in a tenant

Global Configuration

configure()

Override Chroma’s default settings globally.
Parameters: Accepts any Settings parameter as a keyword argument. Common settings include:
  • chroma_api_impl - API implementation to use
  • chroma_server_host - Server hostname
  • chroma_server_http_port - Server port
  • anonymized_telemetry - Enable/disable telemetry

get_settings()

Get the current global settings.
Returns:
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.
This operation is irreversible. All data in the collection will be permanently deleted.

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 with Settings.

Common Settings

  • anonymized_telemetry (bool): Enable/disable anonymized telemetry. Default: True
  • allow_reset (bool): Allow resetting the database. Default: False
  • chroma_server_host (str): Chroma server hostname
  • chroma_server_http_port (int): Chroma server HTTP port
  • chroma_server_ssl_enabled (bool): Enable SSL for server connections
  • chroma_server_headers (Dict[str, str]): Headers to send with requests
  • persist_directory (str): Directory for persistent storage
  • is_persistent (bool): Enable persistence
Settings can also be configured via environment variables. See the Configuration guide for details.