Class VertexAiEmbeddingModel

java.lang.Object
dev.langchain4j.model.embedding.DimensionAwareEmbeddingModel
dev.langchain4j.model.vertexai.VertexAiEmbeddingModel
All Implemented Interfaces:
EmbeddingModel

public class VertexAiEmbeddingModel extends DimensionAwareEmbeddingModel
Represents a Google Vertex AI embedding model, such as textembedding-gecko. See details here.

This embedding model transparently handles call batching, however the underlying API has imposes a maximum of 250 embeddings per call, with a max of 20,000 tokens per call. You can tweak those two parameters with the maxSegmentsPerBatch() and maxTokensPerBatch() builder methods. For example, if you hit the 20,000 error, set maxTokensPerBatch(18_000).

For authentication and authorization, please follow these steps before using this model:
1. Authentication
When developing locally, you can use one of:
a) Google Cloud SDK
b) Service account When using service account, ensure that GOOGLE_APPLICATION_CREDENTIALS environment variable points to your JSON service account key.
2. Authorization
3. Prerequisites