Logo

Error Handling

Understand how the Fit It On API reports errors, including API-level failures and asynchronous runtime errors.

Understanding how the API reports errors helps you respond quickly and keep your integration resilient. The Fit It On API categorizes errors into two distinct phases:

  1. API-level errors: The request was rejected immediately before a prediction ID was issued.
  2. Runtime errors: The request was accepted and a prediction ID was returned, but the generation failed during asynchronous processing.

API-Level Errors

API-level errors occur synchronously. When you make a POST request to /v1/run, or a GET request to /v1/status/{id}, the server validates the request before beginning any intensive background work.

If validation fails, the API returns an HTTP error status (e.g., 400, 401), and the JSON response contains an error message and a specific string code.

{
  "error": "Invalid request payload. Expected { model_name, inputs }",
  "code": "BadRequest"
}

Standard Error Codes

CodeErrorCauseHow to fix
400BadRequestInvalid request format or unsupported model nameCheck the JSON structure, ensure model_name is correct, and verify all required inputs are provided.
401UnauthorizedAccessInvalid or missing API keyVerify the Authorization: Bearer YOUR_API_KEY header is correct and the key is active.
402OutOfCreditsNo developer API credits remainingRefill your credits in the Fit It On dashboard before retrying.
403ForbiddenUnauthorized access to predictionYou are attempting to check the status of a prediction created by a different developer key.
404NotFoundPrediction not foundConfirm the prediction ID is correct when polling the status endpoint.
413PayloadTooLargePayload exceeds limitsEnsure input images are under 25MB and use reasonable resolutions.
500InternalServerErrorServer-side errorRetry with backoff. Contact support if the issue persists.

[!TIP] Retries and idempotency If you encounter an API-level error, you can safely retry the exact same payload once the issue is resolved. Because the request was rejected immediately, no credits were deducted and duplicate processing is not a risk.


Runtime Errors

Runtime errors occur after the API has successfully accepted your request and returned a prediction ID.

Because generation models are heavily asynchronous, you will discover these errors while polling the /v1/status/{id} endpoint. If a background job fails, the endpoint returns an HTTP 200 OK (because the polling request itself was successful), but the status field inside the payload will be "failed".

The response will include the prediction ID and an error object detailing what went wrong, including a categorized name and a descriptive message.

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "status": "failed",
  "output": null,
  "error": {
    "name": "ImageLoadError",
    "message": "Failed to load input image: URL returned 404"
  },
  "created_at": "2024-05-15T12:00:00Z",
  "updated_at": "2024-05-15T12:00:10Z"
}

Common Runtime Errors

Most runtime issues fall into a handful of shared categories across our models:

CategoryTypical Error MessagesHow to fix
Image Load ErrorFailed to fetch image, Invalid image URLEnsure provided URLs are publicly accessible without authentication. For Base64, ensure it includes the correct MIME-type prefix.
Input ValidationImage resolution too small, Missing required parameterEnsure your input assets meet the minimum dimensions and requirements for the specific model.
Content ModerationNSFW content detected, Safety block triggeredReplace or adjust the input image or text prompt to comply with safety filters.
Pipeline ErrorGeneration failed, Server errorAn unexpected failure occurred in the GPU cluster. Retry the request with backoff.

[!NOTE] Credit Refunds on Failure Failed predictions do not consume credits. If a generation fails during runtime (e.g., due to an Image Load Error or a Pipeline Error), the credits deducted at the start of the request are automatically refunded back to your developer balance.

Endpoint-Specific Errors

Certain models have strict, workflow-specific validation rules that run during generation:

  • Pose Control: Will fail if no human body is detected in the target image.
  • Virtual Try-On: Will fail if it cannot detect a valid garment in the garment image.
  • Model Generation: Will fail if the provided face reference image does not contain a clear, unobstructed face.

If you continue to see runtime failures after aligning inputs with the documentation, please contact support with your prediction ID so we can investigate.