chroma-core/chroma · error · ValueError
The model cannot be changed after the embedding function has
Error message
The model cannot be changed after the embedding function has been initialized.
What it means
MistralEmbeddingFunction.validate_config_update rejects any config update containing the key 'model', raising this ValueError. The model determines the embedding dimension and vector space (mistral-embed = 1024 dims), so changing it in place would make existing stored vectors incomparable; it is deliberately immutable. Only api_key_env_var is updatable.
Source
Thrown at chromadb/utils/embedding_functions/mistral_embedding_function.py:80
def build_from_config(config: Dict[str, Any]) -> "EmbeddingFunction[Documents]":
model = config.get("model")
api_key_env_var = config.get("api_key_env_var")
if model is None or api_key_env_var is None:
assert False, "This code should not be reached" # this is for type checking
return MistralEmbeddingFunction(model=model, api_key_env_var=api_key_env_var)
def get_config(self) -> Dict[str, Any]:
return {
"model": self.model,
"api_key_env_var": self.api_key_env_var,
}
def validate_config_update(
self, old_config: Dict[str, Any], new_config: Dict[str, Any]
) -> None:
if "model" in new_config:
raise ValueError(
"The model cannot be changed after the embedding function has been initialized."
)
@staticmethod
def validate_config(config: Dict[str, Any]) -> None:
"""
Validate the configuration using the JSON schema.
Args:
config: Configuration to validate
"""
validate_config_schema(config, "mistral")
View on GitHub (pinned to aecdd12c8a)
Solutions
- Create a new collection with the new model EF and re-embed your corpus
- Strip the immutable key: cfg = {k: v for k, v in new_config.items() if k != 'model'}
- Treat model changes as a migration (export documents, new collection, re-import), not a config edit
Example fix
# before
update = ef.get_config() # {"model": "mistral-embed", "api_key_env_var": "MISTRAL_API_KEY"}
update["model"] = "mistral-embed-v2"
ef.validate_config_update(ef.get_config(), update) # ValueError
# after
update = {"api_key_env_var": "MISTRAL_API_KEY_PROD"} # only mutable keys
ef.validate_config_update(ef.get_config(), update) Defensive patterns
Strategy: validation
Validate before calling
def safe_mistral_update(ef, new_config: dict) -> dict:
if "model" in new_config:
raise ValueError(
"model is immutable; create a new collection and re-embed instead"
)
ef.validate_config_update(ef.get_config(), new_config)
return new_config Try / catch
try:
ef.validate_config_update(old, new)
except ValueError as e:
if "cannot be changed" in str(e):
new = {k: v for k, v in new.items() if k != "model"}
ef.validate_config_update(old, new)
else:
raise Prevention
- Model changes = migration: new collection, re-embed, repoint clients
- Diff configs and send only mutable changed keys (api_key_env_var is safe)
- Never round-trip get_config() directly into an update
When it happens
Trigger: Applying a config update with {'model': 'mistral-embed-new'} to an existing EF; round-tripping get_config() (which returns model and api_key_env_var) straight into an update; admin tooling PUTting full config objects.
Common situations: Mistral releasing a new embedding model and attempting an in-place upgrade; config-sync scripts echoing stored config back; manually editing serialized EF config JSON.
Related errors
- The model name cannot be changed after the embedding functio
- The model name cannot be changed after the embedding functio
- CohereEmbeddingFunction model_name cannot be changed after i
- DefaultEmbeddingFunction model cannot be changed after initi
- Chroma server host provided in settings[{settings.chroma_ser
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/18a2680a8e217949.
Report an issue: GitHub.