chroma-core/chroma · error · ValueError

Nomic only supports text queries, not images

Error message

Nomic only supports text queries, not images

What it means

NomicEmbeddingFunction.embed_query performs the same all(isinstance(item, str)) check as __call__ but on the query path, raising ValueError when any query element is not a str. The query path exists so query_config["task_type"] can override the default task type (e.g. search_query vs search_document), but the text-only restriction is identical. It fires on collection.query(query_texts=[...]) when a non-string sneaks in.

Source

Thrown at chromadb/utils/embedding_functions/nomic_embedding_function.py:68

        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,
        )
        return [np.array(data.embedding) for data in output.data]

    @staticmethod
    def name() -> str:
        return "nomic"

    def default_space(self) -> Space:
        return "cosine"

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Normalize query input at the boundary: q = [str(x) for x in query_texts[0]] before calling collection.query
  2. Reject None/numeric query fields with a 400-style validation error in your API layer instead of letting the EF raise
  3. For image queries, use an EF that supports them (OpenCLIP) rather than Nomic

Example fix

// before
collection.query(query_texts=[[None]], n_results=3)  # ValueError: Nomic only supports text queries, not images

// after
q = [str(x) for x in [user_input] if x is not None]
if not q:
    raise ValueError("query text required")
collection.query(query_texts=[q], n_results=3)
Defensive patterns

Strategy: type-guard

Validate before calling

query = [q for q in user_queries if isinstance(q, str) and q]
if not query:
    raise ValueError("at least one non-empty string query required")

Type guard

def is_text_queries(q: list) -> bool:
    """True when the query list is non-empty and all str (Nomic embed_query requirement)."""
    return isinstance(q, list) and len(q) > 0 and all(isinstance(item, str) for item in q)

Try / catch

try:
    results = collection.query(query_texts=[queries], n_results=5)
except ValueError as e:
    if "only supports text queries" in str(e):
        queries = [str(x) for x in queries if x is not None]
        results = collection.query(query_texts=[queries], n_results=5)
    else:
        raise

Prevention

When it happens

Trigger: collection.query(query_texts=[[uri_obj]]) or query_texts=[[None]]) where an element is not str; frontends that pass the raw value of an input field (number, None, dict) into query_texts; reusing multimodal query building code (image URIs) from an OpenCLIP-backed collection against a Nomic-backed one.

Common situations: Search API endpoints that forward user input without normalization (None when the field is blank, int for numeric queries); sharing query-preparation helpers between multimodal and text-only collections; notebooks that pass numpy string scalars.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/e20ccace4c602338. Report an issue: GitHub.