diff --git a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/embeddings/vertexai-embeddings-text.adoc b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/embeddings/vertexai-embeddings-text.adoc index 839319c52e5..2e1596f55ed 100644 --- a/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/embeddings/vertexai-embeddings-text.adoc +++ b/spring-ai-docs/src/main/antora/modules/ROOT/pages/api/embeddings/vertexai-embeddings-text.adoc @@ -144,8 +144,8 @@ Next, create a `VertexAiTextEmbeddingModel` and use it for text generations: [source,java] ---- -VertexAiEmbeddigConnectionDetails connectionDetails = - VertexAiEmbeddigConnectionDetails.builder() +VertexAiEmbeddingConnectionDetails connectionDetails = + VertexAiEmbeddingConnectionDetails.builder() .withProjectId(System.getenv()) .withLocation(System.getenv()) .build(); @@ -160,3 +160,24 @@ EmbeddingResponse embeddingResponse = this.embeddingModel .embedForResponse(List.of("Hello World", "World is big and salvation is near")); ---- +=== Load credentials from a Google Service Account + +To programmatically load the GoogleCredentials from a Service Account json file, you can use the following: + +[source,java] +---- +GoogleCredentials credentials = GoogleCredentials.fromStream() + .createScoped("https://www.googleapis.com/auth/cloud-platform"); +credentials.refreshIfExpired(); + +VertexAiEmbeddingConnectionDetails connectionDetails = + VertexAiEmbeddingConnectionDetails.builder() + .withProjectId(System.getenv()) + .withLocation(System.getenv()) + .withApiEndpoint(endpoint) + .withPredictionServiceSettings( + PredictionServiceSettings.newBuilder() + .setEndpoint(endpoint) + .setCredentialsProvider(FixedCredentialsProvider.create(credentials)) + .build()); +----