CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-chromadb

Chroma - the open-source embedding database

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

clients.mddocs/

Client Creation

ChromaDB provides multiple client types for different deployment scenarios, from in-memory testing to production cloud deployments. Each client type implements the same core API while optimizing for specific use cases.

Capabilities

EphemeralClient

Creates an in-memory ChromaDB instance ideal for testing and development. Data is not persisted and is lost when the process ends.

def EphemeralClient(
    settings: Optional[Settings] = None,
    tenant: str = "default_tenant",
    database: str = "default_database"
) -> ClientAPI:
    """
    Creates an in-memory instance of Chroma.
    
    Args:
        settings: Optional Settings object for configuration
        tenant: The tenant to use for this client
        database: The database to use for this client
        
    Returns:
        ClientAPI: A client instance for interacting with ChromaDB
    """

Usage Example:

import chromadb

client = chromadb.EphemeralClient()
collection = client.create_collection("test_collection")

PersistentClient

Creates a ChromaDB instance that persists data to disk, suitable for local development and single-machine deployments.

def PersistentClient(
    path: Union[str, Path] = "./chroma",
    settings: Optional[Settings] = None,
    tenant: str = "default_tenant",
    database: str = "default_database"
) -> ClientAPI:
    """
    Creates a persistent instance of Chroma that saves to disk.
    
    Args:
        path: The directory to save Chroma's data to
        settings: Optional Settings object for configuration
        tenant: The tenant to use for this client
        database: The database to use for this client
        
    Returns:
        ClientAPI: A client instance for interacting with ChromaDB
    """

Usage Example:

import chromadb

client = chromadb.PersistentClient(path="/path/to/chroma/data")
collection = client.create_collection("my_collection")

HttpClient

Creates a client that connects to a remote ChromaDB server over HTTP, supporting production deployments with multiple clients.

def HttpClient(
    host: str = "localhost",
    port: int = 8000,
    ssl: bool = False,
    headers: Optional[Dict[str, str]] = None,
    settings: Optional[Settings] = None,
    tenant: str = "default_tenant",
    database: str = "default_database"
) -> ClientAPI:
    """
    Creates a client that connects to a remote Chroma server.
    
    Args:
        host: The hostname of the Chroma server
        port: The port of the Chroma server
        ssl: Whether to use SSL to connect to the server
        headers: A dictionary of headers to send to the server
        settings: Optional Settings object for configuration
        tenant: The tenant to use for this client
        database: The database to use for this client
        
    Returns:
        ClientAPI: A client instance for interacting with ChromaDB
    """

Usage Example:

import chromadb

client = chromadb.HttpClient(
    host="my-chroma-server.com",
    port=8000,
    ssl=True,
    headers={"Authorization": "Bearer my-token"}
)
collection = client.get_collection("my_collection")

AsyncHttpClient

Creates an async client for connecting to remote ChromaDB servers, enabling concurrent operations and integration with async Python frameworks.

async def AsyncHttpClient(
    host: str = "localhost",
    port: int = 8000,
    ssl: bool = False,
    headers: Optional[Dict[str, str]] = None,
    settings: Optional[Settings] = None,
    tenant: str = "default_tenant",
    database: str = "default_database"
) -> AsyncClientAPI:
    """
    Creates an async client that connects to a remote Chroma server.
    
    Args:
        host: The hostname of the Chroma server
        port: The port of the Chroma server
        ssl: Whether to use SSL to connect to the server
        headers: A dictionary of headers to send to the server
        settings: Optional Settings object for configuration
        tenant: The tenant to use for this client
        database: The database to use for this client
        
    Returns:
        AsyncClientAPI: An async client instance for interacting with ChromaDB
    """

Usage Example:

import chromadb
import asyncio

async def main():
    client = await chromadb.AsyncHttpClient(host="my-server.com", ssl=True)
    collection = await client.get_collection("my_collection")
    
asyncio.run(main())

CloudClient

Creates a client for connecting to ChromaDB cloud service with built-in authentication and managed infrastructure.

def CloudClient(
    tenant: Optional[str] = None,
    database: Optional[str] = None,
    api_key: Optional[str] = None,
    settings: Optional[Settings] = None,
    *,
    cloud_host: str = "api.trychroma.com",
    cloud_port: int = 443,
    enable_ssl: bool = True
) -> ClientAPI:
    """
    Creates a client to connect to a tenant and database on Chroma cloud.
    
    Args:
        tenant: The tenant to use (can be inferred from API key)
        database: The database to use (can be inferred from API key)
        api_key: The API key for authentication (or set CHROMA_API_KEY env var)
        settings: Optional Settings object for configuration
        cloud_host: The cloud service hostname
        cloud_port: The cloud service port
        enable_ssl: Whether to use SSL
        
    Returns:
        ClientAPI: A client instance for interacting with ChromaDB Cloud
    """

