Schema:

ACCOUNT_USAGE

SNOWFLAKE_COCO_USAGE_HISTORY view

The SNOWFLAKE_COCO_USAGE_HISTORY view can be used to query the usage history of CoCo across all interfaces: CLI, Desktop, and Snowsight.

The information in the view includes the number of credits consumed each time a user interacts with CoCo. Each row in the view represents a single request and provides detail about the aggregated tokens and credits as well as a granular breakdown by model. The view also includes relevant metadata, such as the user ID, request ID, and the interface that originated the request.

Note

Interface-specific usage history is also available in the following views:

Tip

In Cortex Code, including the CLI, Desktop, and Snowsight interfaces, you can use the cost-intelligence bundled skill to answer questions about the usage data in this view. Invoke the skill with /cost-intelligence, or describe your question in plain language and Cortex Code selects the skill automatically.

Columns

Column nameData typeDescription
USER_IDNUMBERThe unique identifier of the user who made the request.
USER_NAMEVARCHARThe login name of the user who made the request.
USER_TAGSARRAY

Tags associated with the user. Each object in the array contains the following value pairs:

  • level: The level at which the tag is applied (for example, “ACCOUNT” or “USER”).
  • tag_database: The database where the tag is defined.
  • tag_schema: The schema where the tag is defined.
  • tag_name: The name of the tag.
  • tag_value: The value of the tag.
REQUEST_IDVARCHARThe unique identifier for the request.
PARENT_REQUEST_IDVARCHARThe identifier of the parent request, if applicable.
USAGE_TIMETIMESTAMP_TZThe timestamp when the usage was recorded.
INTERFACEVARCHAR

The CoCo interface that originated the request. Possible values are:

TOKEN_CREDITSNUMBERThe number of token credits used for the request.
TOKENSNUMBERThe total number of tokens used for the request.
TOKENS_GRANULAROBJECT

Granular breakdown of token usage by model. Each key is a model name, and each value is an object containing the following fields:

  • input: Number of input tokens.
  • cache_read_input: Number of cache read input tokens.
  • cache_write_input: Number of cache write input tokens.
  • output: Number of output tokens.
CREDITS_GRANULAROBJECT

Granular breakdown of credit usage by model. Each key is a model name, and each value is an object containing the following fields:

  • input: Credit value for input tokens.
  • cache_read_input: Credit value for cache read input tokens.
  • cache_write_input: Credit value for cache write input tokens.
  • output: Credit value for output tokens.
METADATAOBJECT

Additional metadata, including:

  • role_id: ID of the primary role used for the request.
  • role_name: Name of the primary role used for the request.
  • inference_region: The cross-region inference routing used for the request. Possible values are global (any Snowflake-supported region across any cloud provider) or regional (requests restricted to specific geographic boundaries). Contains NULL if the record predates the introduction of this field.

Usage notes

  • Latency for the view may be up to 1 hour.
  • The view provides up-to-date credit usage for an account within the last 365 days (1 year).
  • Credit rate usage is based on the number of tokens processed, as outlined in the Snowflake Service Consumption Table.
  • The USER_TAGS column returns an empty array for usage records that predate the introduction of user tag support.

Examples

Retrieve CoCo usage history across all interfaces:

SELECT *
  FROM SNOWFLAKE.ACCOUNT_USAGE.SNOWFLAKE_COCO_USAGE_HISTORY;

Retrieve total credits consumed per interface in the last 30 days:

SELECT INTERFACE,
       SUM(TOKEN_CREDITS) AS TOTAL_CREDITS
  FROM SNOWFLAKE.ACCOUNT_USAGE.SNOWFLAKE_COCO_USAGE_HISTORY
  WHERE USAGE_TIME >= DATEADD('day', -30, CURRENT_TIMESTAMP())
  GROUP BY INTERFACE
  ORDER BY TOTAL_CREDITS DESC;

Retrieve total credits consumed per user in the last 30 days:

SELECT USER_ID,
       USER_NAME,
       SUM(TOKEN_CREDITS) AS TOTAL_CREDITS
  FROM SNOWFLAKE.ACCOUNT_USAGE.SNOWFLAKE_COCO_USAGE_HISTORY
  WHERE USAGE_TIME >= DATEADD('day', -30, CURRENT_TIMESTAMP())
  GROUP BY USER_ID, USER_NAME
  ORDER BY TOTAL_CREDITS DESC;