Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › BigQuery

How to Monitor BigQuery AI Function Token Usage and Forecast Monthly Spend (2026 Guide)

By Freedom251 Team · · 11 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Monitor BigQuery AI spending in two places: use each BigQuery job’s Job information panel for the actual input, output, thought, and cached-token counts, then reconcile Vertex AI charges in Cloud Billing with the bigquery_job_id_prefix label. For planning, estimate input tokens with AI.COUNT_TOKENS, measure output and thought tokens from representative jobs, apply the current model’s published rates, and add ordinary BigQuery bytes or slot charges. Daily token quotas can cap activity, but they are global guardrails—not a monthly invoice.

What you are monitoring

BigQuery exposes several AI function families, and they do not all use the same service or billing path. General-purpose generation includes AI.GENERATE and AI.GENERATE_TEXT. Embedding generation uses AI.GENERATE_EMBEDDING. Managed, task-specific functions include AI.IF, AI.SCORE, AI.CLASSIFY, and AI.AGG.

As an Amazon Associate I earn from qualifying purchases.

For general Gemini inference, BigQuery sends requests to Gemini Enterprise Agent Platform. Embedding functions and some task-specific functions can use different services and pricing structures. Before you forecast a workload, identify the exact function, model, endpoint, region, and billing mode. A forecast that treats every AI function as token-priced Gemini generation will be wrong for embeddings or provisioned-throughput deployments.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Step 1: Identify the function, model, and billing path

Generation functions

Generation functions can produce text or structured responses. Their job-level usage can include input tokens, candidate-response output tokens, model-generated thought tokens, and cached input tokens. The model and its serving mode determine which of these categories are billable and at what rates.

Embedding functions

AI.EMBED and AI.GENERATE_EMBEDDING are outside the generative-inference token quotas. They follow different billing structures, so do not add their token counts to the Gemini generation quota ledger. If an embedding function returns statistics, record that information in a separate embedding report.

Managed task-specific functions

Functions such as AI.IF, AI.SCORE, AI.CLASSIFY, and AI.AGG may have service-specific behavior. Confirm which model or endpoint serves each function before assigning a token rate. Keep the function class in your cost table so generation, embedding, and managed workloads cannot be accidentally combined.

Step 2: Estimate input tokens before execution

Use AI.COUNT_TOKENS as a preflight check

Run AI.COUNT_TOKENS against the prompt or a representative input before launching a large query. This gives an estimate of input-token volume without requiring the full generation workload to execute. For a row-based query, sample enough rows to capture short and long records, multimodal payloads, and the complete prompt template used in production.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The estimate is not a promise of the eventual bill. Actual totals can change with the number of rows, prompt-template branches, multimodal inputs, requested output length, candidate count, and model reasoning settings. A prompt-counting check also does not reveal the output or thought tokens that the model will generate.

Turn a sample into a workload estimate

  1. Measure token counts for representative rows, including the largest normal records and any multimodal inputs.
  2. Record the planned number of rows or model calls for each workload.
  3. Multiply the representative per-row input count by the expected call volume, while keeping separate distributions for different prompt templates.
  4. Plan a validation run that captures actual job counters before enabling the full schedule.

Do not use a single unusually small sample to budget a query that processes long documents. Keep a median and a high-percentile sample so the forecast can express normal and peak behavior.

Step 3: Read actual usage from BigQuery Job information

After a Gemini-backed query finishes, the BigQuery job is the source of truth for observed token usage.

  1. Open the query in the BigQuery console.
  2. Open the query results pane.
  3. Select Job information.
  4. Record the token counters shown for the job, along with the job ID, project, location, model, and query time.

The counters aggregate calls made by all applicable generative AI functions in that query. If one SQL statement invokes a model several times, use the job total rather than counting only one expression.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Counter Meaning How to use it in a forecast
Input token count Total input tokens sent by all generative AI functions called in the query. Use the observed total to calibrate prompt and row-volume assumptions.
Output token count Tokens across candidate responses. Separate it from input tokens and account for the model’s output rate when that rate applies.
Thought token count Model-generated reasoning tokens when applicable. Measure from representative jobs; do not infer it from prompt length.
Cache token count Implicitly cached input tokens. Track it separately because cache treatment and pricing can differ from uncached input.

Capture these values for each materially different workload. A single aggregate number can hide a prompt change, a model migration, or a shift in output length.

Step 4: Attribute model charges to a BigQuery job

Filter Cloud Billing by service and label

  1. Open Cloud Billing for the project or billing account that receives the model charges.
  2. Filter the service to Vertex AI.
  3. Filter by the bigquery_job_id_prefix label.
  4. Match the label value to the BigQuery job ID prefix recorded with the Job information counters.

