mem0ai/mem0 · error · ValueError

Either ChromaDB Cloud configuration (api_key, tenant) or loc

Error message

Either ChromaDB Cloud configuration (api_key, tenant) or local configuration (path or host/port) must be provided.

What it means

Raised by ChromaDbConfig's connection validator when the config describes neither a Chroma Cloud client nor a local/server client. Cloud mode needs both api_key and tenant; local mode needs path, or host together with port. A config with none of these (or host without port) has no way to reach any Chroma instance.

Source

Thrown at mem0/configs/vector_stores/chroma.py:39

    @model_validator(mode="before")
    def check_connection_config(cls, values):
        host, port, path = values.get("host"), values.get("port"), values.get("path")
        api_key, tenant = values.get("api_key"), values.get("tenant")
        
        # Check if cloud configuration is provided
        cloud_config = bool(api_key and tenant)
        
        # If cloud configuration is provided, remove any default path that might have been added
        if cloud_config and path == "/tmp/chroma":
            values.pop("path", None)
            return values
        
        # Check if local/server configuration is provided
        local_config = bool(path) or bool(host and port)
        
        if not cloud_config and not local_config:
            raise ValueError("Either ChromaDB Cloud configuration (api_key, tenant) or local configuration (path or host/port) must be provided.")
        
        if cloud_config and local_config:
            raise ValueError("Cannot specify both cloud configuration and local configuration. Choose one.")
            
        return values

    @model_validator(mode="before")
    @classmethod
    def validate_extra_fields(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        allowed_fields = set(cls.model_fields.keys())
        input_fields = set(values.keys())
        extra_fields = input_fields - allowed_fields
        if extra_fields:
            raise ValueError(
                f"Extra fields not allowed: {', '.join(extra_fields)}. Please input only the following fields: {', '.join(allowed_fields)}"
            )
        return values

View on GitHub (pinned to 001c235229)

Solutions

  1. For local embedding mode, set 'path' (e.g. './chroma_db')
  2. For a Chroma server, set both 'host' and 'port'
  3. For Chroma Cloud, set both 'api_key' and 'tenant'
  4. If host is given, double-check port is also given — host alone does not count as local config

Example fix

# before
ChromaDbConfig(api_key="ck_...")

# after
ChromaDbConfig(api_key="ck_...", tenant="my-tenant")
Defensive patterns

Strategy: validation

Validate before calling

def validate_chroma_connection(cfg: dict) -> None:
    cloud = bool(cfg.get("api_key") and cfg.get("tenant"))
    local = bool(cfg.get("path")) or bool(cfg.get("host") and cfg.get("port"))
    if not cloud and not local:
        raise RuntimeError("Chroma config needs (api_key+tenant) or path or (host+port)")

Type guard

def chroma_connection_ok(cfg: dict) -> bool:
    cloud = bool(cfg.get("api_key") and cfg.get("tenant"))
    local = bool(cfg.get("path")) or bool(cfg.get("host") and cfg.get("port"))
    return cloud or local

Try / catch

from pydantic import ValidationError
try:
    ChromaDbConfig(**cfg)
except ValidationError as e:
    if "must be provided" in str(e):
        # add path / host+port / api_key+tenant, then retry
        ...

Prevention

When it happens

Trigger: Creating ChromaDbConfig with no path/host/port/api_key/tenant; passing only host without port; passing only api_key without tenant (so cloud_config is False) while no local config exists. Note the validator strips a default path of '/tmp/chroma' when cloud config is present.

Common situations: Expecting an env var like CHROMA_API_KEY to be picked up automatically (it is not); passing api_key but forgetting tenant for Chroma Cloud; a default path injected elsewhere being popped because cloud creds exist, leaving neither mode configured.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/c748921da3e82f1e. Report an issue: GitHub.