Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Observe and analyze cost for all Unity Gateway traffic by model service, target model, and requesting principal.
Account and workspace admins can view a consolidated overview of AI spend on the AI page in Governance Hub.
Note
Cost observability is based on Azure Databricks billing records. For request-level usage analytics such as token counts, latency, requester details, and request tags, see Track model usage.
Requirements
- Unity Gateway enabled for your account.
- A Azure Databricks workspace in a Unity Gateway supported region.
- The billable usage system table enabled for your account. See Enable system tables.
Attribution
Unity Gateway provides cost attribution through the billable usage system table (system.billing.usage).
Unity Gateway enriches MODEL_SERVING billing records in system.billing.usage with service-specific metadata, so you can attribute Azure Databricks cost to the associated services, target models, principals, and service tags. For the complete schema and field definitions, see the Billing usage system table reference.
The billable usage system table includes cost attribution for Azure Databricks-hosted models. For external model spend, see External models.
For requests served through a Unity Gateway model service, Azure Databricks populates the following fields on MODEL_SERVING records in system.billing.usage:
| Field | Description |
|---|---|
usage_metadata.ai_gateway.endpoint_name |
The name of the Unity Gateway model service that received the request. This is the Unity Catalog fully qualified name, in the form <catalog>.<schema>.<modelservice>. |
usage_metadata.ai_gateway.endpoint_id |
The ID of the Unity Gateway model service. |
usage_metadata.ai_gateway.destination_model |
The destination model that handled the request, for example GPT-5.2. |
usage_metadata.ai_gateway.destination_id |
The ID of the target that handled the request. |
identity_metadata.run_by |
The user or service principal that issued the request. |
custom_tags |
Service tags configured on the Unity Gateway model service, such as team or cost_center. |
Unity Gateway populates these fields for both real-time and batch inference requests routed through it.
External models
For requests routed to external models through model provider services in Unity Catalog, Azure Databricks computes the estimated USD spend for each request from its token usage and the external provider's published prices, adjusted by any price multiplier configured on the model provider service. Spend is aggregated hourly and recorded in the system.ai_gateway.external_model_spend system table. Use this table to analyze external model spend by model provider service, target model, and requesting principal.
Note
External model spend is provided for informational purposes only. These estimates might not reflect your final provider invoice, and Azure Databricks is not liable for discrepancies in third-party billing.
External model spend schema
The system.ai_gateway.external_model_spend table has the following schema:
| Column name | Type | Description |
|---|---|---|
record_id |
STRING | A unique identifier for the aggregated spend record. |
account_id |
STRING | The account ID. |
workspace_id |
STRING | The ID of the workspace where the model provider service is configured. |
usage_date |
DATE | The date of the usage record, derived from usage_start_time. |
usage_start_time |
TIMESTAMP | The start of the hourly aggregation window, in UTC. |
usage_end_time |
TIMESTAMP | The end of the hourly aggregation window, in UTC. |
ingestion_date |
DATE | The date the record was ingested into the table. |
usage_metadata |
STRUCT | Metadata about the external model usage, including provider, model, endpoint_id, endpoint_name, destination_id, and destination_name. |
custom_tags |
STRUCT | User-provided tags for cost attribution, including endpoint_tags and request_tags. |
usage_unit |
STRING | The unit of measurement for usage_quantity. Always USD. |
usage_quantity |
DECIMAL | The estimated cost, in usage_unit, for the aggregation window. |
pricing_metadata |
STRUCT | Metadata about the pricing applied, including service_tier and long_context. |
identity_metadata |
STRUCT | Identity of the requester, including run_by and run_as. |
Analyze spend in the usage dashboard
The built-in Unity Gateway usage dashboard helps you identify spending trends, compare models and users, and attribute spend to teams and projects. It includes Azure Databricks-hosted model spend and estimated external model spend.
Open Unity Gateway > Govern > Usage Dashboard.

- Overview: Compare model and user spend, track changes, and evaluate average spend per million tokens or per request.
- Spend: Explore spend by model and user alongside token usage and caching. Use User Spend Breakdown to identify top spenders and their highest-spend models and services.
- Service tags: Apply tags to services to attribute spend to teams or projects. Select a Service Tag Key and one or more Service Tag Value entries in the global filters to focus the analysis. In the Spend tab, use Group Spend by Service Tag to compare spend across tag values.
- Request tags: Send tags through request headers to attribute spend to individual workloads. In the Spend tab, use Group Spend by Request Tag to compare estimated spend across request-tag values.
- Coding agent sessions: Investigate high-spend sessions in the Coding Agents tab, with estimated session spend alongside token usage, models, and subagent activity.
See Built-in usage dashboard to set up and update the usage dashboard.
Analyzing cost
Tip
Genie Code can do this for you. Try this example prompt:
Query system.billing.usage to show AI Gateway DBU cost for the past 30 days, broken down by usage_metadata.ai_gateway.endpoint_name, destination model, and requesting user. Filter to MODEL_SERVING records. Show top 10 in each.
Databricks-hosted models
The following queries analyze cost for Azure Databricks-hosted models in system.billing.usage. Cost can be broken down by model service, target model, and principal.
By model service
SELECT
usage_metadata.ai_gateway.endpoint_name AS endpoint_name,
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 usage_unit = 'DBU'
AND usage_date >= current_date() - INTERVAL 30 DAYS
GROUP BY endpoint_name
ORDER BY dbus DESC;
By destination model
SELECT
usage_metadata.ai_gateway.destination_model AS destination_model,
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 usage_unit = 'DBU'
AND usage_date >= current_date() - INTERVAL 30 DAYS
GROUP BY destination_model
ORDER BY dbus DESC;
By user or service principal
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;
External models
The following queries analyze external model spend in system.ai_gateway.external_model_spend. Spend can be broken down by model provider service, target model, and request tags.
By model provider service
SELECT
usage_metadata.endpoint_name AS model_provider_service,
SUM(usage_quantity) AS usd
FROM system.ai_gateway.external_model_spend
WHERE usage_start_time >= current_timestamp() - INTERVAL 30 DAYS
GROUP BY model_provider_service
ORDER BY usd DESC;
By destination model
SELECT
usage_metadata.model AS destination_model,
SUM(usage_quantity) AS usd
FROM system.ai_gateway.external_model_spend
WHERE usage_start_time >= current_timestamp() - INTERVAL 30 DAYS
GROUP BY destination_model
ORDER BY usd DESC;
By user or service principal
SELECT
identity_metadata.run_by AS run_by,
SUM(usage_quantity) AS usd
FROM system.ai_gateway.external_model_spend
WHERE usage_start_time >= current_timestamp() - INTERVAL 30 DAYS
GROUP BY run_by
ORDER BY usd DESC;
By request tag
To attach request tags to your queries, see Request tagging.
SELECT
custom_tags.request_tags['team'] AS team,
SUM(usage_quantity) AS usd
FROM system.ai_gateway.external_model_spend
WHERE usage_start_time >= current_timestamp() - INTERVAL 30 DAYS
GROUP BY team
ORDER BY usd DESC;
Limitations
- Spend attribution for Azure Databricks-hosted models applies to
MODEL_SERVINGrecords insystem.billing.usage. - For model services with multiple destinations, such as traffic splitting or fallbacks,
ai_gateway.destination_modelandai_gateway.destination_ididentify the destination that ultimately served the request. - External model spend is supported only for model provider services in Unity Catalog.
- External model spend tracking is not currently supported for the Custom provider. Azure Databricks estimates spend from each provider's published prices, which are not available for custom endpoints.