Google’s documented prefix rules allow at most 63 characters. If the original job ID contains uppercase characters, use a lowercase prefix when filtering. Preserve the exact prefix you use in your reconciliation table so a charge can be traced back to its originating job.

Allow for billing latency

Some Vertex AI charges can take up to 24 hours to appear in Cloud Billing. Do not mark a job as under-billed immediately after it runs. Reconcile only after the posting window, then investigate any remaining difference by checking model, region, retries, cache behavior, row-level failures, and the BigQuery execution charge.

Keep inference and BigQuery charges separate

A remote-model query has at least two cost dimensions: the endpoint or model-inference charge and the BigQuery query charge. Vertex AI filtering reveals the former. BigQuery’s own billing export, query history, bytes processed, or slot usage is needed for the latter. Add both to the monthly budget.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Step 5: Build a transparent monthly forecast

Create one record for each workload and model

Maintain a forecasting table at the granularity where assumptions change. Separate production queries from backfills, different prompt templates, models, regions, and candidate counts. Keep the following fields:

  • Workload name and BigQuery project.
  • Function class and model or endpoint.
  • Expected monthly calls or rows.
  • Input, output, thought, and cache tokens per call, based on observed jobs.
  • Current published rate for every token category the model bills.
  • Estimated BigQuery bytes processed or slot usage.
  • Any endpoint or API charges outside token rates.
  • Scenario label: low, expected, or high.

Apply the token-cost equation

Use the model’s current pricing units and include only token categories that pricing for that model actually bills:

monthly model cost = (input_tokens × input_rate
                     + output_tokens × output_rate
                     + thought_tokens × thought_rate
                     + cache_tokens × cache_rate) / 1,000,000

The token quantities in this equation are monthly totals, not per-row samples. If a category is not billed for the selected model, omit that term rather than assigning it a zero-rate assumption without checking the pricing page. Recheck dynamic rates when you publish the budget and whenever the model or region changes.

Add BigQuery execution cost

After calculating model cost, add the expected BigQuery bytes or slot charges for the SQL itself. Include scans that prepare prompts, joins that select rows, and writes that store responses. A query can have low token volume but a high BigQuery scan, or high token volume with a relatively small scan; the forecast needs both measurements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Include other endpoint charges

If the selected serving mode has charges beyond token rates, add them as a separate line. Keep this line distinct from BigQuery execution and from token arithmetic so a rate change can be updated without rewriting the whole model.

Use three scenarios instead of one point estimate

Low scenario

Use the observed median rows and token counts for each workload. This represents ordinary days when traffic and document sizes are near the middle of their distributions.

Expected scenario

Use a rolling 30-day average by workload. Refresh the average as prompt templates, model settings, and traffic mix change. Reconcile this scenario to Cloud Billing after the posting delay.

High scenario

Use the p95 rows and token counts, then apply an explicit growth assumption. Keep the growth factor visible rather than burying it in a rounded total. This scenario is the basis for quota and budget reviews because retries, long documents, and seasonal volume can push usage above the average.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Scenario Rows and token basis Decision use
Low Observed median rows and token counts Routine operating estimate
Expected Rolling 30-day average by workload Primary budget and billing reconciliation
High P95 rows and token counts plus a stated growth assumption Capacity, quota, and contingency planning

Why a query can cost more than expected

Prompt or row growth

Input totals rise when more rows qualify, documents become longer, or a template adds instructions and metadata. Compare the Job information input counter with the row count and with the AI.COUNT_TOKENS sample for the current template.

Longer responses or more candidates

Output tokens are counted across candidate responses. Increasing the maximum output, requesting multiple candidates, or changing a prompt from classification to explanation can raise output totals even when input is unchanged.

Reasoning-token changes

Some models generate thought tokens. A model or reasoning-setting change can therefore increase billable usage without an obvious increase in visible response length. Compare thought-token counters between jobs after every model-setting change.

Cache behavior

Cached input appears as its own counter. A workload with less cache reuse can shift tokens from cached to billable input treatment. Record cache counts rather than folding them into ordinary input.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Retries and partial failures

Retries, row-level failures, and a second execution after a timeout can create charges that are not obvious from the successful result alone. Match Cloud Billing entries to every job prefix and inspect logs when the billed total exceeds the expected number of calls.

BigQuery bytes or slots

The SQL portion can dominate a token-light workload. Check bytes processed or slot usage for scans, joins, and writes separately from Vertex AI charges.

Posting delay

A same-day comparison is incomplete when charges have not yet posted. Wait up to 24 hours before treating the difference as a pricing or usage error.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Set token quotas as spending guardrails