Usage Example:

import chromadb

client = chromadb.CloudClient(api_key="your-api-key")  # or set CHROMA_API_KEY
collection = client.get_collection("my_collection")

RustClient

Creates a client using the Rust-based implementation for improved performance, supporting both ephemeral and persistent modes.

def RustClient(
    path: Optional[str] = None,
    settings: Optional[Settings] = None,
    tenant: str = "default_tenant",
    database: str = "default_database"
) -> ClientAPI:
    """
    Creates a Rust-backed Chroma client instance.
    
    Args:
        path: Optional directory to save data (ephemeral if None)
        settings: Optional Settings object for configuration
        tenant: The tenant to use for this client
        database: The database to use for this client
        
    Returns:
        ClientAPI: A client instance using Rust implementation
    """

Usage Example:

import chromadb

# Ephemeral Rust client
client = chromadb.RustClient()

# Persistent Rust client
client = chromadb.RustClient(path="/path/to/data")

Generic Client

Creates a client using the current global settings, providing a flexible factory method.

def Client(
    settings: Settings = None,
    tenant: str = "default_tenant",
    database: str = "default_database"
) -> ClientAPI:
    """
    Return a running chroma.API instance using current settings.
    
    Args:
        settings: Settings object (uses global settings if None)
        tenant: The tenant to use for this client
        database: The database to use for this client
        
    Returns:
        ClientAPI: A client instance based on current configuration
    """

AdminClient

Creates an admin client for managing tenants and databases, providing elevated privileges for system administration.

def AdminClient(settings: Settings = None) -> AdminAPI:
    """
    Creates an admin client for tenant and database management.
    
    Args:
        settings: Settings object for configuration
        
    Returns:
        AdminAPI: An admin client for system management operations
    """

Usage Example:

import chromadb

admin = chromadb.AdminClient()
admin.create_tenant("new_tenant")
admin.create_database("new_database", tenant="new_tenant")

AdminAPI Methods

The AdminAPI provides database and tenant management capabilities for system administration.

class AdminAPI:
    def create_database(
        self, 
        name: str, 
        tenant: str = "default_tenant"
    ) -> None:
        """
        Create a new database.
        
        Args:
            name: The name of the database to create
            tenant: The tenant to create the database in
        """
    
    def get_database(
        self, 
        name: str, 
        tenant: str = "default_tenant"
    ) -> Database:
        """
        Get information about a database.
        
        Args:
            name: The name of the database
            tenant: The tenant the database belongs to
            
        Returns:
            Database: Database information
        """
    
    def delete_database(
        self, 
        name: str, 
        tenant: str = "default_tenant"
    ) -> None:
        """
        Delete a database.
        
        Args:
            name: The name of the database to delete
            tenant: The tenant the database belongs to
        """
    
    def list_databases(
        self, 
        limit: Optional[int] = None, 
        offset: Optional[int] = None, 
        tenant: str = "default_tenant"
    ) -> Sequence[Database]:
        """
        List databases in a tenant.
        
        Args:
            limit: Maximum number of databases to return
            offset: Number of databases to skip
            tenant: The tenant to list databases for
            
        Returns:
            Sequence[Database]: List of databases
        """
    
    def create_tenant(self, name: str) -> None:
        """
        Create a new tenant.
        
        Args:
            name: The name of the tenant to create
        """
    
    def get_tenant(self, name: str) -> Tenant:
        """
        Get information about a tenant.
        
        Args:
            name: The name of the tenant
            
        Returns:
            Tenant: Tenant information
        """

AdminAPI Usage Example:

import chromadb

# Create admin client
admin = chromadb.AdminClient()

# Manage tenants
admin.create_tenant("my_organization")
tenant = admin.get_tenant("my_organization")

# Manage databases
admin.create_database("production_db", tenant="my_organization")
admin.create_database("staging_db", tenant="my_organization")

databases = admin.list_databases(tenant="my_organization")
print(f"Found {len(databases)} databases")

# Clean up
admin.delete_database("staging_db", tenant="my_organization")

Types

from pathlib import Path
from typing import Dict, Optional, Union

Settings = chromadb.config.Settings
ClientAPI = chromadb.api.ClientAPI
AsyncClientAPI = chromadb.api.AsyncClientAPI
AdminAPI = chromadb.api.AdminAPI

Install with Tessl CLI

npx tessl i tessl/pypi-chromadb

docs

clients.md

collections.md

configuration.md

documents.md

embedding-functions.md

index.md

queries.md

tile.json