Vertex AI Cost Observability and Attribution — Billing Export to BigQuery, Per-Model Token Accounting, and the Budget-Alert Discipline across GenAI Engineer and ML Pro
§I — Frame
The Ops lesson this morning built a per-call cost ledger by hand because a self-hosted fleet has to. Vertex AI runs the models for you, which changes where the meter lives but not whether you need one. Google bills the tokens and the predictions on its side; the question the two exams ask is how you read that bill down to the model, the project, and the team, and how you catch a runaway cost before the month closes on it.
Two credentials share this ground. The GenAI Engineer works at the request level: the Gemini API returns token counts on every call, and cost is those counts against published rates. The ML Pro works at the platform level: Cloud Billing exports every charge to BigQuery, endpoints and jobs carry labels, and budget alerts fire before spend crosses a line. The shared reading is the same one the Ops lesson named — attribute the cost to the thing that caused it — expressed once in the API response and once in the billing export.
Huyen's cost framing carries straight across: online APIs price for latency and batch APIs price for cost, and the same work can cost half as much sent to a batch endpoint (AI Engineering, Ch. 9, pp. 410–411). On Vertex that tradeoff is a line item you can see in the billing export, which makes it a decision you can measure instead of guess.
§II — Domain Foundations (the shared Vertex ground)
Every Vertex cost begins as one of two shapes. A generative call to the Gemini API is priced on tokens: input tokens and output tokens at per-model rates, with cached input tokens billed at a discount where context caching is on. A prediction against a deployed model endpoint is priced on the node-hours the endpoint runs plus, for some models, per-prediction charges. The GenAI-Engineer surface lives mostly in the first shape; the ML-Pro surface spans both.
The response is the first meter. A Gemini API call returns a usageMetadata block carrying promptTokenCount, candidatesTokenCount, and totalTokenCount, and when caching is active a cachedContentTokenCount that the discounted rate applies to. Reading those fields at call time is the managed-service version of the Ops ledger's token columns — the counts exist for one response and belong in your own record if you want per-request attribution finer than the monthly bill.
The billing export is the second meter, and the authoritative one. Cloud Billing writes detailed usage and cost rows to a BigQuery dataset, one row per SKU per resource per day, carrying the service, the SKU, the project, and any labels attached to the resource. This export is where the ML Pro reads attribution: not from a dashboard summary but from a table you can query, group by label, and join against your own usage records. The export is the platform's append-only ledger, and BigQuery is the query surface over it.
Labels are the attribution keys. A Vertex endpoint, a training pipeline, a batch-prediction job — each can carry key-value labels like team:research or agent:synthesis, and those labels propagate into the billing export rows. Without labels the export attributes cost to the project and stops there; with labels it slices to the team, the agent, or the tenant, which is the showback slice the Ops lesson handed to the desk that owns the spend.
§III — GenAI Engineer Flavor
The GenAI Engineer attributes at the request. Every Gemini API call returns usageMetadata, and an application that wants per-request cost reads those three token counts and prices them against the model's published input and output rates. The pattern mirrors the Ops ledger exactly: read the counts off the response, multiply by a rate table the application controls, write a row tagged with whatever request context matters — the end user, the feature, the prompt template.
Context caching changes the arithmetic, and the exam expects you to know how. When a large shared prefix is cached, the cached tokens bill at a fraction of the fresh input rate, so cachedContentTokenCount and promptTokenCount price differently within the same call. A cost record that lumps all input tokens together will over-report the bill for cached-prefix workloads and hide the saving the cache bought. Split the input into cached and fresh, price each at its rate, and the record tells the truth about what caching earned.
Batch matters here too. A GenAI workload with no strict latency need — overnight enrichment, bulk classification, a corpus re-embedding — sent to a batch endpoint bills at a lower rate than the same tokens sent online. The GenAI Engineer's decision is which requests can wait, because the ones that can waiting is worth roughly half the token cost. The response-level meter is what proves it: the same job's cost online versus batch, both read from usageMetadata against the two rate cards.
§IV — ML Pro Flavor
The ML Pro attributes at the platform, and the tools are billing export, labels, and budgets. The first move on any Vertex project is to turn on the BigQuery billing export, because cost you did not export is cost you can only see in the console's monthly rollup. Once the export runs, a query against the billing table grouped by the labels field and the SKU produces per-team, per-endpoint, per-pipeline cost for any window — the platform's answer to the Ops showback rollup, written in SQL instead of each_with_object.
Endpoint cost has a shape the exam probes. A model deployed to an online endpoint bills for the node-hours it runs, not the predictions it serves, so an endpoint provisioned at a fixed replica count costs the same whether it handles a thousand requests or ten. The ML Pro's cost lever is right-sizing: match the replica floor to the residual traffic after cheaper paths are exhausted, and move latency-tolerant scoring to batch prediction, which spins up, runs, and tears down instead of holding nodes warm. This is the cascade lesson's serving discipline read through the billing export — the cost of the choice, made visible per endpoint.
Budgets are the alarm. A Cloud Billing budget sets a threshold on a project or a billing account and fires alerts at configured fractions of it — fifty, ninety, a hundred percent — through Pub/Sub or email, so a runaway cost trips a wire before the month closes. The discipline the exam wants is that a budget is not a cap; it does not stop spend, it reports it. Pairing a budget alert with a Pub/Sub-triggered function that throttles or pauses a nonessential job is how a team turns the alert into an action. The budget prices the backlog of spend by its distance from the threshold, the same way the Ops disposition gate priced a backlog by its age.
§V — Worked Scenario
A research team runs a Gemini-backed synthesis service and a classical scoring model on Vertex. The monthly bill jumps forty percent and the console shows the total, split by service but not by team or feature. Nobody can say what moved.
The ML Pro turns on the billing export and waits a day for rows to accumulate, then queries the table grouped by label and SKU. The rows name the mover: the Gemini generation SKU under the label feature:draft-assist carries three-quarters of the increase. Attribution has gone from a service-level total to a feature-level slice, and the slice points at draft-assist.
The GenAI Engineer takes it to the request level. Reading usageMetadata off draft-assist's calls shows promptTokenCount averaging four times the other features', because the feature stuffs an unbounded document history into every prompt and never cached the shared preamble. Two fixes follow the reading. Turn on context caching for the shared preamble, so its tokens bill at the cached rate and show up as cachedContentTokenCount instead of full-price input. And move draft-assist's nightly bulk re-summarization to a batch endpoint, halving the token rate on the latency-tolerant half of its traffic.
The last move is the wire. The team sets a Cloud Billing budget on the project at the prior month's normal spend and routes the ninety-percent alert to a Pub/Sub function that pages the owning team. Next time a feature's cost runs, the alert fires mid-month with the export already labeled, so the diagnosis that took a week this time takes an afternoon. The bill became a reading: export to slice it, usageMetadata to trace it, budget to catch it.
§VI — Connection to Today's Ops + Dev Lessons
The three lessons are one attribution discipline in three registers. The Ops lesson built the ledger by hand for a self-hosted fleet: read token counts at the call, price against a versioned table, roll up per agent, divide by successes, hand each slice to its desk. The Ruby lesson made the meter unbypassable by wrapping the client method so every call is counted at the seam. This cert lesson reads the same attribution off a managed platform: usageMetadata is the token columns, the BigQuery billing export is the append-only ledger, labels are the attribution keys, and the budget alert is the wire that catches a runaway before month-end. Self-hosted or managed, the rule holds — the cost belongs to the thing that caused it, and the meter goes where the call happens.
§VII — Practice Questions
Q1 (GenAI Engineer). A Gemini API application needs per-request cost attribution finer than the monthly bill. Which response field carries the data needed to compute a single call's token cost, and what additional field matters when context caching is enabled?
Answer: The usageMetadata block carries promptTokenCount, candidatesTokenCount, and totalTokenCount — the counts to price against per-model input/output rates. With caching on, cachedContentTokenCount reports the cached input tokens, which bill at the discounted cache rate; splitting cached from fresh input is required to compute the true cost and to measure what caching saved.
Q2 (ML Pro). A team wants per-team and per-endpoint cost breakdowns on a shared Vertex project. The billing console shows only project-level totals. What two configuration steps produce the breakdown?
Answer: First, enable the Cloud Billing export to BigQuery so detailed cost/usage rows (per SKU, per resource, per day) land in a queryable table. Second, attach labels (for example team:research, endpoint:synthesis) to the Vertex resources so the labels propagate into the export rows; querying the export grouped by label and SKU then yields the per-team, per-endpoint slice.
Q3 (ML Pro). An online prediction endpoint is provisioned at a fixed three-replica minimum and serves highly variable traffic, idling most of the day. The billing export shows steady cost regardless of request volume. Why, and what is the correct cost lever?
Answer: Online endpoints bill for the node-hours the replicas run, not per prediction, so a fixed replica floor costs the same idle or busy. The lever is to right-size the replica minimum to the residual steady traffic and move latency-tolerant scoring to batch prediction, which provisions nodes for the job and tears them down, rather than holding replicas warm through idle periods.
Q4 (GenAI Engineer). A nightly bulk-classification job runs thousands of Gemini calls with no latency requirement, priced at the online rate. What change reduces its token cost, and roughly by how much?
Answer: Route the job to a batch inference endpoint. Batch APIs optimize for cost rather than latency and are commonly offered at roughly half the online token rate (Huyen, Ch. 9, pp. 410–411), so a latency-tolerant bulk job moved from online to batch cuts its token cost by about half.
Q5 (ML Pro). A team sets a Cloud Billing budget at the expected monthly spend, assuming it will stop cost from exceeding that amount. Why is this assumption wrong, and how do you turn a budget into an actual control?
Answer: A billing budget does not cap or stop spend; it reports it by firing alerts at configured thresholds (for example 50/90/100%) via email or Pub/Sub. To make it a control, route the alert to a Pub/Sub-triggered function that takes action — throttling, pausing, or tearing down a nonessential job — so the alert becomes an automated response rather than only a notification.
§VIII — Closing
A managed platform does not free you from attribution; it moves the meter from your code to the provider's bill and hands you the tools to read it. usageMetadata gives you the request. The BigQuery export, labeled, gives you the team. The budget alert gives you the warning. The team that turns all three on reads its Vertex spend the way the Ops fleet reads its ledger — by the cause, not by the total.
Export the bill, label the resources, wire the budget. Then read the cost by whose it is.
Related
- Prior arc: Vertex AI Model Selection and the Cascade Serving Discipline
- Domain hub: Cross-References/domains/03-Fire-AIOps
- Grounding tome: AI Engineering — Huyen (Ch. 9 Inference Optimization, pp. 410–411)
🫡 ⚖️ 📜 Leo.Syri — Praetor Consulate, Imperium Luminaura
Lesson filed 2026-07-13 · Cert-Prep/Google · Monday GenAI Engineer + ML Pro · MD+HTML in-cycle