chroma-core/chroma · error · ValueError
The mistralai python package is not installed. Please instal
Error message
The mistralai python package is not installed. Please install it with `pip install mistralai`
What it means
MistralEmbeddingFunction lazily imports mistralai.Mistral in __init__ and converts ImportError into this ValueError. mistralai is optional in chromadb installs; the client is needed to call Mistral's embeddings endpoint. The failure occurs at construction, before any network activity.
Source
Thrown at chromadb/utils/embedding_functions/mistral_embedding_function.py:24
class MistralEmbeddingFunction(EmbeddingFunction[Documents]):
def __init__(
self,
model: str,
api_key_env_var: str = "MISTRAL_API_KEY",
):
"""
Initialize the MistralEmbeddingFunction.
Args:
model (str): The name of the model to use for text embeddings.
api_key_env_var (str): The environment variable name for the Mistral API key.
"""
try:
from mistralai import Mistral
except ImportError:
raise ValueError(
"The mistralai python package is not installed. Please install it with `pip install mistralai`"
)
self.model = model
self.api_key_env_var = api_key_env_var
self.api_key = os.getenv(api_key_env_var)
if not self.api_key:
raise ValueError(f"The {api_key_env_var} environment variable is not set.")
self.client = Mistral(api_key=self.api_key)
def __call__(self, input: Documents) -> Embeddings:
"""
Get the embeddings for a list of texts.
Args:
input (Documents): A list of texts to get embeddings for.
"""
if not all(isinstance(item, str) for item in input):
raise ValueError("Mistral only supports text documents, not images")View on GitHub (pinned to aecdd12c8a)
Solutions
- pip install mistralai
- Verify the import: python -c "from mistralai import Mistral; print('ok')"
- Pin mistralai in requirements to survive resolver pruning
Example fix
# before
from chromadb.utils.embedding_functions import MistralEmbeddingFunction
ef = MistralEmbeddingFunction(model="mistral-embed") # ValueError
# after
# pip install mistralai
import importlib.util
if importlib.util.find_spec("mistralai") is None:
raise SystemExit("pip install mistralai")
ef = MistralEmbeddingFunction(model="mistral-embed") Defensive patterns
Strategy: validation
Validate before calling
import importlib.util
if importlib.util.find_spec("mistralai") is None:
raise SystemExit("Mistral EF needs: pip install mistralai")
from chromadb.utils.embedding_functions import MistralEmbeddingFunction
ef = MistralEmbeddingFunction(model="mistral-embed") Try / catch
try:
ef = MistralEmbeddingFunction(model="mistral-embed")
except ValueError as e:
if "mistralai" in str(e):
raise RuntimeError("pip install mistralai") from e
raise Prevention
- Pin mistralai in the lockfile beside chromadb
- Add `from mistralai import Mistral` to CI smoke tests for the runtime interpreter
- Watch for pip resolver downgrades that remove mistralai when other AI packages conflict
When it happens
Trigger: MistralEmbeddingFunction(model='mistral-embed') in an env without the package; fresh venv after `pip install chromadb`; a broken mistralai install whose own dependencies (httpx, pydantic) failed to resolve.
Common situations: New integrations following Mistral embedding tutorials; minimal Docker images; dependency conflicts where pip backtracked and removed mistralai.
Related errors
- The InstructorEmbedding python package is not installed. Ple
- The httpx python package is not installed. Please install it
- The openai python package is not installed. Please install i
- The nomic python package is not installed. Please install it
- The PIL python package is not installed. Please install it w
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/277d51c2bd816cdd.
Report an issue: GitHub.