chroma-core/chroma · error · ValueError
Nomic only supports text documents, not images
Error message
Nomic only supports text documents, not images
What it means
NomicEmbeddingFunction.__call__ validates that every element of the input documents is a Python str before calling self.embed.text. Chroma's Documents type permits image URIs for multimodal embedding functions, but the Nomic text models only accept strings, so any non-string item (typically an ImageDocument/URI object or bytes) triggers this ValueError. It fires at collection.add/update/query time, i.e. when the EF actually embeds.
Source
Thrown at chromadb/utils/embedding_functions/nomic_embedding_function.py:58
try:
from nomic import embed
except ImportError:
raise ValueError(
"The nomic python package is not installed. Please install it with `pip install nomic`"
)
self.model = model
self.task_type = task_type
self.api_key_env_var = api_key_env_var
self.api_key = os.getenv(api_key_env_var)
self.query_config = query_config
if not self.api_key:
raise ValueError(f"The {api_key_env_var} environment variable is not set.")
self.embed = embed
def __call__(self, input: Documents) -> Embeddings:
if not all(isinstance(item, str) for item in input):
raise ValueError("Nomic only supports text documents, not images")
output = self.embed.text(
model=self.model,
texts=input,
task_type=self.task_type,
)
return [np.array(data.embedding) for data in output.data]
def embed_query(self, input: Documents) -> Embeddings:
if not all(isinstance(item, str) for item in input):
raise ValueError("Nomic only supports text queries, not images")
task_type = (
self.query_config.get("task_type") if self.query_config else self.task_type
)
output = self.embed.text(
model=self.model,
texts=input,
task_type=task_type,View on GitHub (pinned to aecdd12c8a)
Solutions
- Coerce every item to str before add/query: docs = [str(d) if not isinstance(d, str) else d for d in docs]
- If your data is images, switch to a multimodal-capable EF (e.g. OpenCLIPEmbeddingFunction) instead of Nomic
- Filter or reject non-text items upstream in the ingestion pipeline before they reach the EF
Example fix
// before
collection.add(ids=["1"], documents=[Path("cat.png")]) # ValueError: Nomic only supports text documents, not images
// after
collection.add(ids=["1"], documents=[str(p) if not isinstance(p, str) else p for p in ["hello.txt"]]) Defensive patterns
Strategy: type-guard
Validate before calling
docs = [d for d in raw_documents if isinstance(d, str)] assert all(isinstance(d, str) for d in docs), "non-text document in batch"
Type guard
from typing import List
def is_text_documents(docs: list) -> bool:
"""True when every item is a plain str (Nomic EF requirement)."""
return isinstance(docs, list) and len(docs) > 0 and all(isinstance(d, str) for d in docs) Try / catch
try:
collection.add(ids=ids, documents=docs)
except ValueError as e:
if "only supports text documents" in str(e):
# coerce/reject the batch, log offending indices, continue
bad = [i for i, d in enumerate(docs) if not isinstance(d, str)]
raise ValueError(f"non-str documents at indices {bad}") from e
raise Prevention
- Normalize documents to str at ingestion time (str(x) for paths/scalars)
- Keep one document pipeline per modality; never feed image-URI lists to a text-only EF
- Add a lint step in your loader that asserts all(isinstance(d, str) ...)
When it happens
Trigger: Calling collection.add(documents=[...]) where the list mixes str and non-str items; passing a numpy str_ / bytes / PIL object / pathlib.Path instead of a plain str; using a multimodal document loader that yields typed objects (e.g. chromadb.utils.document_loaders ImageLoader results) and feeding them to a Nomic EF; passing a single string instead of a list will fail elsewhere, but a list of Paths fails here.
Common situations: Migrating a collection from a multimodal EF (ONNXMiniLM_L6_V2 with images, or OpenCLIP) to Nomic without converting image URIs back to text; data pipelines that emit pathlib.Path or bytes from file scans; JSON payloads decoded with object_hook returning custom classes.
Related errors
- Nomic only supports text queries, not images
- The {api_key_env_var} environment variable is not set.
- The model cannot be changed after the embedding function has
- Embedding function provided when already defined in the coll
- Embedding function name not found in config: {ef_config}
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/f2504e3bb7a01a50.
Report an issue: GitHub.