Class VertexAiImageModel

java.lang.Object
dev.langchain4j.model.vertexai.VertexAiImageModel
All Implemented Interfaces:
dev.langchain4j.model.image.ImageModel

public class VertexAiImageModel extends Object implements dev.langchain4j.model.image.ImageModel
Image model for the Google Cloud Vertex AI Imagen image generation models. Supports both versions of Imagen v1 and v2, respectively identified by the model names imagegeneration@002 and imagegeneration@005.
  • Constructor Details

    • VertexAiImageModel

      public VertexAiImageModel(String endpoint, String project, String location, String publisher, String modelName, Long seed, String language, Integer guidanceScale, String negativePrompt, VertexAiImageModel.ImageStyle sampleImageStyle, Integer sampleImageSize, Integer maxRetries, Boolean withPersisting, Path persistTo)
      Constructor of the Imagen image generation model.
      Parameters:
      endpoint - the base URL of the API (eg. https://us-central1-aiplatform.googleapis.com/v1/)
      project - the Google Cloud Project ID
      location - the cloud region (eg. us-central1)
      publisher - the publisher of the model (google for Imagen)
      modelName - the name of the image model (imagegeneration@002 or imagegeneration@005)
      seed - a fixed random seed number between 0 and 2^32-1
      language - the spoken language used for the prompt
      guidanceScale - an integer that represents the strength of the edit to make (0-9: low, 10-20: medium, 21+: high)
      negativePrompt - a negative prompt to specify what you don't want to see in the generated image
      sampleImageStyle - the style of the image for Imagen v1, see the ImageStyle enum for reference
      sampleImageSize - the size of the images to generate
      maxRetries - number of times to retry in case of error (default: 3)
      withPersisting - true if the generated images should be persisted on the local file system
      persistTo - the Path of the directory that should contain the generated images
  • Method Details

    • generate

      public dev.langchain4j.model.output.Response<dev.langchain4j.data.image.Image> generate(String prompt)
      Specified by:
      generate in interface dev.langchain4j.model.image.ImageModel
    • generate

      public dev.langchain4j.model.output.Response<List<dev.langchain4j.data.image.Image>> generate(String prompt, int n)
      Specified by:
      generate in interface dev.langchain4j.model.image.ImageModel
    • edit

      public dev.langchain4j.model.output.Response<dev.langchain4j.data.image.Image> edit(dev.langchain4j.data.image.Image image, String prompt)
      Specified by:
      edit in interface dev.langchain4j.model.image.ImageModel
    • edit

      public dev.langchain4j.model.output.Response<dev.langchain4j.data.image.Image> edit(dev.langchain4j.data.image.Image image, dev.langchain4j.data.image.Image mask, String prompt)
      Specified by:
      edit in interface dev.langchain4j.model.image.ImageModel
    • builder

      public static VertexAiImageModel.Builder builder()