- Schema:
USER_ AI_ USAGE_ HISTORY view¶
This Account Usage view can be used to query the credits that users consume for AI services, aggregated by hour.
Each row represents the credits consumed by one user, for one service type and one object, during one hour. The view attributes usage to the user that ran the work, including service users.
The view covers a subset of AI service types. It doesn’t include every service type that is billed as AI usage in the METERING_DAILY_HISTORY view. For the service types that the view covers, see Service types.
- See also:
USER_AI_USAGE_HISTORY view (Organization Usage)
Columns¶
| Column Name | Data Type | Description |
|---|---|---|
| USAGE_HOUR | TIMESTAMP_LTZ | Start of the hour in which the usage occurred. The value is aligned to the hour. |
| USER_ID | NUMBER | Internal identifier of the user that the usage is attributed to. 0 indicates usage that couldn’t be attributed to a user. See Usage notes. |
| USER_NAME | VARCHAR | Name of the user. NULL when the user name can’t be resolved, including unattributed usage with USER_ID set to 0. |
| SERVICE_TYPE | VARCHAR | Service type that the usage is billed as. Values correspond to the SERVICE_TYPE column in the METERING_DAILY_HISTORY view. |
| ENTITY_TYPE | VARCHAR | Product category of the object that consumed the credits. See Service types. |
| ENTITY_ID | NUMBER | Internal identifier of the object that consumed the credits. NULL for service types that aren’t tied to a specific object. |
| ENTITY_NAME | VARCHAR | Name of the object that consumed the credits. See Service types. |
| CREDITS | NUMBER | Credits consumed by the user for the service type and object during the hour. Can be 0. Doesn’t include warehouse credits. |
Service types¶
The view returns the following combinations of SERVICE_TYPE, ENTITY_TYPE, and ENTITY_NAME:
| SERVICE_TYPE | ENTITY_TYPE | ENTITY_NAME |
|---|---|---|
| AI_FUNCTIONS | AI FUNCTION | Name of the AI Function, such as AI_COMPLETE or AI_EMBED. ENTITY_ID is NULL. |
| CORTEX_AGENTS | CORTEX AGENT | Name of the Cortex Agent. Use ENTITY_ID to distinguish agents that share a name. |
| SNOWFLAKE_COWORK | SNOWFLAKE INTELLIGENCE | Name of the Snowflake Intelligence object, such as SNOWFLAKE_INTELLIGENCE_OBJECT_DEFAULT. Can be NULL if the object name can’t be resolved. |
| SNOWFLAKE_COCO_CLI | CORTEX CODE | CORTEX_CODE_CLI. ENTITY_ID is NULL. |
| SNOWFLAKE_COCO_SNOWSIGHT | CORTEX CODE | CORTEX_CODE_SNOWSIGHT. ENTITY_ID is NULL. |
| SNOWFLAKE_COCO_DESKTOP | CORTEX CODE | CORTEX_CODE_DESKTOP. ENTITY_ID is NULL. |
| SNOWFLAKE_COCO | CORTEX CODE | CORTEX_CODE. ENTITY_ID is NULL. |
| AI_INFERENCE | AI GATEWAY | Name of the AI Gateway. Use ENTITY_ID to distinguish gateways. Can be NULL if the gateway name can’t be resolved. Includes gateway-routed inference only. Requests sent directly to the Cortex REST API aren’t included. |
| CORTEX_TOOLS | AI GATEWAY | Name of the AI Gateway. Use ENTITY_ID to distinguish gateways. Can be NULL if the gateway name can’t be resolved. |
Usage notes¶
- Latency for the view may be up to 1 hour.
- The view retains credit usage for 12 calendar months, including the current month.
- Only usage that occurred on or after March 1, 2026 is included.
- Usage that Snowflake can’t attribute to a user is returned with
USER_IDset to0andUSER_NAMEempty. A task or a dynamic table runs as the system user unless you setEXECUTE AS USER. To attribute that usage to a user, run the task or dynamic table withEXECUTE AS USER. - Rows can report
0credits. - The credits in this view reconcile with the
CREDITS_BILLEDcolumn of the METERING_DAILY_HISTORY view for the service types that the view covers, exceptAI_INFERENCE. TheAI_INFERENCEservice type includes AI Gateway usage only, so its credits are lower than theAI_INFERENCEtotal inMETERING_DAILY_HISTORY. - Credit rates are listed in the Snowflake Service Consumption Table.
Examples¶
Retrieve credits consumed by each user in the last 30 days:
Retrieve credits consumed by each service type in the last 30 days:
Retrieve credits consumed by each Cortex Agent in the last 30 days: