In 1.0.0-M2, the documentation for vertexai says to do this as part of the prerequisites:
gcloud config set project <PROJECT_ID> &&
gcloud auth application-default login <ACCOUNT>
However, it would be really useful to be able to specify credentials by other means, for example using a GCP service account. The vertex AI google cloud SDK supports this by passing an instance of com.google.auth.Credentials
to com.google.api.gax.rpc.ClientContext
used in PredictionServiceSettings. Builder
. But in org.springframework.ai.vertexai.embedding.VertexAiEmbeddigConnectionDetails
the predictionServiceSettings
is hardcoded to:
PredictionServiceSettings.newBuilder().setEndpoint(endpoint).build()
making it very difficult to use a service account with spring ai.
Comment From: account123456789
Dear All,
I am not able to invoke the vertex ai embedding model from spring ai , I am getting permission denied issue ... knowing that i am having the proper privileges into my service account , how can i invoke the embedding model ... Thanks in advance
Comment From: ddobrin
Just to confirm, @account123456789, @johanhaleby, have you created the service account key file, downloaded it and set the GOOGLE_APPLICATION_CREDENTIALS account file to the location of the file, as ADC is looking first for that before other locations link
Comment From: johanhaleby
@ddobrin Even if that works I don't want to do this. I'd like my application to be able to load the service account key file from classpath or something like Google Cloud Secret Manager.
Comment From: ddobrin
@johanhaleby - The prev comment "... GOOGLE_APPLICATION_CREDENTIALS account file to the location of the file..." should have been "... GOOGLE_APPLICATION_CREDENTIALS environment variable to the location of the file..."
If I understand correctly, you are looking for usage in a local solution
Comment From: garethjevans
With #1739 merged, you can configure the builder as follows:
VertexAiEmbeddingConnectionDetails.builder()
.withProjectId(projectId)
.withLocation(region)
.withApiEndpoint(endpoint)
.withPredictionServiceSettings(
PredictionServiceSettings.newBuilder()
.setEndpoint(endpoint)
.setCredentialsProvider(FixedCredentialsProvider.create(credentials))
.build());
Where credentials
is an instance of a GoogleCredentials
object (this can be loaded from a service account json)
Comment From: ilayaperumalg
@garethjevans Thanks for the input. @johanhaleby Closing this as complete. Please re-open if you still see the issue.