r/googlecloud 2d ago

Cloud SQL PostgreSQL google_ml_integration returns "Unavailable error while processing the prediction call"

I am trying to use the google_ml_integration extension in a Cloud SQL PostgreSQL instance to generate text embeddings via Vertex AI, but the query fails with an unavailable error.

What I Have Done:

  1. Extensions Created: Enabled both vector and google_ml_integration in the database.
  2. IAM Permissions: Granted the aiplatform.user role to the Cloud SQL service account associated with the instance.
  3. Billing: The GCP project has billing enabled and the Vertex AI API is active.

The Error:

When running the following query:

SQL

SELECT google_ml.embedding('text-embedding-gecko', 'your_text_here');

It throws this error:

What could be the reason for this? Are there missing database flags, or a specific setup step required for Cloud SQL to communicate with Vertex AI?

Used gemini for formatting

2 Upvotes

2 comments sorted by

1

u/Konstantin_83 2d ago

Hey, this one looks worse than it is. Almost everyone trips over Cloud SQL Vertex the first time. Nothing is wrong with you, and the SQL itself is probably fine. Unavailable on google_ml.embedding() usually means Cloud SQL never finished the call to Vertex.
Check these in order: Instance flag cloudsql.enable_google_ml_integration is on, then restart. Enabling the extension is not enough.

The Cloud SQL instance service account (the one on the instance overview page) has roles/aiplatform.user. The Compute default SA is the usual mix-up.

Region: the Cloud SQL instance and the Vertex model must be in a supported pair. Cross-region calls often come back as Unavailable.

Model id: text-embedding-gecko is the old name. On current Vertex you usually need something like text-embedding-004 / text-embedding-005 and google_ml.create_model() pointing at that id.

If the instance is private-IP only, it needs a path to aiplatform.googleapis.com (PSC / private Google access). No egress, after same Unavailable, no useful SQL error.

If you paste region, Cloud SQL major version, and the exact google_ml.create_model statement, this can be narrowed to one of those five.Separate note, only if you are not locked to Cloud SQL: generating embeddings inside a managed Postgres add-on is the painful part.

A normal MariaDB with vector in the server can store the embeddings you already get from Vertex or another API, without google_ml_integration. That does not fix this GCP flag, it just avoids this class of error next time.Good luck - you’ll get through it. If any step is unclear, ask.

No such thing as a dumb question on this setup.

1

u/GlebOtochkin Googler 1d ago

Hi, can you try a different model? For example ````SELECT google_ml.embedding('text-embedding-005', 'your_text_here');``` - The text-embedding-gecko model was deprecated long time ago. You can have a look for the models lifecycle here - https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/model-versions#gemini-models