Instruct Customization

You can use Imagen on Vertex AI to instruct the model how to customize and transformthe subjects in an image to a style that you specify in a text prompt.

View Imagen for Editing and Customization model card

Customization prompt writing

The prompt that you use with Imagen 3 Customization might affect thequality of your generated images. Use the following prompt templates as astarting point for writing customization prompts. You might need to send severalrequests to get your targeted output.

Use caseReference imagesPrompt templateExample
Instruct customization - Style transferImage (1)Transform thesubject in image [1] to have a style of${STYLE_DESCRIPTION}. The image depicts${IMAGE_DESCRIPTION}.Transform thesubject in image [1] to have a style ofa watercolor painting of the image with loose watercolor techniques, soft tone, pastel colors, brush strokes, delicate, clean background, spontaneity, analog style drawing, intricate highly detailed painting. The image depictsa portrait of a proud woman.

Customize using instruct customization for style transfer

Use the following code samples to specify the style of the output images basedon the style described in the text prompt.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_ID: Your Google Cloudproject ID.
  • LOCATION: Your project's region. For example,us-central1,europe-west2, orasia-northeast3. For a list of available regions, seeGenerative AI on Vertex AI locations.
  • TEXT_PROMPT: The text prompt guides what images the model generates. To use Imagen 3 Customization, include thereferenceId of the reference image or images you provide in the format[$referenceId]. For example:
    • Transform the subject in image[1] to have a Digital Stained Glass style image style.
    • Add a red cowboy hat to the cat in the image[1].
    • Remove the corgi dog in the image[1].
    • Change the red ball in the image[1] to a blue box.
  • "referenceId": The ID of the reference image, or the ID for a series of reference images that correspond to the same subject or style.
  • BASE64_REFERENCE_IMAGE: A reference image to guide image generation. The image must be specified as abase64-encoded byte string.
  • IMAGE_COUNT: The number of generated images. Accepted integer values: 1-4. Default value: 4.

HTTP method and URL:

POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagen-3.0-capability-001:predict

Request JSON body:

{  "instances": [    {      "prompt": "TEXT_PROMPT",      "referenceImages": [        {          "referenceType": "REFERENCE_TYPE_RAW",          "referenceId":1,          "referenceImage": {            "bytesBase64Encoded": "BASE64_REFERENCE_IMAGE"          }        }      ]    }  ],  "parameters": {    "sampleCount":IMAGE_COUNT  }}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagen-3.0-capability-001:predict"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/imagen-3.0-capability-001:predict" | Select-Object -Expand Content
The following sample response is for a request with"sampleCount": 2. The response returns two prediction objects, with the generated image bytes base64-encoded.
{  "predictions": [    {      "bytesBase64Encoded": "BASE64_IMG_BYTES",      "mimeType": "image/png"    },    {      "mimeType": "image/png",      "bytesBase64Encoded": "BASE64_IMG_BYTES"    }  ]}

Product usage

To view usage standards and content restrictions associated withImagen on Vertex AI, see theusage guidelines.

Model versions

There are multiple image generation models that you can use. For moreinformation, seeImagenmodels.

What's next

Read articles about Imagen and other Generative AI on Vertex AIproducts:

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.