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.
Alright, I think I figured it out - granted I’m not 100% sure of root cause. The issue has to do with the service accounts. Cloud Functions use the default service account for compute unless you specify otherwise. For some reason the default Compute service account doesn’t have access to Vertex AI (granted you can get into Gemini if you have the API key). I got around the problem by creating a new custom service account and giving it VertexAI permissions - then attaching that new custom service account to my cloud functions.
To be honest I’m still not exactly sure why this works but it does, it could be a bug, like I gave a slew of IAM permissions to the default service account and no luck.
I suspect this doesn’t have visibility because (1) most dev shops have a well-laid out IAM set of rules that are already custom and (2) most use cloud functions with Vertex AI simply for Gemini and not the other features (eg embeddings). Still though, I’d expect to see this raised more often.