Errors

Error categories and handling guidance for OptimAI Search API consumers.

Handle errors by category, not only by message text. The server may include a machine-readable code, details, and request ID; preserve those fields for support and retry decisions.

Error envelope

{
  "error": {
    "code": "invalid_request",
    "message": "The request body is invalid.",
    "details": {}
  },
  "request_id": "req_123"
}

The exact server code strings can evolve. Prefer the HTTP status, returned message, and top-level request ID instead of hard-coding an undocumented code enum.

StatusMeaningAction
400Invalid request shapeFix the payload.
401Missing or invalid keyCheck authentication.
402Payment or credit requiredAsk the user to add credits or payment.
404Operation not found or not accessibleCheck the operation ID and API key.
429Rate limitedBack off and retry later.
500Server-side errorPreserve the request ID and retry only when safe.
502/503/other 5xxTemporary service issueRetry with backoff if safe.

Preserve context

Log the status code, endpoint, and top-level request_id when available. Keep the request ID with the error message when opening a support ticket.