Skip to main content

Error response format

All error responses follow this structure:

Error codes

400 — Bad Request

The request body is malformed or missing required fields. Common causes:
  • Missing model, task_type, or input in the request body
  • Unknown or unsupported task_type
  • Invalid input parameters for the selected task type

401 — Unauthorized

The API key is missing, invalid, or has been revoked. Common causes:
  • No x-api-key header in the request
  • API key does not exist or has been deleted
  • API key has been disabled

402 — Payment Required

Your account does not have enough available credits to cover the task cost. How to fix: Top up credits in your dashboard.

404 — Not Found

The requested resource does not exist. Common causes:
  • Invalid task ID
  • Task belongs to a different user

429 — Too Many Requests

You have exceeded the rate limit. How to fix: Wait for the duration in retry_after_seconds (or the Retry-After header) before retrying.

500 — Internal Server Error

An unexpected error occurred on the server. What to do: Retry the request after a short delay. If the error persists, contact support.

502 — Bad Gateway

The upstream AI provider returned an error or is temporarily unavailable. What to do: Retry the request after a short delay. Credits are automatically refunded for failed tasks.

Handling errors

Always check the HTTP status code of the response before parsing the body. For 5xx errors, implement exponential backoff with a maximum of 3 retries.

Example error handling