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
- For local embedding mode, set 'path' (e.g. './chroma_db')
- For a Chroma server, set both 'host' and 'port'
- For Chroma Cloud, set both 'api_key' and 'tenant'
- 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
- Remember host requires port; path works alone
- Cloud config requires both api_key and tenant — plan both in one commit
- Set an explicit path for local dev so no implicit default is relied on
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
- Either 'contact_points' or 'secure_connect_bundle' must be p
- Cannot specify both cloud configuration and local configurat
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Either cloud_id or host must be provided
- Either 'password' must be provided or 'use_azure_credential'
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/c748921da3e82f1e.
Report an issue: GitHub.