Schema:

ACCOUNT_USAGE

AI_GATEWAY_USAGE_HISTORY view

The AI_GATEWAY_USAGE_HISTORY view can be used to query the usage history of Cortex AI Gateway.

Each row in the view represents a single request sent through the gateway, and includes the user who made it, the service that handled it, details of the operation, and the resulting credit consumption. Use this view for showback, adoption reporting, and identifying which users and models drive spend.

Note

Requests sent directly to Cortex Inference rather than through a gateway are recorded in CORTEX_REST_API_USAGE_HISTORY instead.

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
REQUEST_IDTEXTUnique identifier for the request. Each HTTP request gets a unique ID.
GATEWAY_NAMETEXTThe gateway that served the request. A gateway name can change over time.
GATEWAY_IDTEXTThe identifier of the gateway that served the request. This is static over time.
USER_IDTEXTThe internal identifier of the authenticated user.
SERVICE_TYPETEXTThe service that handled the request. Inference requests are recorded as AI_INFERENCE.
OPERATION_DETAILSOBJECTDetails of the operation, keyed by model. For inference, each model maps to its token counts, as in {"claude-sonnet-5": {"input_tokens": 27, "output_tokens": 7427}}.
CREDITSNUMBERTotal credits consumed for the request.
CREDITS_GRANULAROBJECTCredits consumed for the request, keyed by model, as in {"claude-sonnet-5": 0.037162}.
METADATAOBJECTAdditional metadata about the request.

Usage notes

  • The view provides credit usage for an account within the last 365 days (1 year).
  • Credit rate usage is as outlined in the Snowflake Service Consumption Table.
  • This view reports credits. It isn’t intended for near-real-time activity monitoring, and it can’t be reconciled request-for-request against activity data.

Examples

Retrieve all gateway usage history:

SELECT *
  FROM SNOWFLAKE.ACCOUNT_USAGE.AI_GATEWAY_USAGE_HISTORY;

Retrieve total credits consumed per user:

SELECT USER_ID,
       SUM(CREDITS) AS TOTAL_CREDITS
  FROM SNOWFLAKE.ACCOUNT_USAGE.AI_GATEWAY_USAGE_HISTORY
  GROUP BY USER_ID
  ORDER BY TOTAL_CREDITS DESC;

Inspect the per-request operation details and credit breakdown, which are objects whose contents depend on the service that handled the request:

SELECT REQUEST_ID,
       SERVICE_TYPE,
       OPERATION_DETAILS,
       CREDITS_GRANULAR,
       CREDITS
  FROM SNOWFLAKE.ACCOUNT_USAGE.AI_GATEWAY_USAGE_HISTORY
  ORDER BY CREDITS DESC
  LIMIT 100;