Service agents are being provisioned GenerativeModel.generateContent Android

Suddenly receiving an error all day with no changes to my source from when it worked yesterday.
Receiving this when making the generateContent call from Android firebase.vertexai.GenerativeModel

Error: Unexpected Response:
{
“error”: {
“code”: 400,
“message”: “Service agents are being provisioned (Vertex AI access control with IAM  |  Google Cloud). Service agents are needed to read the Cloud Storage file provided. So please try again in a few minutes.”,
“status”: “FAILED_PRECONDITION”
}
}
kotlinx.serialization.MissingFieldException: Field ‘details’ is required for type with serial name ‘com.google.ai.client.generativeai.common.server.GRpcError’, but it was missing at path: $.error

I have the same problem in GCP Vertex AI prompt console. The problem exists if I input video or audio to prompt, while image and pdf work fine without problem.

Failed to submit prompt
Error message: "Service agents are being provisioned (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents). Service agents are needed to read the Cloud Storage file provided. So please try again in a few minutes."

Status: 400 Error code: 9

Request ID: 15926358707855887495

I have tried using the same prompt, the same video, and the same default setting in another GCP account, it is successful. So, I have no idea what’s wrong.

Do you have any findings?

I’m experiencing a very similar error.

I’m calling the gemini-1.5-pro-001:generateContent endpoint ([full endpoint] from Postman.

This API request was repeatedly run successfully up until 8/16. I went to re-test it today (9/5), and got the below error.

{
“error”: {
“code”: 400,
“message”: “Service agents are being provisioned (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents). Service agents are needed to read the Cloud Storage file provided. So please try again in a few minutes.”,
“status”: “FAILED_PRECONDITION”
}
}

I’ve waited about an hour now, and the error is still the same.

Does anyone have any guidance on whether or not these “service agents” are actually being provisioned or this is some other kind of underlying error?

@David_Howe by God’s grace I was able to solve the issue by manually triggering the creation of a Vertex AI Service Agent from the Cloud Shell.

To access the Cloud Shell click on this icon in your Google Cloud Project (GCP)

image

near the top right of the page.

I’m not sure which command finally triggered the Vertex AI Service Agent, so I’ll provide all the commands I tried, and you can try yourself.

  • gcloud ai-platform models create test_model
    • just randomly creating something|
  • gcloud services list --enabled | grep aiplatform
  • gcloud ai endpoints list --region=us-central1
  • gcloud projects get-iam-policy $(gcloud config get-value project) --flatten=bindings[].members --format=table(bindings.role,bindings.members) --filter=bindings.members:service-*@gcp-sa-aiplatform.iam.gserviceaccount.com
  • gcloud ai tensorboards create --display-name=test-tensorboard --region=us-central1
    • just randomly creating something|

I verified that the Service Agent had been created by going to my GCP > IAM, checking the “Include Google-provided role grants” box, and finding a principal with the format service-[YOUR_PROJECT_NUMBER]@gcp-sa-aiplatform.iam.gserviceaccount.com.

Now my API request works in Postman and in my code.

Hope this helps!

4 Likes

@Samuel_Kuhn
You sir are an absolute legend. I got mine working now thanks to you. I only ran the following two commands and it worked:

  • gcloud services list --enabled | grep aiplatform
  • gcloud ai endpoints list --region=us-central1
2 Likes

Thank you so much @Samuel_Kuhn and @David_Howe. I’ve been struggling with this for 2 days. You guys saved me!

It’s bizarre that Google documentation doesn’t address this. Also did not help: Google Cloud Assist, Gemini Chat, ChatGPT, Github CoPilot lol

Thank you so much for posting your workaround @Samuel_Kuhn! This issue wasted half of my day yesterday until I tried your steps.

I use the google AI and the answer is using the following command
gcloud beta services identity create --service=aiplatform.googleapis.com --project=PROJECT_ID

it works

1 Like

This issue has been acknowledged by Google. Strangely only in the context of Firebase though.

I followed the instructions listed there and they worked for me:

Here’s the workaround to fix your project and correctly provision these service agents so that you can start including Cloud Storage for Firebase URLs in your multimodal requests. You must be an Owner on the project, and you only need to complete this set of tasks once for your project.

  1. Access and authenticate with the gcloud CLI.
    The easiest way to do this is from Cloud Shell. Learn more in the Google Cloud.
  2. If prompted, follow the instructions displayed in the terminal to make the gcloud CLI run against your Firebase project.You’ll need your Firebase project ID, which you can find at the top of the settings Project settings in the Firebase console.
  3. Provision the required service agents in your project by running the following command:

curl -X POST -H “Authorization: Bearer $(gcloud auth print-access-token)” -H “Content-Type: application/json” https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID

  1. /locations/us-central1/endpoints -d ‘’

  2. Wait a few minutes to ensure that the service agents are provisioned, and then retry sending your multimodal request that includes the Cloud Storage for Firebase URL.

If you’re still getting this error after waiting several minutes, reach out to Firebase.

Worked like a charm .. Thank you @David_Howe