Skip to content

Calling a hosted Google language model straight from BigQuery

BigQuery lets you call Google's pretrained large language models directly from SQL by creating a remote model object that points to a Vertex AI endpoint through a BigQuery Cloud resource connection. This enables generative AI tasks like text generation and embeddings without moving data out of BigQuery or standing up separate ML infrastructure.

1 · Learn the must-know

  • You must first create a BigQuery Cloud resource connection (CREATE CONNECTION) which provisions a service account used to authenticate to Vertex AI.
  • The connection's service account needs the Vertex AI User IAM role (or equivalent permissions) granted before the remote model will work.
  • A remote model is created with CREATE MODEL ... REMOTE WITH CONNECTION, specifying the connection and the target pretrained endpoint (e.g., a Gemini model).
  • Once the remote model exists, ML.GENERATE_TEXT is used to generate text output and ML.GENERATE_EMBEDDING is used to produce vector embeddings from a table's text column, both via standard SQL.
  • The BigQuery dataset, the connection, and the Vertex AI endpoint region must be compatible (often same region) or model creation/inference will fail.
  • Calls to these remote LLM functions incur Vertex AI prediction charges in addition to normal BigQuery query costs, so usage should be monitored.

2 · Check your understanding

Check this objectiveFree · always available

A data analyst at a retail company wants to use a pretrained Gemini model directly from BigQuery SQL to summarize thousands of customer review rows stored in a table, without exporting any data or training a custom model. Which sequence of steps correctly enables this in BigQuery?

Your objective map0 tried · 0 answered correctly · 41 untouched

What you have tried across GCP ADP's objectives, not a readiness score.

Data Preparation and Ingestion~30% of the exam0 of 8 tried
Data Analysis and Presentation~27% of the exam0 of 12 tried
Data Pipeline Orchestration~18% of the exam0 of 9 tried
Data Management~25% of the exam0 of 12 tried

3 · Keep going