- Schema:
USER_ AI_ USAGE_ HISTORY view¶
Important
This view is only available in the organization account. For more information, see Premium views in the organization account.
This Organization Usage view can be used to query the credits that users consume for AI services across all the accounts in your organization, 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 (Account Usage)
Columns¶
Organization-level columns
| Column Name | Data Type | Description |
|---|---|---|
| ORGANIZATION_NAME | VARCHAR | Name of the organization. |
| ACCOUNT_LOCATOR | VARCHAR | System-generated identifier for the account. |
| ACCOUNT_NAME | VARCHAR | User-defined identifier for the account. |
Additional 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. Empty when USER_ID is 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 | SNOWFLAKE_INTELLIGENCE_OBJECT_DEFAULT. |
| 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 | SNOWFLAKE. Usage for the AI Gateway only. Usage for the Cortex REST API isn’t included. |
| CORTEX_TOOLS | AI GATEWAY | SNOWFLAKE. |
Usage notes¶
- Latency for the view may be up to 24 hours.
- The view provides credit usage within the last 365 days (1 year).
- 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, across all accounts:
Retrieve credits consumed by each service type in the last 30 days: