Class VertexAiImageModel

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

public class VertexAiImageModel extends Object implements 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, and will also work with the upcoming Imagen v3 model, identified as imagen-3.0-generate-preview-0611 or imagen-3.0-fast-generate-preview-0611 for faster generation.
  • 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, VertexAiImageModel.AspectRatio aspectRatio, VertexAiImageModel.PersonGeneration personGeneration, Integer maxRetries, VertexAiImageModel.MimeType mimeType, Integer compressionQuality, Boolean addWatermark, String cloudStorageBucket, Boolean withPersisting, Path persistTo, Boolean logRequests, Boolean logResponses)
      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, imagegeneration@005, imagen-3.0-generate-preview-0611, imagen-3.0-fast-generate-preview-0611)
      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
      aspectRatio - the aspect ratio of the image, whether square, portrait or landscape
      personGeneration - specify if it is allowed to generate persons (none, only adults, all)
      maxRetries - number of times to retry in case of error (default: 3)
      mimeType - specify the mime type of the image to generate (image/png by default, but image/jpeg possible)
      compressionQuality - when generating a JPEG image, specify the compression quality (ex: 80 for good quality)
      addWatermark - true to generate a watermark so users can know it's an AI generated image (default to false for Imagen v1 and v2, but to true for Imagen v3)
      cloudStorageBucket - URI of the Google Cloud Storage bucket where to persist the generated image
      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