chroma-core/chroma · error · ValueError
Cloudflare Workers AI only supports text documents, not imag
Error message
Cloudflare Workers AI only supports text documents, not images
What it means
__call__ posts {'text': input} to the Workers AI endpoint, which accepts text only; unlike CohereEmbeddingFunction there is no image branch. Before making the request it requires every element of input to be a str and rejects the batch otherwise. This is an up-front input-type check, not an API-side failure.
Source
Thrown at chromadb/utils/embedding_functions/cloudflare_workers_ai_embedding_function.py:91
self._api_url = f"{BASE_URL}/{self.account_id}/ai/run/{self.model_name}"
self._session = httpx.Client()
self._session.headers.update(
{"Authorization": f"Bearer {self.api_key}", "Accept-Encoding": "identity"}
)
def __call__(self, input: Documents) -> Embeddings:
"""
Generate embeddings for the given documents.
Args:
input: Documents to generate embeddings for.
Returns:
Embeddings for the documents.
"""
if not all(isinstance(item, str) for item in input):
raise ValueError(
"Cloudflare Workers AI only supports text documents, not images"
)
payload: Dict[str, Any] = {
"text": input,
}
resp = self._session.post(self._api_url, json=payload).json()
if "result" not in resp and "data" not in resp["result"]:
raise RuntimeError(resp.get("detail", "Unknown error"))
return cast(Embeddings, resp["result"]["data"])
@staticmethod
def name() -> str:
return "cloudflare_workers_ai"
View on GitHub (pinned to aecdd12c8a)
Solutions
- Send only str documents to CloudflareWorkersAIEmbeddingFunction.
- For images, switch to an image-capable function (e.g. CohereEmbeddingFunction) or convert images to text (OCR/captions) first.
- Add a type guard that splits or filters non-str items before calling the function.
Example fix
# before ef(['a caption', np.zeros((32, 32, 3), dtype=np.uint8)]) # ValueError: only text # after texts = [d for d in batch if isinstance(d, str)] embs = ef(texts) # images go to a separate, image-capable EF
Defensive patterns
Strategy: type-guard
Validate before calling
texts = [d for d in batch if isinstance(d, str)]
if len(texts) != len(batch):
raise ValueError('Cloudflare EF accepts str documents only') Type guard
def is_text_batch(batch: list) -> bool:
return len(batch) > 0 and all(isinstance(d, str) for d in batch) Try / catch
try:
embs = ef(batch)
except ValueError as e:
if 'only supports text documents' in str(e):
batch = [d for d in batch if isinstance(d, str)] # or route images to an image-capable EF
embs = ef(batch)
else:
raise Prevention
- Keep Cloudflare batches homogeneous strings; route images to an image-capable EF.
- Assert element types in the ingestion loader before batching.
- Document per-provider input contracts in your pipeline (Cloudflare: text-only).
When it happens
Trigger: Calling a CloudflareWorkersAIEmbeddingFunction with any non-string element: ef([np.zeros((32, 32, 3), dtype=np.uint8)]), ef(['hello', pil_image]), or ef([b'bytes']).
Common situations: Reusing a multimodal ingestion pipeline built for Cohere (which accepts ndarray images) against the Cloudflare function; batches where an upstream loader yields PIL images, tensors, or bytes alongside text.
Related errors
- The httpx python package is not installed. Please install it
- The model name cannot be changed after the embedding functio
- The PIL python package is not installed. Please install it w
- Expected image input to be a numpy array, got {type(image_np
- Input contains a mix of text documents and images, which is
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/ef47415af1d55317.
Report an issue: GitHub.