CORTEX_ CODE_ DESKTOP_ USAGE_ HISTORY view¶
The CORTEX_CODE_DESKTOP_USAGE_HISTORY view can be used to query the usage history of Cortex Code Desktop.
The information in the view includes the number of credits consumed each time a user interacts with Cortex Code Desktop. 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, user name, user tags, and request ID.
Note
This view does not include requests originating from Cortex Code CLI or Cortex Code in Snowsight. Requests originating from Cortex Code CLI are recorded in the CORTEX_CODE_CLI_USAGE_HISTORY view. Requests originating from Cortex Code in Snowsight are recorded in the CORTEX_CODE_SNOWSIGHT_USAGE_HISTORY view.
Columns¶
| Column Name | Data Type | Description |
|---|---|---|
| USER_ID | NUMBER | The unique identifier of the user who made the request. |
| USER_NAME | VARCHAR | The login name of the user who made the request. |
| USER_TAGS | ARRAY | Tags associated with the user. Each object in the array contains: level (the level at which the tag is applied), tag_database, tag_schema, tag_name, and tag_value. |
| REQUEST_ID | VARCHAR | The unique identifier for the request. |
| PARENT_REQUEST_ID | VARCHAR | The identifier of the parent request, if applicable. |
| USAGE_TIME | TIMESTAMP_TZ | The timestamp when the usage was recorded. |
| TOKEN_CREDITS | NUMBER | The total number of credits consumed for the request. |
| TOKENS | NUMBER | The total number of tokens used for the request. |
| TOKENS_GRANULAR | OBJECT | Granular breakdown of token usage by model. Each key is a model name, and each value is an object containing: input, cache_read_input, cache_write_input, and output. |
| CREDITS_GRANULAR | OBJECT | Granular breakdown of credit usage by model. Each key is a model name, and each value is an object containing: input, cache_read_input, cache_write_input, and output. |
Usage notes¶
- 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_TAGScolumn returns an empty array for usage records that predate the introduction of user tag support.
Examples¶
Retrieve Cortex Code Desktop usage history:
Retrieve total credits consumed per user in the last 30 days:
Retrieve usage by model for a specific user in the last 7 days:
Filter usage by a specific user tag: