ImagenModel

public final classImagenModel


Represents a generative model (like Imagen), capable of generating images based on various input types.

See the documentation for a list ofsupported models.

Summary

Public methods

final @NonNullImagenGenerationResponse<@NonNullImagenInlineImage>
@PublicPreviewAPI
editImage(
    @NonNullList<@NonNullImagenReferenceImage> referenceImages,
    @NonNullString prompt,
    ImagenEditingConfig config
)

Generates an image from a single or set of base images, returning the result directly to the caller.

final @NonNullImagenGenerationResponse<@NonNullImagenInlineImage>

Generates an image, returning the result directly to the caller.

final @NonNullImagenGenerationResponse<@NonNullImagenInlineImage>

Generates an image by inpainting a masked off part of a base image.

final @NonNullImagenGenerationResponse<@NonNullImagenInlineImage>
@PublicPreviewAPI
outpaintImage(
    @NonNullImagenInlineImage image,
    @NonNullDimensions newDimensions,
    @NonNullImagenImagePlacement newPosition,
    @NonNullString prompt,
    ImagenEditingConfig config
)

Generates an image by outpainting the given image, extending its content beyond the original borders using context from the original image, and optionally, the prompt.

Public methods

editImage

@PublicPreviewAPI
public final @NonNullImagenGenerationResponse<@NonNullImagenInlineImageeditImage(
    @NonNullList<@NonNullImagenReferenceImage> referenceImages,
    @NonNullString prompt,
    ImagenEditingConfig config
)

Generates an image from a single or set of base images, returning the result directly to the caller.

Parameters
@NonNullList<@NonNullImagenReferenceImage> referenceImages

the image inputs given to the model as a prompt

@NonNullString prompt

the text input given to the model as a prompt

ImagenEditingConfig config

the editing configuration settings

generateImages

public final @NonNullImagenGenerationResponse<@NonNullImagenInlineImagegenerateImages(@NonNullString prompt)

Generates an image, returning the result directly to the caller.

Parameters
@NonNullString prompt

The input(s) given to the model as a prompt.

inpaintImage

@PublicPreviewAPI
public final @NonNullImagenGenerationResponse<@NonNullImagenInlineImageinpaintImage(
    @NonNullImagenInlineImage image,
    @NonNullString prompt,
    @NonNullImagenMaskReference mask,
    @NonNullImagenEditingConfig config
)

Generates an image by inpainting a masked off part of a base image. Inpainting is the process of filling in missing or masked off parts of the image using context from the original image and prompt.

Parameters
@NonNullImagenInlineImage image

the base image

@NonNullString prompt

the text input given to the model as a prompt

@NonNullImagenMaskReference mask

the mask which defines where in the image can be painted by Imagen.

@NonNullImagenEditingConfig config

the editing configuration settings, it should include anImagenEditMode

outpaintImage

@PublicPreviewAPI
public final @NonNullImagenGenerationResponse<@NonNullImagenInlineImageoutpaintImage(
    @NonNullImagenInlineImage image,
    @NonNullDimensions newDimensions,
    @NonNullImagenImagePlacement newPosition,
    @NonNullString prompt,
    ImagenEditingConfig config
)

Generates an image by outpainting the given image, extending its content beyond the original borders using context from the original image, and optionally, the prompt.

Parameters
@NonNullImagenInlineImage image

the base image

@NonNullDimensions newDimensions

the new dimensions for the image,must be larger than the original image.

@NonNullImagenImagePlacement newPosition

the placement of the base image within the new image. This can either be coordinates (0,0 is the top left corner) or an alignment (ex:ImagenImagePlacement.BOTTOM_CENTER)

@NonNullString prompt

optional, can be used to specify the background generated if context is insufficient

ImagenEditingConfig config

the editing configuration settings

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-10-09 UTC.