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
All models (except VertexAiScoringModel) require these builder parameters:
Builder endpoint(String endpoint); // GCP API endpoint URL (required)
Builder project(String project); // Google Cloud Project ID (required)
Builder location(String location); // GCP region (required)
Builder publisher(String publisher); // Model publisher, typically "google" (required)
Builder modelName(String modelName); // Specific model name/version (required)Builder maxRetries(Integer maxRetries); // Retry attempts on API failureType: String (required)
Purpose: Google Cloud Platform API endpoint URL for Vertex AI.
Format varies by region:
US Central: https://us-central1-aiplatform.googleapis.com/v1/
Europe West: https://europe-west1-aiplatform.googleapis.com/v1/
Asia Northeast: https://asia-northeast1-aiplatform.googleapis.com/v1/Embedding models use different format:
us-central1-aiplatform.googleapis.com:443
europe-west1-aiplatform.googleapis.com:443Pattern: https://{location}-aiplatform.googleapis.com/v1/ or {location}-aiplatform.googleapis.com:443
Type: String (required)
Purpose: Your Google Cloud Project ID (not project number).
Example: my-project-123 or production-ml-project
Finding your project ID:
gcloud config get-value projectgcloud projects listType: String (required)
Purpose: Google Cloud Platform region where the model is hosted.
Common values:
us-central1 # Iowa, USA
us-east1 # South Carolina, USA
us-west1 # Oregon, USA
europe-west1 # Belgium
europe-west4 # Netherlands
asia-northeast1 # Tokyo, Japan
asia-southeast1 # SingaporeNotes:
Type: String (required)
Purpose: The organization that published the model.
Value: Almost always "google" for Vertex AI models.
Example:
.publisher("google")Type: String (required)
Purpose: Specific model name and version to use.
Format: {model-name}@{version} or {model-name}
Chat Models:
chat-bison@001
chat-bison@002
gemini-pro
gemini-ultraLanguage Models:
text-bison@001
text-bison@002
text-bison-32kEmbedding Models:
text-embedding-004
textembedding-gecko@001
textembedding-gecko@002
textembedding-gecko@003
text-multilingual-embedding-002
multimodalembeddingImage Models:
imagegeneration@006 # Imagen 3
imagegeneration@005 # Imagen 2
imagegeneration@002 # Imagen 1Scoring Models:
semantic-ranker-512@latestType: Integer (optional)
Purpose: Maximum number of retry attempts for failed API calls.
Default: Varies by model type (typically 2-3)
Range: 0 or positive integer
Behavior:
Example:
.maxRetries(5) // Retry up to 5 times on transient failuresRecommended values:
VertexAiScoringModel uses different required parameters:
Builder projectId(String projectId); // GCP project ID (required)
Builder projectNumber(String projectNumber); // GCP project number (required)
Builder location(String location); // GCP region (required)
Builder model(String model); // Ranking model name (required)Key difference: Requires both projectId and projectNumber (12-digit number).
Finding project number:
gcloud projects describe PROJECT_ID --format="value(projectNumber)"Or check Google Cloud Console project dashboard.
VertexAiChatModel model = VertexAiChatModel.builder()
.endpoint("https://us-central1-aiplatform.googleapis.com/v1/")
.project("my-project")
.location("us-central1")
.publisher("google")
.modelName("chat-bison@001")
.build();VertexAiChatModel model = VertexAiChatModel.builder()
.endpoint("https://us-central1-aiplatform.googleapis.com/v1/")
.project("my-project")
.location("us-central1")
.publisher("google")
.modelName("chat-bison@001")
.maxRetries(5)
.build();String region = "europe-west1";
String endpoint = "https://" + region + "-aiplatform.googleapis.com/v1/";
VertexAiChatModel model = VertexAiChatModel.builder()
.endpoint(endpoint)
.project("my-project")
.location(region)
.publisher("google")
.modelName("chat-bison@001")
.build();String project = System.getenv("GCP_PROJECT_ID");
String location = System.getenv("GCP_LOCATION");
String endpoint = "https://" + location + "-aiplatform.googleapis.com/v1/";
VertexAiChatModel model = VertexAiChatModel.builder()
.endpoint(endpoint)
.project(project)
.location(location)
.publisher("google")
.modelName("chat-bison@001")
.build();All models implement automatic retry logic for transient failures:
Configure retry behavior via maxRetries() parameter.
Install with Tessl CLI
npx tessl i tessl/maven-dev-langchain4j--langchain4j-vertex-ai@1.11.0