Cloud Function gets 404 "Model Not Found" from Vertex AI, even with correct IAM roles

Hello everyone,

I’m hoping someone in the community can spot what I’m missing. I have a project where a Cloud Function is unable to access the Gemini Pro model and I’ve hit a wall after trying all the standard troubleshooting steps.

My Goal:
I have a Firestore trigger (onDocumentCreated) in the me-west1 region. This trigger should execute a Cloud Function in us-central1 that calls the Gemini API to generate content.

The Problem:
The function triggers and runs correctly, but the call to generativeModel.generateContent() fails with a 404 Not Found error.

Here is the exact error log:

codeCode

Publisher Model `projects/[YOUR_PROJECT_ID]/locations/us-central1/publishers/google/models/gemini-1.0-pro` was not found or your project does not have access to it.

What I’ve Already Done:

  1. Project/API: The Vertex AI API is enabled and the project has an active billing account.

  2. Function Code: The function is deployed to us-central1 and the code specifies location: “us-central1” for Vertex AI and model: “gemini-1.0-pro”.

  3. IAM Permissions: This is the key part. I have confirmed in the IAM console (with “Include Google-provided role grants” checked) that:

    • The Eventarc Service Agent (…gcp-sa-eventarc.iam.gserviceaccount.com) has the Eventarc Service Agent role.

    • The Vertex AI Service Agent (…gcp-sa-aiplatform.iam.gserviceaccount.com) exists and has the Vertex AI Service Agent and Vertex AI User roles.

I have followed all the official troubleshooting documentation for this 404 error, and everything seems to be configured correctly. The fact that the error persists makes me think there is a subtle, project-level provisioning issue that I can’t see.

Has anyone encountered a similar situation where a project seems unable to access standard Vertex AI models despite having the correct permissions? Is there another service agent or permission I might be missing?

Thank you so much for any help you can provide!

Hi tuval.daskal,

It looks like you are encountering a 404 error because your Cloud Function in us-central1 can’t access the Gemini Pro model via Vertex AI, even though you’ve correctly set up the API and IAM roles.

Here are the potential ways that might help with your use case:

  • Region-Specific Availability: Confirm whether Gemini Pro is available in your region. While us-central1 is commonly used, its integration with Vertex AI may involve regional rollouts or dependencies that could impact your specific setup.
  • Verify Cloud Function Service Account Permissions: Verify that your Cloud Function’s service account has the Vertex AI User role (roles/aiplatform.user) in IAM. This is frequently the primary cause when global model access has been ruled out as the underlying issue.
  • Test Model Availability in Vertex AI Console (us-central1): Try accessing Gemini-1.0-Pro directly through Vertex AI’s Generative AI Studio or Model Garden in the us-central1 region. If you don’t see it available there, the problem is upstream of your function.

For more information, you can check the following documentation below:

If you continue to run into issues, consider reaching out to Google Cloud Support to further check underlying issues. When you contact them, be sure to provide as much detail as possible and include screenshots. This will help them understand your problem better and get it sorted out more quickly.