Errors and troubleshooting

Unsuccessful responses generally use a common error object. Retain the HTTP status, error.type, error.message, and the X-Request-Id response header.

Error response shape

JSON
{
  "error": {
    "message": "model is required",
    "type": "invalid_request_error"
  }
}

Common status codes

StatusMeaningSuggested action
400Invalid request shape or parametersCheck JSON or multipart formatting, required fields, and capabilities of the selected model.
401Missing, invalid, or expired API keyCheck the authentication header, key value, and expiry; do not quote the Bearer value.
403API key restrictions rejected the requestCheck the model allowlist, IP allowlist, and other key restrictions.
404Model or asynchronous task unavailableUse a model ID returned by /v1/models and confirm the task belongs to the current account.
429Rate limit or insufficient quotaReduce request frequency and check key limits, account quota, and wallet state before retrying with backoff.
500Internal platform failureRetain X-Request-Id, retry later, and locate the request in the console records.
502Upstream Provider request failedCheck model route availability and retry a limited number of times with backoff.
503Service or model route temporarily unavailableRetry later; if persistent, select another available model or inspect Provider status.

Request ID

The gateway returns a request ID in the X-Request-Id response header. Retain it when reporting an issue and use the signed-in console usage or request records to locate the call.

Streaming requests

An error after a stream starts may arrive as an SSE event instead of a new HTTP error response. Handle non-2xx responses, in-stream error events, connection timeouts, and interrupted streams. Idle connections may receive comment heartbeats.

Troubleshooting order

  1. Confirm the Base URL ends in /v1 and the endpoint does not repeat /v1.
  2. Use /v1/models to verify both the API key and model ID.
  3. Start with a minimal non-streaming request, then add optional fields one at a time.
  4. Inspect the HTTP status, error.type, error.message, and X-Request-Id.
  5. Check quota, key restrictions, and request records in the console.