Async API Reference

Async image edit contract

Async endpoint returns a response without waiting for an actual result. The actual result should be queried with another request. So you can request image editing and separately get the result after it's ready.

Request image processing

The request body for async endpoint is the same as for regular image edit operation. See Image edit contract for more info.

Request

POST /v1-beta1/image/edit/async HTTP/1.1
Host: api.claid.ai
Authorization: Bearer {YOUR_API_KEY}
Content-Type: application/json

{
  "input": "https://picsum.photos/200.jpg",
  "operations": {
    "resizing": {
      "width": 1000
    },
    "background": {
      "remove": false
    }
  }
}

Read a response

Once you have made the request to https://api.claid.ai/v1-beta1/image/edit/async you will get a response with information about request status and some other details (listed below).

Request information shown in the response:

Response body

{
  "data": {
    "id": 1,
    "status": "ACCEPTED",
    "result_url": "https://api.claid.ai/v1-beta1/image/edit/async/1",
    "created_at": "2023-03-13T11:37:09.160554+00:00",
    "request": {
      "input": "https://picsum.photos/200.jpg",
      "operations": {
        "resizing": {
            "width": 1000
        },
        "background": {
            "remove": false
        }
      }
    }
  }
}

See the Request Headers and Response Headers to learn about headers.

Result of request processing contract

To get image editing result, you need to know the ID of the processing request. Or you can take a ready-to-use link from the result_url property of the response body described above.

Request

GET /v1-beta1/image/edit/async/1 HTTP/1.1
Host: api.claid.ai
Authorization: Bearer {YOUR_API_KEY}

Read a response

Once you have made the request to https://api.claid.ai/v1-beta1/image/edit/async/<task_id> you will get a response with information about the request, input and output images.

Image information shown in the response:

Read a input_object and output_object properties of response result property:

Read an item from errors property:

Response body

{
  "data": {
    "id": 1,
    "status": "DONE",
    "created_at": "2023-03-13T11:37:09.160554+00:00",
    "request": {
      "input": "https://picsum.photos/200.jpg",
      "operations": {
        "resizing": {
            "width": 1000
        },
        "background": {
            "remove": false
        }
      }
    },
    "errors": [],
    "result": {
      "input_object": {
        "ext": "pnj",
        "mps": 0.016384,
        "mime": "image/jpeg",
        "format": "JPEG",
        "width": 128,
        "height": 128
      },
      "output_object": {
        "ext": "jpeg",
        "mps": 1.0,
        "mime": "image/jpeg",
        "format": "JPEG",
        "width": 1000,
        "height": 1000,
        "tmp_url": "https://storage.googleapis.com/production-leapi-tmp-public/000/200.jpeg"
      }
    }
  }
}

See Response headers to learn about headers.

Last updated