Which Google Vertex AI model do people actually use for image generation with reference images + prompt?

I’m trying to build an automated image generation workflow in n8n using
Google Cloud (Vertex AI) with a service account. I am using the HTTP Request node to post from URL.

My goal is:

  • provide one or more reference images
  • provide a text prompt describing the scene
  • generate a single final image

I’m NOT looking for text-to-image only.
I specifically need image + image + prompt → new image.

I see many model names in Google documentation and AI Studio, but it’s unclear:

  • which Imagen model is actually usable via Vertex AI REST API
  • which one people use in real production workflows (img2img / image editing)

For example:

  • imagen-3.0-generate-001
  • imagen-3.0-capability-002
  • imagen-3.0-edit-001
  • other recommended alternatives?

Thanks!

1 Like

Hey @Abstract-Creator Welcome to the n8n community!

For image + image + prompt → new image on Vertex AI, the model you want is the Imagen model designed for editing/customization:

• Use imagen-3.0-capability-001 via the Vertex AI Imagen API. This model supports providing one or more reference images and a text prompt to guide generation or edit based on the input images.

Vertex AI also lets you generate or edit images using Imagen with masks or raw reference images, where you send the reference image bytes plus a prompt in the same API call.

If you only need text-to-image without a reference image, the general Imagen generation models (like imagen-3.0-generate-002) are available for that purpose, but they won’t take reference images in the same way. Although i won’t say “That model is the best” cause every model is trained differently i recommend trying out some models and based on the output you are desiring pick the one which meets your needs, let me know if this helps!

1 Like

@Abstract-Creator if this helped you please mark that as a solution

Unfortunately, this isn’t a solution yet. This model still isn’t working for me, and I’m getting errors trying to run it.

indeed, enlighten me with those errors and your workflow

My very simple JSON (Send Body) in HTTP Request looks like this:

{
  "instances": [
    {
      "prompt": "{{ $('HTTP Request GET').item.json.prompt }}",
      "referenceImages": [
        {
          "referenceType": "REFERENCE_TYPE_SUBJECT",
          "referenceId": 1,
          "referenceImage": {
            "bytesBase64Encoded": "{{ $json.data }}"
          }
        }
      ]
    }
  ],
  "parameters": {
    "sampleCount": 1
  }
}

End now i get error:

Bad request - please check your parameters
Request contains an invalid argument.
Error details

From HTTP Request
Error code

400

1 Like

@Abstract-Creator Your error is because the API expects a different JSON structure and specific image fields. Vertex AI’s Generative Image models require referenceImages[i].referenceImage.image with both bytesBase64Encoded and mimeType. Just having referenceImage.bytesBase64Encoded is not enough.

Here’s a working payload pattern:

{
  "instances": [
    {
      "prompt": {{ $json.prompt.toJsonString() }},
      "referenceImages": [
        {
          "referenceId": 1,
          "referenceType": "REFERENCE_TYPE_RAW",
          "referenceImage": {
            "image": {
              "bytesBase64Encoded": {{ $json.data.toJsonString() }},
              "mimeType": "image/png"
            }
          }
        }
      ]
    }
  ],
  "parameters": {
    "sampleCount": 1
  }
}

Key fixes vs your original body

  1. Use referenceImage.image with mimeType
    The API requires the image object to include "image": { "bytesBase64Encoded": ..., "mimeType": ... }. Just putting base64 at referenceImage level is not supported.

  2. Valid referenceType
    Use a supported enum such as "REFERENCE_TYPE_RAW" for raw reference images. Unsupported types can cause a 400.

  3. Proper string injection
    When injecting values from n8n expressions, use .toJsonString() so the JSON sent to the API is valid.

If you adjust your body to match the structure above, the API should stop returning 400 Invalid Argument and accept the request. Maybe this will bring some help to you

2 Likes

This code worked for this model:

{
  "instances": [
    {
      "prompt": "{{ $('HTTP Request GET').item.json.prompt }}",
      "referenceImages": [
        {
          "referenceId": 1,
          "referenceType": "REFERENCE_TYPE_RAW",
          "referenceImage": {
            "bytesBase64Encoded": "{{ $json.data }}",
			"mimeType": "image/png"
          }
        }
      ]
    }
  ],
  "parameters": {
    "editMode": "EDIT_MODE_DEFAULT",
    "sampleCount": 1,
    "aspectRatio": "1:1"
  }
}

There are minor differences in the structure of “referenceImage,” and perhaps the addition of “editMode” in “parameters” had something to do with it.

Thank you anyway.

1 Like

I think i deserved that solution. Anyways happy n8n-ing

No problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.