Gemini-embedding-2-preview Persistent API error (code 400): Service agents are being provisioned

I’m getting this error constantly for two days already, not sure why.

Persistent API error (code 400): 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.

I’m trying to use the new gemini-embedding-2-preview https://ai.google.dev/gemini-api/docs/embeddings#gemini-embedding-2-preview

I can use the other gemini api’s, gemini-3-flash-preview etc. with Files API this just fine.

The fix was enabling the Vertex AI service and forcing creation of its service agent:

gcloud services enable aiplatform.googleapis.com --project="$PROJECT_ID"

gcloud beta services identity create \
  --service=aiplatform.googleapis.com \
  --project="$PROJECT_ID"

After that the API calls worked immediately. Looks like the service agent never finished auto-provisioning on its own.