
BigQuery Generative AI Token Quotas for Cost Management

The generative AI functions in BigQuery, including AI.GENERATE, AI.IF, AI.CLASSIFY, and AI.SCORE, let a single SQL query classify millions of support tickets or score each product review for sentiment. Because these functions are billed by token, scaling them across massive datasets makes proactive budget management important. BigQuery has now brought token-based cost management for these functions to general availability, with four daily quotas managed through the Cloud IAM quota system: AI input tokens per day (default 200 billion per project), AI input tokens per day per user (default 150 billion per project per user), AI output tokens per day (default 20 billion per project), and AI output tokens per day per user (default 15 billion per project per user). Per-user limits apply to each user within a project rather than across the organization, and all quotas are global, with usage summed across regions. Output quotas include “thinking” tokens, so reasoning tokens count against them exactly as they do on the Gemini platform bill.
The quotas cover the LLM-backed generation functions AI.GENERATE, AI.GENERATE_TABLE, AI.GENERATE_TEXT (and its alias ML.GENERATE_TEXT), AI.CLASSIFY, AI.IF, AI.SCORE, and AI.AGG. Embedding functions such as AI.GENERATE_EMBEDDING and AI.EMBED are excluded because they run on different, substantially cheaper models.
Administrators can view and adjust the quotas directly in the Google Cloud console at IAM & Admin → Quotas & System Limits, filtering by BigQuery API, with no support case required. Lowering a quota takes effect immediately; increases are requested from the same page and may be auto-approved or go through a quick review. The required roles are Owner, Editor, Quota Administrator, or Service Usage Admin. The same settings can be managed programmatically with the Cloud Quotas API, gcloud CLI, or Terraform. The Quotas & System Limits page also shows historical token consumption to detect spikes and right-size budgets, including a longer-term usage graph with selectable 7-day, 14-day, 30-day, and custom ranges.
Enforcement is preventive: a query is rejected up front with a QuotaExceeded error only if a needed quota is already exhausted; otherwise it starts, and if a quota runs out mid-query, BigQuery stops sending new LLM calls. Functions that support max_error_ratio, such as AI.IF, return partial results when unprocessed rows stay within the ratio and otherwise fail; general-purpose functions like AI.GENERATE still succeed. Skipped rows have no generated value, and their status field contains the quota-exceeded error.
These token quotas are distinct from Cloud Billing spend caps. Token quotas are AI-specific and preventive, tracking token usage during query execution and stopping work near the limit. Spend caps operate on dollars at the project and service level and can automatically block usage when a threshold is reached, but they are a broad financial backstop rather than a precise usage control and can incur some overages because enforcement is not instant. The article recommends using token quotas as the first line of defense and a spend cap as the project-wide safety net.
For sizing, AI.COUNT_TOKENS returns the number of tokens a model’s tokenizer produces for a text string without making a billable generation call, so it can be run over a column to measure input data. The result is a lower bound on input tokens because it excludes output and thinking tokens, the instructions each AI function adds around the input, and non-text inputs such as images. It is useful for gauging the input side before launch, right-sizing quotas after a small sample run measures actual input and output usage, and translating tokens into dollars using the published Gemini platform pricing for the model.
The post includes a worked example: to keep a project near $100/day with Gemini 3.1 Flash-Lite, using BigQuery batch pricing’s 50% discount, input costs $0.125 per million tokens and output costs $0.75 per million tokens. With an average 100:1 input-to-output ratio, the daily budget works out to about 754 million input tokens and 7.54 million output tokens, which become the daily quota values. If a project uses models with different prices, the article recommends budgeting per model or blending the rates.
Best practices from the article are to start with per-user quotas to stop one user or runaway experiment from draining the budget, measure before scaling, set max_output_tokens where available because output tokens cost more, and monitor and adjust limits as real usage and budgets change. Token-based cost management is available now, and setup begins by opening IAM & Admin → Quotas & System Limits and filtering by BigQuery API, with AI.COUNT_TOKENS available for sizing input data.


