- Schema:
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 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¶
- 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:
Retrieve total credits consumed per user:
Inspect the per-request operation details and credit breakdown, which are objects whose contents depend on the service that handled the request: