Errors

The API uses standard HTTP status codes and returns consistent error responses. All errors follow the same response format.

Error Response Format

{
  "success": false,
  "error": "Description of what went wrong",
  "code": "ERROR_CODE"
}

Error Codes

HTTP StatusCodeDescription
400BAD_REQUESTThe request body is invalid or missing required fields.
401UNAUTHORIZEDMissing or invalid API key.
403FORBIDDENThe API key does not have permission for this resource.
403QUOTA_EXCEEDEDMonthly request quota has been exceeded. Upgrade your plan or wait for the next billing period.
404NOT_FOUNDThe requested resource does not exist.
429RATE_LIMITEDToo many requests. Wait for the rate limit window to reset.
500INTERNAL_ERRORAn unexpected server error occurred. Contact support if this persists.

Handling Errors

Always check the successfield in the response. If it's false, read the error message and code field to determine how to handle it.

const response = await fetch("/api/v1/example", {
  method: "POST",
  headers: {
    "x-api-key": apiKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ input: "test" }),
});

const data = await response.json();

if (!data.success) {
  switch (data.code) {
    case "RATE_LIMITED":
      // Wait and retry
      break;
    case "QUOTA_EXCEEDED":
      // Upgrade plan
      break;
    case "UNAUTHORIZED":
      // Check API key
      break;
    default:
      console.error(data.error);
  }
}

Rate Limit Errors

When you exceed the rate limit, you'll receive a 429 response. Check the X-RateLimit-Reset header for when you can retry.