Schema:

ORGANIZATION_USAGE

AI_GATEWAY_USAGE_HISTORY view

Important

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

The AI_GATEWAY_USAGE_HISTORY view in the ORGANIZATION_USAGE schema can be used to query the usage history of Cortex AI Gateway across all the accounts in your organization.

Each row in the view represents a single request sent through a 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 organization-wide showback, adoption reporting, and identifying which accounts, 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.

See also:

AI_GATEWAY_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
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

  • 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 gateway usage history across the organization:

SELECT *
  FROM SNOWFLAKE.ORGANIZATION_USAGE.AI_GATEWAY_USAGE_HISTORY;

Retrieve total credits consumed per account:

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