Skip to main content
GET
/
usage
List AI Gateway usage events
curl --request GET \
  --url https://api.ngrok.ai/usage \
  --header 'Authorization: Bearer <token>'
{
  "aiGatewayUsage": [
    {
      "id": "<string>",
      "eventTime": "2023-11-07T05:31:56Z",
      "requestId": "<string>",
      "accessKeyId": "<string>",
      "provider": "<string>",
      "providerDisplayName": "<string>",
      "model": "<string>",
      "modelDisplayName": "<string>",
      "attemptNumber": 123,
      "isFinalAttempt": true,
      "statusCode": 123,
      "timedOut": true,
      "isError": true,
      "isStreaming": true,
      "stopReason": "<string>",
      "inputTokens": 123,
      "outputTokens": 123,
      "cacheReadTokens": 123,
      "reasoningTokens": 123,
      "totalCost": "<string>",
      "keySource": "<string>",
      "providerKeyId": "<string>",
      "providerKeyDisplayName": "<string>"
    }
  ],
  "uri": "<string>",
  "nextPageUri": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

startTime
string<date-time>
required

Only return events with eventTime >= this RFC3339 timestamp.

endTime
string<date-time>

Only return events with eventTime <= this RFC3339 timestamp. Defaults to now.

accessKeyId
string

Filter results to a single AI Gateway access key.

includeRetries
boolean
default:false

When true, include retry attempts in addition to the request-level terminal attempt. Defaults to false.

cursor
string

Cursor from a previous response's nextPageUri. Pass to fetch the next page.

limit
integer<int32>

Maximum number of items to return. Defaults to 100 and may not exceed 100.

Required range: 1 <= x <= 100

Response

A page of AI Gateway usage events.

aiGatewayUsage
object[]
required

A page of AI Gateway usage events, ordered newest first.

uri
string
required

URI of this list resource.

nextPageUri
string | null

URI of the next page of results, or null if there is no next page.