Usage
Query usage events and aggregated overview via the AI Gateway API
Debugging
Troubleshoot failed requests and error codes
Error Codes
Reference for gateway error responses
Identify a request
Every gateway response carriesNgrok-AIG-Request-Id, plus headers such as Ngrok-AIG-Attempts, Ngrok-AIG-Model, Ngrok-AIG-Rejected-Models, and Ngrok-AIG-Removed-Params that describe how the request was served.
Record the request ID in your application logs so you can tie a client-side failure to gateway usage data later.
See Response headers.
Usage API
Query usage with the AI Gateway API:startTime is required. Group by provider (the default) or accessKey.
List individual usage events to see one record per upstream attempt.
Each event reports the provider, model, status code, token counts, and a per-attempt cost breakdown.
Attempts of the same client request share a requestId.
By default the list returns only each request’s terminal attempt.
Pass includeRetries=true to see the retries the gateway made along the way.
When a provider reports no usage of its own,
usageEstimated is true and the provider-reported token fields are all zero.
Read inputTokensEstimate and outputTokensEstimate on those attempts instead.Look up one request
To see every attempt the gateway made for one request, pass itsNgrok-AIG-Request-Id to GET /usage/requests/{requestId}. See Why a request failed over.