How can I track my org's AI costs?
Summary
- Route model traffic through Unity Gateway and each request is logged to the
system.ai_gateway.usagesystem table with its requester, tokens, latency, status and tags. - Billed cost lands in
system.billing.usage. For requests through a model service, Unity Gateway adds the service name, destination model, requesting user and service tags toMODEL_SERVINGrecords. Estimated spend on external providers is insystem.ai_gateway.external_model_spend. - Attribute spend with tags. Service tags set on a model service reach the billing table, and request tags sent in the
Databricks-Ai-Gateway-Request-Tagsheader reach the usage table. - A built-in usage dashboard shows the same data, and budgets turn it into alerts. External spend is an estimate, and list-price conversions exclude negotiated discounts.
How can I track my org's AI costs?
Send AI traffic through Unity Gateway, tag it by team or project, and read the results from system tables or the built-in usage dashboard. The AI governance guide says Unity Gateway "records usage across any model provider and any coding agent," so one set of tables answers who is spending, on which models, and through which tool. Other AI workloads, such as agents and Databricks AI Search, show up in the billing table under their own products.
Which tables hold AI cost data?
| Source | What it holds | Use it to |
|---|---|---|
system.ai_gateway.usage |
Request and response details for model services, model provider services and MCP services: requester, input and output tokens, latency, status code, service tags and request tags. | Rank users, models and teams by tokens and requests. |
system.billing.usage |
Billed usage in DBUs. For gateway requests, MODEL_SERVING records carry usage_metadata.ai_gateway.endpoint_name, usage_metadata.ai_gateway.destination_model, identity_metadata.run_by and service tags in custom_tags. |
Attribute Databricks-billed cost to services, models, users and teams. |
system.billing.list_prices |
List prices. | Join to the usage table to convert DBUs to dollars. |
system.ai_gateway.external_model_spend |
Hourly estimated USD for requests to external models, from token usage and the provider's published prices. | Track spend on external providers. |
| Built-in usage dashboard | Overview, performance, usage and cost views, plus MCP and coding agent tabs. | Share analysis without granting table access. |
How do I attribute cost to a team or project?
Pick the tag type that matches how your traffic is organized:
- Service tags go on a model service, for example
teamset toml-platform, when each team or project has its own service. They appear inendpoint_tagsin the usage table and incustom_tagsinsystem.billing.usage. - Request tags go on individual calls through the
Databricks-Ai-Gateway-Request-TagsHTTP header, a JSON object of string keys and values. Use them when teams share a service. They appear inrequest_tagsin the usage table.
For Databricks-provided models, only service tags reach the billing table. For external provider models, both kinds reach external_model_spend. This query from the cost tutorial groups usage by a service tag:
SELECT
endpoint_tags['team'] AS team,
endpoint_name,
destination_model,
COUNT(*) AS request_count,
SUM(total_tokens) AS total_tokens
FROM system.ai_gateway.usage
WHERE endpoint_tags['team'] IS NOT NULL
GROUP BY endpoint_tags['team'], endpoint_name, destination_model
ORDER BY total_tokens DESC;
The tutorial's next steps join system.billing.usage to system.billing.list_prices for dollars by team, and divide by tokens for cost per million tokens.
Where else do AI costs appear?
The billing_origin_product column in system.billing.usage separates products. For AI, filter on MODEL_SERVING, AI_GATEWAY (gateway usage), AI_FUNCTIONS, AGENT_BRICKS and SUPERVISOR_AGENT (agent workloads), GENIE, VECTOR_SEARCH (Databricks AI Search), AI_RUNTIME (serverless GPU) and AGENT_EVALUATION. Legacy model serving endpoints log to system.serving.endpoint_usage instead of the gateway table.
What does tracking miss or approximate?
- External spend is an estimate. Databricks computes it from token usage and published prices, adjusted by any price multiplier on the model provider service, and it can differ from the invoice.
- Dollar conversions use list price. They exclude negotiated discounts and credits, so use them for attribution and trends and your billing statement for reconciliation.
- Refresh rates differ.
system.billing.usageupdates every few hours, and the external spend table updates hourly. Budgets use a separate near-real-time estimate. - Some tokens aren't recorded. Unity Gateway doesn't track token usage for non-streaming, non-embedding responses larger than 1 MiB.
- Usage tracking is a billed feature. Databricks charges for the usage it logs to the gateway table.
How do I turn tracking into limits?
Create a monthly budget scoped to Unity Gateway, with shared or per-user thresholds that send an alert, block usage, or both. Budgets cover pay-per-token usage and ai_query, and can include external model usage (Beta). They don't cover provisioned throughput or traffic that bypasses the gateway. Account and workspace admins can also see budget status and spend on the AI page in Governance Hub (Beta).
FAQs
Who can query these tables?
Both account and metastore admin roles are required by default. Admins can grant access, or an account admin can create the usage dashboard so other people see the analysis without table access.
How do I see cost by model?
Group system.billing.usage by usage_metadata.ai_gateway.destination_model. With traffic splitting or fallbacks, that field names the destination that ultimately served the request.
Can I see which coding agent drives spend?
The usage dashboard has a Coding Agents tab, and session_metadata.coding_agent in the usage table names the agent. The session fields are in Public Preview.
What if we use several model providers?
Register each as a model provider service. Its estimated spend flows to system.ai_gateway.external_model_spend, and a price multiplier can reflect rates you negotiated.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.