Jorge Turbica / blog · Blog ← All articles ES · Leer en español
Cloud

BigQuery makes token quotas GA for its generative AI functions

Daily token quotas per project and per user for AI.GENERATE, AI.IF or AI.CLASSIFY. Useful if you call LLMs from SQL and want a hard spending cap.

Google Cloud has made token-based quotas for BigQuery's generative AI functions generally available (GA) (October 14, 2026). If your team puts AI.GENERATE or AI.CLASSIFY inside SQL queries, there is now a preventive brake per project and per user, not just a bill you read at the end of the month.

What changes

Quotas are managed through the IAM quota system and apply to AI.GENERATE, AI.GENERATE_TABLE, AI.GENERATE_TEXT (alias ML.GENERATE_TEXT), AI.CLASSIFY, AI.IF, AI.SCORE and AI.AGG. They don't cover AI.GENERATE_EMBEDDING or AI.EMBED, which use different and much cheaper models. There are four daily quotas, global (summed across all regions), with these defaults according to the article:

QuotaScopeDefault
AI input tokens per dayproject200 billion
AI input tokens per day per userproject and user150 billion
AI output tokens per dayproject20 billion
AI output tokens per day per userproject and user15 billion

Output tokens include thinking tokens, as on the Gemini bill. You edit them under IAM & Admin → Quotas & System Limits, filtering by BigQuery API. Lowering a quota takes effect immediately with no approval; raising one is requested on the same page. You need roles such as Quota Administrator (roles/servicemanagement.quotaAdmin) or Service Usage Admin, and you can automate it with the Cloud Quotas API, gcloud and Terraform.

The behavior when a quota runs out is the interesting part. If it is already exhausted when the query starts, the query fails up front with QuotaExceeded. If it runs out mid-query, BigQuery stops sending new calls to the model: functions with max_error_ratio (like AI.IF) return partial results as long as the unprocessed rows stay within the ratio, and general-purpose ones (like AI.GENERATE) still succeed, leaving skipped rows without a value and with the error in their status field.

Why it matters in production

A query over a big table can fire millions of LLM calls without anyone noticing until the invoice arrives. Cloud Billing spend caps are in dollars and, per the article, aren't enforced instantly, so overages can happen. Token quotas are preventive and AI-specific, and the per-user split stops one analyst's experiment from eating the project's budget.

There is a trap to watch for: with the general-purpose functions, running out of quota does not fail the query. A pipeline that doesn't check status can write empty rows and call the job a success.

What I would do

  1. Estimate before setting anything, using AI.COUNT_TOKENS, which gives a lower bound on input tokens (it excludes output, the instructions each function adds, and non-text inputs).
  2. Work out the budget. The article's example, with Gemini 3.1 Flash-Lite at BigQuery's 50% batch discount ($0.125 per million input and $0.75 per million output) and a 100:1 ratio, comes to about 754M input and 7.54M output tokens a day for $100 a day.
  3. Start with per-user quotas and lower the project ones to a realistic value.
  4. Add a check for rows with errors in status to your pipelines, plus an alert on consumption from the quotas page.
  5. Make sure embeddings, which aren't covered, have their own control.

Sources

Jorge Turbica

Software Engineer and SRE. I write about the real challenges I run into in production.

See portfolio ↗