chroma-core/chroma · error · ValueError
The model name is required.
Error message
The model name is required.
What it means
GoogleGeminiEmbeddingFunction.build_from_config requires the persisted config dict to contain 'model_name'; it is the only required key (task_type, dimension, etc. all default). It returns None-safe gets for everything else, so a config dict lacking model_name cannot identify which Gemini model to instantiate and the builder refuses.
Source
Thrown at chromadb/utils/embedding_functions/google_embedding_function.py:145
def default_space(self) -> Space:
return "cosine"
def supported_spaces(self) -> List[Space]:
return ["cosine", "l2", "ip"]
@staticmethod
def build_from_config(config: Dict[str, Any]) -> "EmbeddingFunction[Documents]":
model_name = config.get("model_name")
task_type = config.get("task_type")
dimension = config.get("dimension")
api_key_env_var = config.get("api_key_env_var", "GEMINI_API_KEY")
vertexai = config.get("vertexai")
project = config.get("project")
location = config.get("location")
if model_name is None:
raise ValueError("The model name is required.")
return GoogleGeminiEmbeddingFunction(
model_name=model_name,
task_type=task_type,
dimension=dimension,
api_key_env_var=api_key_env_var,
vertexai=vertexai,
project=project,
location=location,
)
def get_config(self) -> Dict[str, Any]:
config: Dict[str, Any] = {
"model_name": self.model_name,
"api_key_env_var": self.api_key_env_var,
"vertexai": self.vertexai,
"project": self.project,
"location": self.location,View on GitHub (pinned to aecdd12c8a)
Solutions
- Include 'model_name' in the config, e.g. {'model_name': 'gemini-embedding-001', ...}
- Emit configs from a live instance via ef.get_config() instead of writing them by hand - it always includes model_name
- Validate the dict against the 'google_gemini' schema (GoogleGeminiEmbeddingFunction.validate_config) before building
Example fix
# before
from chromadb.utils.embedding_functions import GoogleGeminiEmbeddingFunction
ef = GoogleGeminiEmbeddingFunction.build_from_config({"task_type": "RETRIEVAL_DOCUMENT"}) # ValueError
# after
ef = GoogleGeminiEmbeddingFunction.build_from_config({
"model_name": "gemini-embedding-001",
"task_type": "RETRIEVAL_DOCUMENT",
}) Defensive patterns
Strategy: validation
Validate before calling
config = {"model_name": "gemini-embedding-001", "task_type": "RETRIEVAL_DOCUMENT"}
assert config.get("model_name"), "model_name is required in google_gemini config"
ef = GoogleGeminiEmbeddingFunction.build_from_config(config) Type guard
from typing import Any, TypeGuard
def has_model_name(cfg: Any) -> TypeGuard[dict]:
return isinstance(cfg, dict) and isinstance(cfg.get("model_name"), str) and bool(cfg["model_name"]) Prevention
- Generate configs with ef.get_config() from a live instance instead of hand-writing them
- Run GoogleGeminiEmbeddingFunction.validate_config(config) before build_from_config
- Add schema validation for persisted configs in migration scripts
When it happens
Trigger: Calling GoogleGeminiEmbeddingFunction.build_from_config({}) or any dict without a 'model_name' key; hand-written or migrated config dicts where the key was dropped or renamed (e.g. 'model' instead of 'model_name'); corrupted persisted collection metadata being replayed.
Common situations: Manually crafting the config payload passed to get_embedding_function; migrating configs between chromadb versions; tests that build partial configs; editing stored JSON configs by hand.
Related errors
- Invalid hash algorithm specified: {alg}
- The google-genai python package is not installed. Please ins
- Vertex AI and API key are mutually exclusive in the client i
- The {self.api_key_env_var} environment variable must be set
- Input documents cannot be empty
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/b8b97a890c80cbd6.
Report an issue: GitHub.