Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Permission denied error when calling vertex ai text embedding from google cloud funtion

Hi,

I am trying to call vertex ai text embedding from a google cloud function like below.

 
aiplatform.init(project=project,location=location)
model = TextEmbeddingModel.from_pretrained("textembedding-gecko@001")
embeddings = model.get_embeddings(sentences)

However I am getting a permission denied error.

google.api_core.exceptions.PermissionDenied: 403 Permission 'aiplatform.endpoints.predict' denied on resource '//aiplatform.googleapis.com/projects/algo-ai-dev-081c04/locations/us-central1/publishers/google/models/textembedding-gecko@001' (or it may not exist). [reason: "IAM_PERMISSION_DENIED"

What IAM permission/ role should i add to my service account to solve this

 

Solved Solved
1 9 16.6K
1 ACCEPTED SOLUTION

Did you ever get this issue resolved? We are facing the same and despite assigning all possible Vertex AI roles (admin, user, AI platform) to the service account, we keep getting it. Please post if you found a solution. Thank you.

Health Jeanie team

View solution in original post

9 REPLIES 9