HKUDS/DeepTutor · error · ValueError
Cohere v2 does not support content type '{kind}'
Error message
Cohere v2 does not support content type '{kind}' What it means
While mapping multimodal contents to Cohere v2 inputs, the adapter handles only 'text' and 'image' kinds; any other content kind (audio, video, generic 'file') raises with the offending kind. Cohere's embed-v4.0 input schema accepts text and image_url parts only.
Source
Thrown at deeptutor/services/embedding/adapters/cohere.py:114
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()))
if kind == "text":
inputs.append({"content": [{"type": "text", "text": value}]})
elif kind == "image":
inputs.append(
{"content": [{"type": "image_url", "image_url": {"url": value}}]}
)
else:
raise ValueError(f"Cohere v2 does not support content type '{kind}'")
payload["inputs"] = inputs
else:
payload["texts"] = request.texts
supported_dims = model_info.get("dimensions", [])
if isinstance(supported_dims, list) and len(supported_dims) > 1:
payload["output_dimension"] = dimension or model_info.get("default")
if not request.truncate:
payload["truncate"] = "NONE"
url = self.base_url
logger.debug(f"Sending embedding request to {url} with {len(request.texts)} texts")
async with httpx.AsyncClient(
timeout=self.request_timeout, verify=not disable_ssl_verify_enabled()
) as client:View on GitHub (pinned to 3e82f13042)
Solutions
- Filter contents to text/image parts before calling the Cohere adapter
- Route non-text/image modalities to a provider whose SDK supports them (e.g. DashScope multimodal)
- Reject unsupported kinds at request-build time with a clear error instead of deep in the adapter
Example fix
# before
contents = all_parts # includes {"kind": "audio", ...}
await cohere.embed(EmbeddingRequest(contents=contents))
# after
supported = [p for p in all_parts if p["kind"] in ("text", "image")]
await cohere.embed(EmbeddingRequest(contents=supported)) Defensive patterns
Strategy: type-guard
Validate before calling
ALLOWED = {"text", "image"}
contents = [p for p in contents if p["kind"] in ALLOWED] Type guard
def is_cohere_content(part: dict) -> bool:
return part.get("kind") in ("text", "image") Try / catch
try:
await adapter.embed(req)
except ValueError as e:
if "does not support content type" in str(e):
req = replace(req, contents=[p for p in req.contents if p["kind"] in ("text", "image")])
return await adapter.embed(req)
raise Prevention
- Advertise per-provider modality support and route accordingly
- Reject unsupported kinds at request-build time
When it happens
Trigger: EmbeddingRequest(contents=[{"kind": "audio", ...}]) or kind='file'/'video' passed to the Cohere v2 adapter's embed().
Common situations: Sharing a generic multimodal request builder across providers where another provider accepts audio; upstream pipelines adding new content kinds that reach the Cohere adapter.
Related errors
- Cohere v1 API does not support multimodal `contents`. Use em
- Cohere model '{model_name}' does not support multimodal `con
- OpenAI-compatible embedding model '{model}' does not support
- openai_sdk adapter does not support multimodal `contents`. P
- dashscope SDK not installed. Run `pip install dashscope` (or
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/3234fe6ac65205a7.
Report an issue: GitHub.