Example error response
Fields you will always get
generation_id: a stable request ID you can share with support.status_code: mirrors the HTTP status code.error: a machine-readable error code, such asvalidation_error.error_type: a high-level class, usuallyuserorsystem.error_origin: whether the problem was mainly caused by the caller, AI Stats, or an upstream provider.description: a plain-language explanation of what happened.details(optional): structured validation details when the error is a request-validation problem.
Extra fields you may see
Some errors include more detail to help you fix the issue faster:reason: a more specific subreason such asall_candidates_failedorpricing_not_configured.provider_candidate_diagnosticsandprovider_enablement: explain why a model could not be used with the requested endpoint.routing_diagnostics: extra detail about how routing or availability checks narrowed the request.provider_failure_diagnostics: hints for missing credentials, missing access, region restrictions, rate limits, and similar provider-side failures.upstream_errorandfailure_sample: best-effort summaries of the first provider failure when the request reached a provider.failed_providers,failed_statuses, andattempt_count: extra retry and failover context.
Status class guidance
| Status | Meaning | Recommended action |
|---|---|---|
400-499 | Request, auth, or permission problem | Fix the request or credentials before retrying. |
429 | Provider or route-level throttling | Retry with backoff and respect Retry-After. |
500-599 | AI Stats or upstream provider failure | Retry with jittered backoff and log the request ID. |
Common error codes
| Type | HTTP Status | Description |
|---|---|---|
authentication_error | 401 | Missing or invalid API key. |
authorization_error | 403 | The key does not have access to this resource. |
not_found_error | 404 | The endpoint or resource could not be found. |
rate_limit_error | 429 | Too many requests. Retry after the specified delay. |
validation_error | 400 | Invalid parameters or request body. |
provider_error | 502 | The upstream model provider failed to respond correctly. |
server_error | 500 | An unexpected issue happened inside AI Stats. |
When a provider fails
If AI Stats reached a provider but the request still failed, you may see:provider_failure_diagnostics.categoryprovider_failure_diagnostics.hintprovider_failure_diagnostics.provider
credentials_not_configuredcredentials_invalid_or_forbiddenprovider_access_missingregion_or_project_restrictionmodel_unavailable_for_endpointrate_limitedserver_error
When a model or endpoint is not available
Forunsupported_model_or_endpoint responses, AI Stats may include:
provider_candidate_diagnosticsprovider_enablementmissing_pricing_providersrouting_diagnostics
- a known model that is not active yet
- a model that does not support the endpoint you asked for
- missing pricing data
- rollout or internal availability restrictions
provider_candidate_diagnostics.totalProviders: how many providers were known for the model before endpoint filtering.provider_candidate_diagnostics.supportsEndpointCount: how many of those providers support the requested endpoint.provider_candidate_diagnostics.candidateCount: how many providers remained after adapter checks.provider_candidate_diagnostics.droppedUnsupportedEndpoint: providers dropped because they do not support the endpoint.provider_candidate_diagnostics.droppedMissingAdapter: provider/endpoint pairs dropped because there is no gateway adapter for that endpoint yet.provider_enablement.capability: the capability gate being enforced, such asvideo_generation.provider_enablement.providersBefore/provider_enablement.providersAfter: providers before and after capability or enablement filtering.provider_enablement.dropped[].reason: machine-readable reasons such aspricing_missing.routing_diagnostics.filterStages[].stage: the routing stage, for example capability, rollout, or routing-status filtering.routing_diagnostics.filterStages[].beforeCount/routing_diagnostics.filterStages[].afterCount: provider counts before and after each stage.routing_diagnostics.filterStages[].droppedProviders[].reason: machine-readable reasons such as rollout or routing restrictions.
Example
Optional debug mode
Most request schemas support adebug object for controlled troubleshooting:
enabledreturn_upstream_requestreturn_upstream_responsetracetrace_level(summaryorfull)
Retry strategy
- 400-series errors: Fix your request before retrying.
- 429: Implement exponential backoff and honor the
Retry-Afterheader. - 500-series errors: Retry safely after a short delay.
Streaming-specific notes
- If the request fails before streaming begins, you get a standard JSON error payload.
- If it fails mid-stream, treat the partial stream as incomplete and show a retry option.
- Always capture
generation_idand endpoint/model metadata in logs.
Troubleshooting tips
- Check the Gateway status page for ongoing incidents.
- Review your request payload against the endpoint docs.
- Share
generation_idwhen contacting support.
Related resources
Authentication
Authenticate with bearer API keys.
Limits
Handle provider-driven throttling and retries.
Streaming
Use SSE safely in production flows.