Error Handling

Learn how to interpret API errors and build robust handling logic.

Error response structure

{
  "status": "error",
  "code": "invalid_request",
  "message": "Missing required field: prompt",
  "details": {
    "field": "prompt"
  }
}

Common error codes

  • 400invalid_request: invalid payload or missing fields
  • 401unauthorized: invalid or missing API key
  • 403forbidden: insufficient permissions or blocked access
  • 429rate_limit_exceeded: request volume exceeded
  • 500server_error: unexpected system failure

Handling retries

Retry only idempotent requests and use a delay that increases with each attempt. Do not retry on client-side validation errors.

Logging and troubleshooting

Log the error code, message, request payload, and timestamps to make support requests easier to resolve.