Schema:

ORGANIZATION_USAGE

SNOWFLAKE_COCO_USAGE_HISTORY view

Important

This view is only available in the organization account. For more information, see Premium views in the organization account.

The SNOWFLAKE_COCO_USAGE_HISTORY view in the ORGANIZATION_USAGE schema can be used to query the usage history of CoCo across all interfaces (CLI, Desktop, and Snowsight) and across all accounts in your organization.

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:

See also:

SNOWFLAKE_COCO_USAGE_HISTORY view (Account Usage)

Columns

Organization-level columns

Column NameData TypeDescription
ORGANIZATION_NAMEVARCHARName of the organization.
ACCOUNT_LOCATORVARCHARSystem-generated identifier for the account.
ACCOUNT_NAMEVARCHARUser-defined identifier for the account.

Additional 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 24 hours.
  • 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 and accounts in the organization:

SELECT *
  FROM SNOWFLAKE.ORGANIZATION_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.ORGANIZATION_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 account in the last 30 days:

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