LangChain4j integration for Google Vertex AI models including chat, language, embedding, image, and scoring capabilities
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Image generation and editing using Google Vertex AI Imagen models (v1, v2, v3). Implements LangChain4j ImageModel.
public class VertexAiImageModel implements ImageModel {
public Response<Image> generate(String prompt);
public Response<List<Image>> generate(String prompt, int n);
public Response<Image> edit(Image image, String prompt);
public Response<Image> edit(Image image, Image mask, String prompt);
public static Builder builder();
}import dev.langchain4j.model.vertexai.VertexAiImageModel;
import dev.langchain4j.model.vertexai.VertexAiImageModel.AspectRatio;
import dev.langchain4j.model.vertexai.VertexAiImageModel.ImageStyle;
import dev.langchain4j.model.vertexai.VertexAiImageModel.MimeType;
import dev.langchain4j.model.vertexai.VertexAiImageModel.PersonGeneration;
import dev.langchain4j.data.image.Image;
import dev.langchain4j.model.output.Response;VertexAiImageModel model = VertexAiImageModel.builder()
.endpoint("https://us-central1-aiplatform.googleapis.com/v1/")
.project("your-project-id")
.location("us-central1")
.publisher("google")
.modelName("imagegeneration@006")
.build();
Response<Image> response = model.generate("A serene mountain landscape at sunset");
Image image = response.content();
byte[] imageData = image.bytes();imagegeneration@006 - Imagen 3 (latest, highest quality)imagegeneration@005 - Imagen 2 (good quality)imagegeneration@002 - Imagen 1 (basic quality)endpoint - API endpoint URLproject - Google Cloud Project IDlocation - GCP regionpublisher - Model publisher ("google")modelName - Model name/versionseed (Long) - Random seed for reproducibility (0-4,294,967,295)language (String) - Language code (e.g., "en", "es")guidanceScale (Integer) - Edit strength (0-21+)negativePrompt (String) - What to avoidaspectRatio (AspectRatio) - Image aspect ratiomimeType (MimeType) - PNG or JPEGcompressionQuality (Integer) - JPEG quality (1-100)personGeneration (PersonGeneration) - Person generation policywatermark (Boolean) - Add watermarksampleImageStyle (ImageStyle) - Style (Imagen v1 only)sampleImageSize (Integer) - Output size in pixelsmaxRetries (Integer) - Retry attempts (default: 3)persistToCloudStorage (String) - GCS URI for savingwithPersisting - Enable local persistencepersistTo (Path) - Local save directorylogRequests (Boolean) - Log requestslogResponses (Boolean) - Log responsesSQUARE (1:1), PORTRAIT (9:16), LANDSCAPE (16:9), THREE_FOURTHS (3:4), FOUR_THIRDS (4:3)
PNG, JPEG
DONT_ALLOW, ALLOW_ADULT, ALLOW_ALL
PHOTOGRAPH, DIGITAL_ART, LANDSCAPE, SKETCH, WATERCOLOR, CYBERPUNK, POP_ART
Install with Tessl CLI
npx tessl i tessl/maven-dev-langchain4j--langchain4j-vertex-ai