Schema:

ACCOUNT_USAGE

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 NameData TypeDescription
USAGE_HOURTIMESTAMP_LTZStart of the hour in which the usage occurred. The value is aligned to the hour.
USER_IDNUMBERInternal 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_NAMEVARCHARName of the user. NULL when the user name can’t be resolved, including unattributed usage with USER_ID set to 0.
SERVICE_TYPEVARCHARService type that the usage is billed as. Values correspond to the SERVICE_TYPE column in the METERING_DAILY_HISTORY view.
ENTITY_TYPEVARCHARProduct category of the object that consumed the credits. See Service types.
ENTITY_IDNUMBERInternal identifier of the object that consumed the credits. NULL for service types that aren’t tied to a specific object.
ENTITY_NAMEVARCHARName of the object that consumed the credits. See Service types.
CREDITSNUMBERCredits 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_TYPEENTITY_TYPEENTITY_NAME
AI_FUNCTIONSAI FUNCTIONName of the AI Function, such as AI_COMPLETE or AI_EMBED. ENTITY_ID is NULL.
CORTEX_AGENTSCORTEX AGENTName of the Cortex Agent. Use ENTITY_ID to distinguish agents that share a name.
SNOWFLAKE_COWORKSNOWFLAKE INTELLIGENCEName of the Snowflake Intelligence object, such as SNOWFLAKE_INTELLIGENCE_OBJECT_DEFAULT. Can be NULL if the object name can’t be resolved.
SNOWFLAKE_COCO_CLICORTEX CODECORTEX_CODE_CLI. ENTITY_ID is NULL.
SNOWFLAKE_COCO_SNOWSIGHTCORTEX CODECORTEX_CODE_SNOWSIGHT. ENTITY_ID is NULL.
SNOWFLAKE_COCO_DESKTOPCORTEX CODECORTEX_CODE_DESKTOP. ENTITY_ID is NULL.
SNOWFLAKE_COCOCORTEX CODECORTEX_CODE. ENTITY_ID is NULL.
AI_INFERENCEAI GATEWAYName 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_TOOLSAI GATEWAYName 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_ID set to 0 and USER_NAME empty. A task or a dynamic table runs as the system user unless you set EXECUTE AS USER. To attribute that usage to a user, run the task or dynamic table with EXECUTE AS USER.
  • Rows can report 0 credits.
  • The credits in this view reconcile with the CREDITS_BILLED column of the METERING_DAILY_HISTORY view for the service types that the view covers, except AI_INFERENCE. The AI_INFERENCE service type includes AI Gateway usage only, so its credits are lower than the AI_INFERENCE total in METERING_DAILY_HISTORY.
  • Credit rates are listed in the Snowflake Service Consumption Table.

Examples

Retrieve credits consumed by each user in the last 30 days:

SELECT user_name,
       SUM(credits) AS total_credits
  FROM SNOWFLAKE.ACCOUNT_USAGE.USER_AI_USAGE_HISTORY
  WHERE usage_hour >= DATEADD('day', -30, CURRENT_TIMESTAMP())
    AND user_id > 0
  GROUP BY user_id, user_name
  ORDER BY total_credits DESC;

Retrieve credits consumed by each service type in the last 30 days:

SELECT service_type,
       SUM(credits) AS total_credits
  FROM SNOWFLAKE.ACCOUNT_USAGE.USER_AI_USAGE_HISTORY
  WHERE usage_hour >= DATEADD('day', -30, CURRENT_TIMESTAMP())
  GROUP BY service_type
  ORDER BY total_credits DESC;

Retrieve credits consumed by each Cortex Agent in the last 30 days:

SELECT entity_name,
       SUM(credits) AS total_credits
  FROM SNOWFLAKE.ACCOUNT_USAGE.USER_AI_USAGE_HISTORY
  WHERE service_type = 'CORTEX_AGENTS'
    AND usage_hour >= DATEADD('day', -30, CURRENT_TIMESTAMP())
  GROUP BY entity_id, entity_name
  ORDER BY total_credits DESC;