Action result variables
After theai-gateway action runs, detailed results are available in ${actions.ngrok.ai_gateway}. This includes:
- Which models were considered as candidates
- Every attempt made to providers
- Token counts (estimated and actual)
- Error details for failed attempts
Schema
Overall outcome of the action:
"success" or "error".List of all provider/model combinations considered before attempting requests.Each candidate contains:
provider- Provider ID (for example,"openai","anthropic")model- Model ID (for example,"gpt-4o","claude-3-5-sonnet-20241022")
List of all request attempts made. Each attempt contains:
status- Attempt outcome:"success"or"error"status_code- HTTP status code from provider (0 if no response)error- Error message if the attempt failedprovider_id- Provider namemodel_id- Model nameapi_key_hash- Non-reversible hash of the API key usedinput_tokens_estimated- An estimate generated before the request is sentinput_tokens_actual- Actual tokens from provider responseoutput_tokens_estimated- Estimated output tokensoutput_tokens_actual- Actual output tokens from responsetokenizer_encoding- Encoding used (for example,"cl100k_base")body_on_error- Response body for failed attempts (truncated to 1KB)req- Request details (method, URL, headers, body)
Error code if the action failed (for example,
"ERR_NGROK_3807").Error message if the action failed.
Accessing action results
To access action results, configureon_error: "continue" so subsequent actions can inspect the data:
Cloud Endpoints require a terminal action such as
deny, custom-response, redirect, or forward-internal to complete the request. See Cloud Endpoints for more details.Debugging patterns
Return results as response (development)
During development, return the full action result to the client for inspection:Send to log exports (production)
In production, send action results to your logging infrastructure:Combined approach
Log the results and return a user-friendly error:Interpreting results
Identifying rate limits
Look forstatus_code: 429 in attempts:
api_key_selection.
Identifying model mismatches
Whencandidates is empty and you get ERR_NGROK_3804:
Identifying timeout issues
Look for attempts without astatus_code or with timeout errors:
per_request_timeout or investigate provider latency.