CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 6 · Lesson 51/56

    Controlling LLM costs on Databricks: capacity modes, budgets, rate limits and spend attribution

    Use Databricks features to control LLM costs

    17 min read
    1.2% of exam
    8 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Choose between pay-per-token and provisioned throughput by weighing traffic shape against a fixed capacity bill
    • Configure Unity Gateway budget thresholds with alert and block actions, and explain why a budget is not a hard spending cap
    • Contrast a rate limit, which caps spend rate, with a budget, which acts after a threshold, and predict which rate limit a caller hits
    • Attribute LLM spend to users, teams and projects with system.billing.usage, system.ai_gateway.external_model_spend, and service or request tags

    Key concept

    Unity Gateway budget — A monthly spend threshold on traffic that flows through Unity Gateway. When the near-real-time spend estimate crosses it, the budget sends an alert, blocks further requests, or both. Because enforcement runs on an estimate, it limits spend approximately and is not a guaranteed cap on the final bill.

    1.Choosing a capacity mode by its cost shape

    The first cost decision for an LLM workload is how its capacity is bought, and that decision is made before any budget or tag. The Foundation Model API serving modes are pay-per-token, which bills each token against a shared pool, and provisioned throughput, which bills for dedicated capacity. Each one produces a different kind of bill. With pay-per-token, the bill moves with token volume. With provisioned throughput, you pay for the capacity you hold, which is measured in model units.

    Dedicated capacity also changes how the endpoint performs. Shared pay-per-token capacity competes with everyone else's traffic. Provisioned throughput endpoints offer predictable performance because dedicated resources keep latency consistent. Databricks positions provisioned throughput for workloads that require performance guarantees and recommends it for production.

    Reserved provisioned throughput pushes the trade-off further. A reservation is a prepaid grant of model units for a term of 1 or 3 months, and the longer term carries a lower per-unit rate. You pay for the reserved units whether or not traffic uses them, so a reservation only pays off when steady traffic keeps those units busy. Databricks recommends reservations when you are scaling to high or sustained volumes of predictable traffic. For exploratory or low-volume traffic it points to pay-per-token. Traffic above the reserved capacity is rate-limited by default. One common pattern is to reserve a baseline for everyday traffic and configure a fallback so that bursts run on pay-per-token.

    Sizing a provisioned throughput endpoint means setting a minimum and maximum tokens-per-second range that matches the expected traffic. Current models express that capacity in model units instead, and only the legacy model families still use tokens-per-second ranges set at endpoint creation.

    How the two Foundation Model API capacity modes bill and behave
    ConsiderationPay-per-tokenProvisioned throughput
    CapacityShared poolDedicated, reserved capacity
    BillingPer token, so the bill follows volumeBased on provisioned model units
    Latency under loadCompetes with other tenants' trafficPredictable, from dedicated resources
    Best fitExploratory or low-volume trafficHigh or sustained volumes of predictable traffic

    Checkpoint 1 of 9· Check yourself

    A support chatbot gets steady traffic around the clock and must meet a strict latency SLA. Finance also wants a monthly LLM bill they can plan for. What should the team do?

    Checkpoint 2 of 9· Exam question

    A generative AI engineer is serving a foundation model that receives a steady, predictable volume of production traffic 24/7, and the application's latency SLA requires consistently low and stable response times that cannot tolerate the variability of shared, on-demand capacity. Leadership also wants the ability to plan a fixed monthly cost for this workload rather than a variable bill tied to token volume. Which Databricks Foundation Model APIs deployment option best fits this scenario?

    Sources1234

    2.Attributing spend with billing tables and tags

    Before you can control spend, you need to know who and what is generating it. For Databricks-hosted models, cost attribution starts in system.billing.usage. Unity Gateway adds service metadata to the MODEL_SERVING records in that table, for both real-time and batch requests routed through it. Each record can then be grouped by the model service that received the request, the destination model that handled it, the principal that issued it, and the service's tags.

    Fields Unity Gateway populates on MODEL_SERVING records in system.billing.usage
    FieldAnswers
    usage_metadata.ai_gateway.endpoint_nameWhich model service received the request
    usage_metadata.ai_gateway.destination_modelWhich model handled it
    identity_metadata.run_byWhich user or service principal issued it
    custom_tagsService tags such as team or cost_center
    Ranking users and service principals by DBUs consumed on Unity Gateway model services over 30 dayssql
    SELECT
      identity_metadata.run_by AS run_by,
      SUM(usage_quantity) AS dbus
    FROM system.billing.usage
    WHERE billing_origin_product = 'MODEL_SERVING'
      AND usage_metadata.ai_gateway.endpoint_name IS NOT NULL
      AND identity_metadata.run_by IS NOT NULL
      AND usage_unit = 'DBU'
      AND usage_date >= current_date() - INTERVAL 30 DAYS
    GROUP BY run_by
    ORDER BY dbus DESC;

    The query returns DBUs. To turn them into dollars, join system.billing.list_prices at the price that was in effect for each record. The result is a list-price figure: it leaves out negotiated discounts and billing credits, so it works for attribution and trend analysis, but reconciliation still uses the billing statement. Requests to external models go to a different table, system.ai_gateway.external_model_spend. It records estimated USD spend, aggregated hourly, computed from token usage and the provider's published prices. For the request-level view, the usage tables (token counts and endpoint metadata) show which callers consumed the tokens behind a cost.

    Knowing the user tells you who spent the money, but not which team or project to charge it to. Tags fill that gap, and there are two kinds. A service tag is set once on a model service, and every request through that service inherits it, so service tags fit when each team owns its own service. A request tag is set by the caller on each request through a header, so request tags fit when many teams share one service.

    A request tag header attached to a single callhttp
    Databricks-Ai-Gateway-Request-Tags: {"project": "chatbot", "team": "ml-platform"}
    Where each tag type lands, and so which spend it can attribute
    Tag typeSet bysystem.billing.usage (Databricks-hosted models)system.ai_gateway.external_model_spend
    Service tagAdmin, once per model serviceYes, in custom_tagsYes
    Request tagCaller, per requestNoYes

    Checkpoint 3 of 9· Fill the gap

    This query ranks users and service principals by the DBUs they used on Unity Gateway model services that serve Databricks-hosted models. Which table belongs in the FROM clause?

    SELECT
      identity_metadata.run_by AS run_by,
      SUM(usage_quantity) AS dbus
    FROM  ? 
    WHERE billing_origin_product = 'MODEL_SERVING'
      AND usage_metadata.ai_gateway.endpoint_name IS NOT NULL
      AND identity_metadata.run_by IS NOT NULL
      AND usage_unit = 'DBU'
      AND usage_date >= current_date() - INTERVAL 30 DAYS
    GROUP BY run_by
    ORDER BY dbus DESC;

    Checkpoint 4 of 9· Check yourself

    Finance wants a dollar figure for each team's use of a Databricks-hosted model, taken from system.billing.usage. Which setup gives them that?

    Sources56

    3.Budgets: thresholds that alert or block

    Attribution tells you where money went after it was spent. A budget acts while it is being spent. A Unity Gateway budget tracks monthly spend through filters on billing records. You can scope it to the Unity Gateway product alone, or include Unity Gateway in an account-wide budget. For budgets scoped to Unity Gateway, alerts and blocking take effect within moments of crossing a threshold.

    A budget only sees spend that flows through Unity Gateway. Inside its reach:

    • pay-per-token usage
    • ai_query
    • Genie
    • external model providers, if you select Include external model usage

    Two kinds of spend fall outside every budget: provisioned throughput, and traffic sent directly to standalone Model Serving endpoints without passing through Unity Gateway. If a workload moves to provisioned throughput for the reasons in the first section, its budget stops seeing it.

    Thresholds come in three shapes. A shared threshold is one collective limit for everyone in the budget's scope. A per-user threshold is a monthly limit applied to each user individually. A per-user override gives specific users or groups a higher limit than the default per-user threshold, and a user who belongs to several override groups gets the highest one. Each budget supports up to four shared thresholds and 20 per-user overrides, and an account can hold up to 1,000 budgets.

    Each shared or per-user threshold can carry one or both of two actions. Send alert emails the configured addresses, and users keep their access. Block usage stops the user from making further requests through Unity Gateway and shows a message that their budget is exhausted. Access returns when the budget resets or an admin raises the threshold.

    Budget tag filters match model service tags. To give each cost center its own budget, put the cost-center identifier on the model service as a service tag. Request tags appear in the external model spend table but have no effect on budget matching.

    Checkpoint 5 of 9· Match them up

    Match each Unity Gateway budget threshold type and action to its effect.

    Tap a term, then the definition that fits it.

    Checkpoint 6 of 9· Exam question

    A platform team supports five separate agent applications, each tagged with its own cost-center identifier, all routed through a shared Unity Catalog AI Gateway endpoint. Finance wants an email alert the moment any one cost center's monthly spend on that endpoint crosses $2,000, and they want the option to automatically block further requests from that cost center once the threshold is hit. Which Databricks feature should the team configure?

    Sources7

    4.Why a budget is not a hard spending cap

    Budgets make decisions from a near-real-time estimate of cost, so blocking happens only approximately. That has three practical effects. A user can be blocked before their actual spend reaches the threshold. Some spend can pass the threshold before enforcement kicks in. And requests already running when the threshold is crossed finish, so a long generation that started at $4,999 completes. Databricks states plainly that a budget should not be used to guarantee an absolute cap on final billed amounts, and it may later adjust budget estimates to match actual costs.

    The billed figures come from elsewhere. system.billing.usage is the source of truth for Databricks-billed usage, and for external models the provider's invoice is the source of truth. Budget enforcement does not wait for either: it runs on its own near-real-time tracking, independent of when the system tables refresh.

    Checkpoint 7 of 9· Check yourself

    An admin sets a shared threshold of $10,000 with Block usage on a Unity Gateway budget for pay-per-token traffic. Which end-of-month result is consistent with how that budget enforces the limit?

    Sources7

    5.Rate limits: capping the rate of spend

    A budget reacts once a monthly total is crossed. A rate limit works earlier, on how fast spend can accumulate. Gateway rate limits per endpoint, user and group cap requests per minute (QPM) or tokens per minute (TPM) on a model service, so they bound throughput and therefore the rate at which tokens can be billed. No threshold has to be crossed first. A caller over the limit gets HTTP 429 and should retry with exponential backoff. No rate limits exist until you configure them.

    Knowing which limit applies tells you who gets throttled. The service limit is a global ceiling on all traffic: once it is exceeded, every request to the service is blocked, whatever the user or group limits say. Below that ceiling, each caller is held to their own limit. Custom limits override the User (Default) limit, and a limit set on an individual user or service principal takes priority over a group limit. So a user with a low custom limit gets 429s while the service as a whole is far below its ceiling, and other users are unaffected. When a principal has both a QPM and a TPM limit, the more restrictive one applies.

    Budget versus rate limit as a cost control
    AspectBudgetRate limit
    What it limitsMonthly spend totalRequests or tokens per minute
    When it actsAfter a threshold is crossedOn every minute of traffic
    ActionAlert email, block usage, or bothHTTP 429 to the excess requests
    GranularityShared, per-user, per-user overridesService, user default, custom user or group

    The two controls answer different requests from finance. "Email us and stop this cost center at $2,000 a month" is a budget, since a TPM limit has no idea what the month has cost so far. "No single caller may burn tokens faster than X" is a rate limit, since a budget does nothing until a total is reached.

    Checkpoint 8 of 9· Check yourself

    On one model service, the rate limits are a 50,000 TPM service limit, a 10,000 TPM User (Default) limit and a 20,000 TPM limit for the analysts group. The service principal etl-bot belongs to analysts and also has its own custom limit of 2,000 TPM. Total traffic on the service is 15,000 TPM, and etl-bot is sending 5,000 TPM of it. What happens?

    Checkpoint 9 of 9· Exam question

    An engineer configures a rate limit on a Unity Catalog AI Gateway model serving endpoint and sets both a service-level limit and a lower custom limit for one specific user. During testing, that user's requests are throttled with HTTP 429 responses well before the service-level limit is reached, while other users are not. Why does this occur?

    Sources8

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Provisioned throughput provides endpoints with optimized inference for foundation model workloads that require performance guarantees.”
      ↩︎ Choosing a capacity mode by its cost shape
    2. 2.
      “Predictable performance: Dedicated resources ensure consistent latency”
      ↩︎ Choosing a capacity mode by its cost shape
    3. 3.
      “A longer term carries a lower per-unit rate.”
      ↩︎ Choosing a capacity mode by its cost shape
      “If your traffic is exploratory or low-volume, see pay-per-token or priority pay-per-token.”
      ↩︎ Choosing a capacity mode by its cost shape
      “Traffic above your reserved capacity is rate-limited, not served automatically on pay-per-token.”
      ↩︎ Choosing a capacity mode by its cost shape
    4. 4.
      “provision inference capacity based on tokens per second ranges configured during endpoint creation”
      ↩︎ Choosing a capacity mode by its cost shape
    5. 5.
      “Unity Gateway provides cost attribution through the billable usage system table (system.billing.usage).”
      ↩︎ Attributing spend with billing tables and tags
    6. 6.
      “Dollar estimates in this tutorial are based on list price. They exclude negotiated discounts and billing credits.”
      ↩︎ Attributing spend with billing tables and tags
      “Databricks-provided models: use service tags. Only service tags propagate to system.billing.usage.”
      ↩︎ Attributing spend with billing tables and tags
      “Databricks-provided models: use service tags. Only service tags propagate to system.billing.usage.”
      ↩︎ Exam trap 3
    7. 7.
      “Send alert: Sends an email notification to configured addresses. Users retain access to Unity Gateway.”
      ↩︎ Budgets: thresholds that alert or block
      “Block usage: Prevents the user from making further requests through Unity Gateway.”
      ↩︎ Budgets: thresholds that alert or block
      “Budget tag filters apply to model service tags.”
      ↩︎ Budgets: thresholds that alert or block
      “Active requests in progress when the threshold is reached are not interrupted.”
      ↩︎ Why a budget is not a hard spending cap
      “system.billing.usage: Updates every few hours.”
      ↩︎ Why a budget is not a hard spending cap
      “Budgets help you monitor and control monthly Unity Gateway spend using filters applied to billing records.”
      ↩︎ Key concept
      “Do not use this feature as a way to ensure an absolute spend cap on final billed amounts.”
      ↩︎ Exam trap 1
      “Provisioned throughput inference is not currently tracked.”
      ↩︎ Exam trap 2
      “Do not use this feature as a way to ensure an absolute spend cap on final billed amounts.”
      ↩︎ Checkpoint
      “Provisioned throughput inference is not currently tracked.”
      ↩︎ Prediction
      “Per-user overrides: Grant specific users or groups a higher spending limit than the default per-user threshold.”
      ↩︎ Checkpoint
    8. 8.
      “Rate limits let you enforce consumption limits on a model service or MCP service to manage capacity and costs.”
      ↩︎ Rate limits: capping the rate of spend
      “The service rate limit is a global maximum.”
      ↩︎ Rate limits: capping the rate of spend
      “Individual users or service principals: These take priority over user group custom rate limits.”
      ↩︎ Rate limits: capping the rate of spend
      “Individual users or service principals: These take priority over user group custom rate limits.”
      ↩︎ Exam trap 4
      “If a user belongs to both a user-specific limit and a group-specific limit, the user-specific limit is enforced.”
      ↩︎ Checkpoint

    Ready to test yourself?

    Practise the 6 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.