Image embeddings

The GenAI plugin allows you to generate vector embeddings for images. These embeddings can be used for visual similarity search or multi-modal analysis within your Neo4j graph. You can provide images as base64-encoded strings, local file paths, or remote URLs.

Generate a single image embedding

Use the ai.image.embed() function to generate a vector embedding for a single image.

Signature for ai.image.embed()

Syntax

ai.image.embed(resource, provider, configuration = {}) :: VECTOR

Description

Encode a given image as a vector using the named provider.

Inputs

Name

Type

Description

resource

STRING

The image to transform into an embedding: either base64-encoded image bytes, a local file path (file:///path/to/image), or a remote URL (http/https/ftp).

provider

STRING

The identifier of the provider: 'Bedrock-Titan', 'VertexAI'.

configuration

MAP

Provider specific configuration. Use CALL ai.image.embed.providers() to find the configuration needed for each provider.

Returns

VECTOR

The generated vector embedding for the image.

Generate a batch of image embeddings

Use the ai.image.embedBatch() procedure to generate embeddings for a list of images in a single call.

Signature for ai.image.embedBatch()

Syntax

CALL ai.image.embedBatch(resources, provider, configuration = {}) YIELD index, resource, vector

Description

Encode a given batch of images as vectors using the named provider.

Inputs

Name

Type

Description

resources

LIST<STRING>

The images to transform into embeddings: base64-encoded image bytes, local file paths (file:///path/to/image), or remote URLs (http/https/ftp).

provider

STRING

The identifier of the provider: 'Bedrock-Titan', 'VertexAI'.

configuration

MAP

Provider specific configuration.

Returns

Name

Type

Description

index

INTEGER

The index of the corresponding element in the input list.

resource

STRING

The resolved resource element (base64 bytes).

vector

VECTOR

The generated vector embedding for the resource.

Image embedding providers

Use ai.image.embed.providers() to list the available image vector embedding providers and their configuration.

CALL ai.image.embed.providers()
Result
name requiredConfigType optionalConfigType defaultConfig

Bedrock-Titan

{region: STRING, accessKeyId: STRING, secretAccessKey: STRING}

{model: STRING, vendorOptions: MAP}

{model: "amazon.titan-embed-image-v1"}

VertexAI

{project: STRING, region: STRING, apiKey: STRING | token: STRING}

{model: STRING, publisher: STRING, vendorOptions: MAP}

{model: "multimodalembedding", publisher: "google"}

Examples

The following examples show how to generate and store image embeddings.

Generate an embedding from a remote URL
RETURN ai.image.embed(
  "https://example.com/image.jpg",
  "VertexAI",
  {
    project: $project,
    region: "us-central1",
    apiKey: $apiKey
  }
) AS vector
Generate and store embeddings for product images stored as local paths
MATCH (p:Product)
WHERE p.imagePath IS NOT NULL
WITH collect(p) AS products
CALL ai.image.embedBatch(
  [p IN products | "file://" + p.imagePath],
  "Bedrock-Titan",
  {
    region: "us-east-1",
    accessKeyId: $accessKey,
    secretAccessKey: $secretKey
  }
) YIELD index, vector
SET (products[index]).embedding = vector
RETURN count(*) AS count

Provider configuration

For more details on the configuration parameters for each provider, see the following sections: