- Schema:
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 Name | Data Type | Description |
|---|---|---|
| ORGANIZATION_NAME | VARCHAR | Name of the organization. |
| ACCOUNT_LOCATOR | VARCHAR | System-generated identifier for the account. |
| ACCOUNT_NAME | VARCHAR | User-defined identifier for the account. |
Additional columns
| Column name | Data type | Description |
|---|---|---|
| REQUEST_ID | TEXT | Unique identifier for the request. Each HTTP request gets a unique ID. |
| GATEWAY_NAME | TEXT | The gateway that served the request. A gateway name can change over time. |
| GATEWAY_ID | TEXT | The identifier of the gateway that served the request. This is static over time. |
| USER_ID | TEXT | The internal identifier of the authenticated user. |
| SERVICE_TYPE | TEXT | The service that handled the request. Inference requests are recorded as AI_INFERENCE. |
| OPERATION_DETAILS | OBJECT | Details 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}}. |
| CREDITS | NUMBER | Total credits consumed for the request. |
| CREDITS_GRANULAR | OBJECT | Credits consumed for the request, keyed by model, as in {"claude-sonnet-5": 0.037162}. |
| METADATA | OBJECT | Additional 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:
Retrieve total credits consumed per account: