Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

CohereDocumentImageEmbedder

Compute document embeddings based on images using Cohere's multimodal embedding API. Use this component in indexing pipelines to embed image documents before writing them to a document store.

Key Features​

  • Uses Cohere multimodal models (such as embed-v4.0) to embed documents containing images or PDFs.
  • Stores the computed embedding in each document's embedding field, enabling image-based semantic search and retrieval.
  • Reads image file paths from a configurable document metadata field (default: file_path).
  • Supports JPEG and PNG images, as well as PDF pages converted to JPEG automatically.
  • Configurable embedding type (float, int8, uint8, binary, ubinary) and optional embedding dimension for v4 and newer models.
  • Supports both synchronous and asynchronous operation via run() and run_async().

Configuration​

  1. Drag the CohereDocumentImageEmbedder component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Select the embedding model. Make sure Haystack Platform is connected to your Cohere account. For details, see Use Cohere Models.
    2. Set the file_path_meta_field to the document metadata key that holds the image file path (default: file_path).
  4. Go to the Advanced tab to configure embedding_type, embedding_dimension, image_size, timeout, and progress_bar.

Connections​

CohereDocumentImageEmbedder receives a list of documents through its documents input. Each document must include an image file path in its metadata under the field specified by file_path_meta_field. It outputs the same documents with their embeddings added through its documents output.

Connect it after a converter that creates documents with image paths in their metadata. Connect its documents output to DocumentWriter to store embedded documents in a document store.

Source Code​

To check this component's source code, open document_image_embedder.py in the Haystack Core Integrations repository.

Usage Examples​

Basic Configuration​

CohereDocumentImageEmbedder:
type: haystack_integrations.components.embedders.cohere.document_image_embedder.CohereDocumentImageEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- COHERE_API_KEY
- CO_API_KEY
strict: false
model: embed-v4.0
file_path_meta_field: file_path
api_base_url: https://api.cohere.com
timeout: 120.0
progress_bar: true

Using the Component in a Pipeline​

This example shows an indexing pipeline that takes documents with image file paths in their metadata, embeds the images using Cohere's multimodal API, and writes them to a document store.

# haystack-pipeline
components:
CohereDocumentImageEmbedder:
type: haystack_integrations.components.embedders.cohere.document_image_embedder.CohereDocumentImageEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- COHERE_API_KEY
- CO_API_KEY
strict: false
model: embed-v4.0
file_path_meta_field: file_path
root_path:
image_size:
api_base_url: https://api.cohere.com
timeout: 120.0
embedding_dimension:
embedding_type: float
progress_bar: true
DocumentWriter:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
policy: OVERWRITE
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: Image-Index
max_chunk_bytes: 104857600
embedding_dim: 1536
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:

connections:
- sender: CohereDocumentImageEmbedder.documents
receiver: DocumentWriter.documents

max_runs_per_component: 100

metadata: {}

inputs:
documents:
- CohereDocumentImageEmbedder.documents

Parameters​

Inputs​

ParameterTypeDescription
documentsList[Document]A list of Documents to embed. Each document must have an image file path in its metadata under the field specified by file_path_meta_field.

Outputs​

ParameterTypeDescription
documentsList[Document]Documents with their embedding field populated and an embedding_source entry added to their metadata.

Init Parameters​

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
api_keySecretSecret.from_env_var(['COHERE_API_KEY', 'CO_API_KEY'])The Cohere API key.
modelstrembed-v4.0The Cohere multimodal embedding model to use. Supported models: embed-v4.0, embed-english-v3.0, embed-english-light-v3.0, embed-multilingual-v3.0, embed-multilingual-light-v3.0. See Cohere documentation for the full list.
api_base_urlstrhttps://api.cohere.comThe Cohere API base URL.
file_path_meta_fieldstrfile_pathThe document metadata field that contains the file path to the image or PDF.
root_pathOptional[str]NoneThe root directory for resolving relative file paths. When None, file paths are treated as absolute.
image_sizeOptional[tuple[int, int]]NoneTarget dimensions (width, height) to resize images while maintaining aspect ratio. Reduces file size, memory usage, and processing time.
timeoutfloat120.0Request timeout in seconds.
embedding_dimensionOptional[int]NoneThe dimension of the embeddings to return. Only valid for v4 and newer models.
embedding_typeEmbeddingTypesfloatThe type of embeddings to return. Specifying a type other than float is only supported for Embed v3.0 and newer models.
progress_barboolTrueWhether to show a progress bar. Disable in production to keep logs clean.

Run Method Parameters​

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDescription
documentsList[Document]A list of Documents to embed.