Google documents these default daily quotas for Gemini-backed generative AI functions. They are measured globally across regions and reset at midnight Pacific time.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Quota Default daily limit Scope
AI input tokens per day 200,000,000,000 Google Cloud project, global across regions
AI input tokens per day per user 150,000,000,000 Individual user, global across regions
AI output tokens per day 20,000,000,000 Google Cloud project, global across regions
AI output tokens per day per user 15,000,000,000 Individual user, global across regions

These limits are not a monthly invoice and do not convert directly into currency. They are consumption ceilings. Cached tokens do not count toward the quotas.

Impose stricter limits

  1. Open IAM & Admin → Quotas & System Limits.
  2. Filter the service list for the BigQuery API.
  3. Locate the AI input and output token quotas.
  4. Create quota overrides with limits that match your organization’s daily risk tolerance.

Set limits below the documented defaults when a runaway query could exceed your budget. Coordinate project-level and user-level settings so a single user cannot consume the entire project allowance.

Understand enforcement behavior

Quota checks occur before execution and during execution. When a configured quota is exhausted, new model calls can fail with QuotaExceeded. Remaining rows in an in-progress query can fail, and later generative-AI queries can remain blocked until the quota resets at midnight Pacific time.

Provisioned-throughput models are not billed by token usage. For those models, quota settings still control activity, but a token-based budget calculation is not the billing model; include the applicable provisioned-throughput charge instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Monitor embeddings on a separate path

AI.EMBED and AI.GENERATE_EMBEDDING do not consume the generative-inference token quotas. Treat their costs and limits independently from Gemini generation.

AI.GENERATE_EMBEDDING can return a statistics JSON value containing token_count for text embeddings and token information for some multimodal models. Persist that value with the embedding job’s model, region, row count, and billing record. Do not merge it into the input or output counters used for generative-function quota reporting.

Add request-response logging when job counters are not enough

Agent Platform request-response logging is optional and must be enabled separately for each foundation model and region. Logs are stored in BigQuery. Use it when you need to explain prompt growth, retries, model changes, or row-level failures.

  1. Enable request-response logging for the specific foundation model.
  2. Enable it for every region in which the workload runs.
  3. Query the BigQuery log tables and search the full_request field for labels.bigquery_job_id_prefix.
  4. For US queries, specify us-central1; for EU queries, specify europe-west4.
  5. Join the matching request and response records to the BigQuery job ID, token counters, and billing entry.

Logging provides request-level context, but it does not replace Cloud Billing reconciliation. Keep both: Job information for the aggregate token totals, logs for payload and failure analysis, and Cloud Billing for posted charges.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build an operating routine

For every new model or prompt

  • Identify the function class, model, endpoint, region, and serving mode.
  • Run representative AI.COUNT_TOKENS checks.
  • Execute a controlled sample and save Job information counters.
  • Record rows, candidates, output settings, reasoning settings, and cache counts.
  • Update the model-rate and BigQuery-cost assumptions in the forecast.

For each production run

  • Store the job ID and location with the workload name.
  • Capture input, output, thought, and cache counters for generative jobs.
  • Capture embedding statistics separately when applicable.
  • Record bytes processed or slot usage for the BigQuery portion.
  • Check for retries, row-level failures, and quota errors.

For monthly close

  1. Wait for the Cloud Billing posting window, allowing up to 24 hours for delayed charges.
  2. Filter Vertex AI charges by bigquery_job_id_prefix.
  3. Reconcile posted model charges to the expected scenario by workload and model.
  4. Add BigQuery bytes or slot charges and any separate endpoint charges.
  5. Explain variances using row volume, token mix, cache behavior, retries, model or region changes, and failures.
  6. Rebase the next rolling 30-day forecast and review the high scenario against quota overrides.

Practical reconciliation checklist

  • Function: Is this generation, embedding, or a managed task-specific function?
  • Model: Did the model, reasoning setting, candidate count, or output limit change?
  • Input: Do observed input tokens match row volume and AI.COUNT_TOKENS samples?
  • Output and thought: Are both counters included where the model bills them?
  • Cache: Did cache-token volume change?
  • Billing: Has enough time passed for Vertex AI charges to post?
  • Attribution: Does the billing label match the lowercase, 63-character-or-shorter job prefix?
  • BigQuery: Were bytes processed or slot charges added to endpoint cost?
  • Quota: Could a global, midnight-Pacific reset or a per-user limit explain failures?
  • Embeddings: Were embedding statistics and billing kept out of generative quota totals?

How to interpret the final number

A defensible monthly estimate is not a single token count. It is the expected number of calls or rows multiplied by observed token distributions, priced with the selected model’s current billable categories, then augmented with BigQuery execution and any endpoint charges. The estimate becomes operationally useful only when it is reconciled to posted Cloud Billing data and bounded by stricter daily quotas than the defaults when the budget requires it.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

BigQuerycloud costsFinOpsGeminiToken usageVertex AI

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.