Image Upload

Learn how to upload images to use in various tasks, including image-to-image generation, background removal, upscaling, and more.

Introduction

Images can be uploaded to be used in other tasks like Image-to-Image, Upscaling or ControlNet preprocessing.

There are 3 things to keep in mind:

  • Valid extensions are: jpeg, jpg, png, webp, bmp and gif.
  • There is no limit on image size but we save them with a maximum of 2048 pixels in width or height, maintaining the original aspect ratio.
  • Images are deleted 30 days after last use. As long as you continue using them, we will continue saving them indefinitely.

Request

Our API always accepts an array of objects as input, where each object represents a specific task to be performed. The structure of the object varies depending on the type of the task. For this section, we will focus on the parameters related to the image upload task.

The following JSON snippet shows the basic structure of a request object. All properties are explained in detail in the next section.

[
  {
    "taskType": "imageUpload",
    "taskUUID": "50836053-a0ee-4cf5-b9d6-ae7c5d140ada",
    "image": "data:image/png;base64,iVBORw0KGgo..."
  }
]

taskType

stringrequired

The type of task to be performed. For this task, the value should be imageUpload.

taskUUID

stringrequiredUUID v4

When a task is sent to the API you must include a random UUID v4 string using the taskUUID parameter. This string is used to match the async responses to their corresponding tasks.

If you send multiple tasks at the same time, the taskUUID will help you match the responses to the correct tasks.

The taskUUID must be unique for each task you send to the API.

image

stringrequired

Specifies the image to be uploaded. The image can be specified in one of the following formats:

  • A data URI string representing the image. The data URI must be in the format data:<mediaType>;base64, followed by the base64-encoded image. For example: data:image/png;base64,iVBORw0KGgo....
  • A base64 encoded image without the data URI prefix. For example: iVBORw0KGgo....
  • A URL pointing to the image. The image must be accessible publicly.

Supported formats are: PNG, JPG and WEBP.

Response

Results will be delivered in the format below.

{
  "data": {
    "taskType": "imageUpload",
    "taskUUID": "9ed8a593-5515-46f3-9cd7-81ab0508176c",
    "imageUUID": "989ba605-1449-4e1e-b462-cd83ec9c1a67"
  }
}

taskUUID

stringUUID v4

The API will return the taskUUID you sent in the request. This way you can match the responses to the correct request tasks.

imageUUID

stringUUID v4

The unique identifier of the image.