HKUDS/DeepTutor · error · ValueError

Cohere model '{model_name}' does not support multimodal `con

Error message

Cohere model '{model_name}' does not support multimodal `contents`.

What it means

On the v2 API path, the adapter checks the model catalog's 'multimodal' flag before sending contents; if the configured model doesn't declare multimodal support it raises with the model name. Even on v2, text-only models (embed-v3.0 family) cannot take image/text content parts.

Source

Thrown at deeptutor/services/embedding/adapters/cohere.py:88

        input_type = request.input_type or "search_document"

        if api_version == "v1":
            if request.contents:
                raise ValueError(
                    "Cohere v1 API does not support multimodal `contents`. "
                    "Use embed-v4.0 (v2 API) for multimodal."
                )
            payload = {
                "texts": request.texts,
                "model": model_name,
                "input_type": input_type,
            }

            if not request.truncate:
                payload["truncate"] = "NONE"
        else:
            if request.contents and not bool(model_info.get("multimodal", False)):
                raise ValueError(
                    f"Cohere model '{model_name}' does not support multimodal `contents`."
                )
            payload = {
                "model": model_name,
                "embedding_types": ["float"],
                "input_type": input_type,
            }

            if request.contents:
                # Cohere v2 multimodal: `inputs: [{content: [{type, text|image_url}]}]`
                # We translate the simple [{text|image|video}] contract into v2's
                # nested form. v2 cannot mix text+image in one input, so each
                # content dict becomes its own input item.
                inputs = []
                for item in request.contents:
                    if not isinstance(item, dict):
                        continue
                    kind, value = next(iter(item.items()))

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Switch to a multimodal model such as embed-v4.0 (declared multimodal in the catalog)
  2. If the catalog entry is custom and the model truly supports it, add "multimodal": true
  3. Drop contents and send texts only for text-only models

Example fix

# before
await cohere.embed(EmbeddingRequest(model="embed-english-v3.0", contents=parts))
# after
await cohere.embed(EmbeddingRequest(model="embed-v4.0", contents=parts))
Defensive patterns

Strategy: validation

Validate before calling

def model_allows_contents(model_info: dict, request: EmbeddingRequest) -> bool:
    return not request.contents or bool(model_info.get("multimodal", False))

Try / catch

try:
    await adapter.embed(req)
except ValueError as e:
    if "does not support multimodal" in str(e):
        req = replace(req, contents=None)  # degrade to text-only
        return await adapter.embed(req)
    raise

Prevention

When it happens

Trigger: api_version='v2' with request.contents populated but the catalog entry for model_name has multimodal=false or missing (e.g. embed-english-v3.0), then embed().

Common situations: Switching to v2 but keeping a v3.0 model; custom/outdated catalog entries lacking the 'multimodal' key; typo'd model name resolving to a text-only entry.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/c72f20fc56efa10a. Report an issue: GitHub.