1. Read the attempt count off the response
Every response through ngrok.ai includes theNgrok-AIG-Attempts header, which shows how many attempts were made. A value greater than 1 means the first attempt failed and the gateway tried again.
Use the
Ngrok-AIG-Model response header to identify the model that handled your request. The AI Gateway passes the provider’s response body through unchanged, including its model field. If the gateway switches models after a failed attempt, these values may differ. Use the header as the source of truth.2. Look the request up by ID
Pass theNgrok-AIG-Request-Id value to the attempts endpoint:
3. Check why the AI Gateway retried or stopped
For each attempt, checkcompletion to see how it ended and retryAction to see what the AI Gateway decided to do next. Use served to identify the attempt that returned the response to your client.
Identify the attempt that returned the response
Look forserved: true. At most one attempt per request has this value.
Do not assume the last attempt returned a response. A request can end with a failed attempt that did not produce a response for your client.
Check how each attempt ended
Thecompletion field has one of these values:
succeededfailedtimed_outstream_failedunknown
retryAction to understand why the gateway retried or stopped.
Follow the retry decisions
retryAction is optional. It is absent from attempts recorded before the gateway began storing retry decisions.
In the example above, next_key on attempt 1 means the gateway tried another key for the same provider. next_backend on attempt 2 means it then moved to the next model in the failover list. Check each attempt’s error details to see why it failed.
What this tells you to change
What this endpoint does not include
This endpoint does not include captured request and response bodies, which could contain sensitive information.Next steps
Handle gateway errors
How failover decides what to try next
Debug failed requests
Diagnose a failure from the response alone