CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-dev-langchain4j--langchain4j-vertex-ai

LangChain4j integration for Google Vertex AI models including chat, language, embedding, image, and scoring capabilities

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

overview.mddocs/models/image/

Image Model Overview

Image generation and editing using Google Vertex AI Imagen models (v1, v2, v3). Implements LangChain4j ImageModel.

Class

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();
}

Imports

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;

Minimal Example

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();

Supported Models

  • imagegeneration@006 - Imagen 3 (latest, highest quality)
  • imagegeneration@005 - Imagen 2 (good quality)
  • imagegeneration@002 - Imagen 1 (basic quality)

Configuration Parameters

Required

  • endpoint - API endpoint URL
  • project - Google Cloud Project ID
  • location - GCP region
  • publisher - Model publisher ("google")
  • modelName - Model name/version

Optional

  • seed (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 avoid
  • aspectRatio (AspectRatio) - Image aspect ratio
  • mimeType (MimeType) - PNG or JPEG
  • compressionQuality (Integer) - JPEG quality (1-100)
  • personGeneration (PersonGeneration) - Person generation policy
  • watermark (Boolean) - Add watermark
  • sampleImageStyle (ImageStyle) - Style (Imagen v1 only)
  • sampleImageSize (Integer) - Output size in pixels
  • maxRetries (Integer) - Retry attempts (default: 3)
  • persistToCloudStorage (String) - GCS URI for saving
  • withPersisting - Enable local persistence
  • persistTo (Path) - Local save directory
  • logRequests (Boolean) - Log requests
  • logResponses (Boolean) - Log responses

Enums

AspectRatio

SQUARE (1:1), PORTRAIT (9:16), LANDSCAPE (16:9), THREE_FOURTHS (3:4), FOUR_THIRDS (4:3)

MimeType

PNG, JPEG

PersonGeneration

DONT_ALLOW, ALLOW_ADULT, ALLOW_ALL

ImageStyle (Imagen v1 only)

PHOTOGRAPH, DIGITAL_ART, LANDSCAPE, SKETCH, WATERCOLOR, CYBERPUNK, POP_ART

Use Cases

  • AI art generation
  • Product visualization
  • Marketing content creation
  • Image editing and enhancement
  • Concept prototyping

See Also

  • Examples - Detailed usage examples
  • API Reference - Complete API documentation

Install with Tessl CLI

npx tessl i tessl/maven-dev-langchain4j--langchain4j-vertex-ai@1.11.0

docs

index.md

quick-reference.md

tile.json