The resources (image, video, voice) generated by our API are valid for 7 days. Please save the relevant resources as soon as possible to prevent expiration.

Background Change

POST https://openapi.akool.com/api/open/v3/content/image/bg/replace

Request Headers

ParameterValueDescription
AuthorizationBearer tokenYour API Key used for request authorization

Body Attributes

ParameterisRequiredTypeValueDescription
color_codefalseStringeg: #aafbe3background color。 Use hexadecimal to represent colors
template_urlfalseStringresource address of the background image
origin_imgtrueStringForeground image address
modify_template_sizefalseStringeg:“3031x3372”The size of the template image after expansion
modify_origin_img_sizetrueStringeg: “3031x2894”The size of the foreground image after scaling
overlay_origin_xtrueinteg: 205The position of the upper left corner of the foreground image in the canvas
overlay_origin_ytrueinteg: 497The position of the upper left corner of the foreground image in the canvas
overlay_template_xfalseinteg: 10The position of the upper left corner of the template image in the canvas
overlay_template_yfalseinteg: 497The position of the upper left corner of the template image in the canvas
canvas_sizetrueStringeg:“3840x3840”Canvas size
webhookUrltrueStringCallback url address based on HTTP request
removeBgfalseBooleantrue or false default falseWhether to remove the background image
In addition to using the required parameters,you can also use one or both of the color_code or template_url parameters(but this is not required). Once you use template_url, you can carry three additional parameters: modify_template_size, overlay_template_x, and overlay_template_y.

Response Attributes

ParameterTypeValueDescription
codeint1000Interface returns business status code(1000:success)
msgStringInterface returns status information
dataObject{ _id: "", image_status: 1 }_id: Interface returns data, image_status: the status of image: 【1:queueing, 2:processing, 3:completed,4:failed】

Example

Body

You have 4 combination parameters to choose from
The first combination of parameters: use template_url

{
    "canvas_size": "3840x3840",
    "template_url": "https://s3-alpha-sig.figma.com/img/dd86/048d/a2f66b5440ca0097162432cc5d420f31?Expires=1712534400&Key-Pair-Id=APKAQ4GOSFWCVNEHN3O4&Signature=YfFEN1MK9UZvh5CX8ne6OOPWLW4mMYU7x8jm7CyCtD5XyEmz-nsuzuLE2TdfYNXtt6vF3TLmyRbECkpAKzEnnpR8LMNgT7w2v-qn~QwnJAjAhmBhBwZ95eUEQ1IPxpX~8Gp8U3aUOYHla3mwWEULlSpFgcei6HffDZh2oIC6prKzH8rWB4JuUcpUvKw7Lq~kUfeEZ8Em-l3DvgQYzrKIuAAvoPKiYOeqIcmUs9Ba1d9wAFbjJXxHqo9xxJENMLtXIOqjGbcZLV9DWpk-fZnQAhC-ikrqoEpU~zA64aqcGYE0pv~LmV7LrCrugBcujQFBvdZqgdoV8po4HBH1Io~TkQ__",
    "modify_template_size": "3830x3830",
    "overlay_template_x": 5,
    "overlay_template_y": 5,
    "origin_img": "https://drz0f01yeq1cx.cloudfront.net/1711939252580-7e40bd1a-e480-42ed-8585-3f9ffccf6bdb-5822.png",
    "modify_origin_img_size": "3830x2145",
    "overlay_origin_x": 5,
    "overlay_origin_y": 849
}
The second combination of parameters:use color_code
{
    "color_code": "#c9aafb",
    "canvas_size": "3840x3840",
    "origin_img": "https://drz0f01yeq1cx.cloudfront.net/1712132369637-69a946c0-b2a7-4fe6-92c8-2729b36cc13e-0183.png",
    "modify_origin_img_size": "3060x3824",
    "overlay_origin_x": 388,
    "overlay_origin_y": 8
}
The third combination of parameters: use template_url and color_code
{
    "color_code": "#aafbe3",
    "canvas_size": "3840x3840",
    "template_url": "https://s3-alpha-sig.figma.com/img/dd86/048d/a2f66b5440ca0097162432cc5d420f31?Expires=1712534400&Key-Pair-Id=APKAQ4GOSFWCVNEHN3O4&Signature=YfFEN1MK9UZvh5CX8ne6OOPWLW4mMYU7x8jm7CyCtD5XyEmz-nsuzuLE2TdfYNXtt6vF3TLmyRbECkpAKzEnnpR8LMNgT7w2v-qn~QwnJAjAhmBhBwZ95eUEQ1IPxpX~8Gp8U3aUOYHla3mwWEULlSpFgcei6HffDZh2oIC6prKzH8rWB4JuUcpUvKw7Lq~kUfeEZ8Em-l3DvgQYzrKIuAAvoPKiYOeqIcmUs9Ba1d9wAFbjJXxHqo9xxJENMLtXIOqjGbcZLV9DWpk-fZnQAhC-ikrqoEpU~zA64aqcGYE0pv~LmV7LrCrugBcujQFBvdZqgdoV8po4HBH1Io~TkQ__",
    "modify_template_size": "3828x3828",
    "overlay_template_x": 2049,
    "overlay_template_y": -6,
    "origin_img": "https://drz0f01yeq1cx.cloudfront.net/1712132369637-69a946c0-b2a7-4fe6-92c8-2729b36cc13e-0183.png",
    "modify_origin_img_size": "3062x3828",
    "overlay_origin_x": -72,
    "overlay_origin_y": -84
}
The fourth combination of parameters:
{
    "canvas_size": "3840x3840",
    "origin_img": "https://drz0f01yeq1cx.cloudfront.net/1712132369637-69a946c0-b2a7-4fe6-92c8-2729b36cc13e-0183.png",
    "modify_origin_img_size": "3060x3824",
    "overlay_origin_x": 388,
    "overlay_origin_y": 8
}

Request

Response

{
    "code": 1000,
    "msg": "OK",
    "data": {
        "create_time": 1712133151184,
        "uid": 1432101,
        "type": 3,
        "faceswap_quality": 2,
        "image_id": "c7ed5294-6783-481e-af77-61a850cd19c7",
        "image_sub_status": 1,
        "image_status": 1,   // the status of image: 【1:queueing, 2:processing,3:completed, 4:failed】
        "deduction_credit": 4,
        "buttons": [],
        "used_buttons": [],
        "upscaled_urls": [],
        "error_reasons": [],
        "_id": "660d15b83ec46e810ca642f5",
        "__v": 0
    }
}

Get Image Result image info

GET https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=660d15b83ec46e810ca642f5

Request Headers

ParameterValueDescription
AuthorizationBearer tokenYour API Key used for request authorization

Query Attributes

ParameterTypeValueDescription
image_model_idStringimage db id:You can get it based on the _id field returned by https://openapi.akool.com/api/open/v3/content/image/bg/replace api.

Response Attributes

ParameterTypeValueDescription
codeint1000Interface returns business status code(1000:success)
msgStringInterface returns status information
dataObject{image_status:1,_id:"",image:""}image_status: the status of image: 【1:queueing, 2:processing, 3:completed, 4:failed】 image: Image result after processing _id: Interface returns data

Example

Request

Response

{
    "code": 1000,
    "msg": "OK",
    "data": {
        "_id": "660d15b83ec46e810ca642f5",
                "create_time": 1712133560525,
                "uid": 1486241,
                "type": 3,
                "faceswap_quality": 2,
                "image_id": "e23018b5-b7a9-4981-a2ff-b20559f9b2cd",
                "image_sub_status": 3,
                "image_status": 3,  // the status of image:【1:queueing, 2:processing,3:completed,4:failed】
                "deduction_credit": 4,
                "buttons": [],
                "used_buttons": [],
                "upscaled_urls": [],
                "error_reasons": [],
                "__v": 0,
                "external_img": "https://drz0f01yeq1cx.cloudfront.net/1712133563402-result.png",
                "image": "https://drz0f01yeq1cx.cloudfront.net/1712133564746-d4a80a20-9612-4f59-958b-db9dec09b320-9409.png"  // Image result after processing  
    }
}

Response Code Description

Please note that if the value of the response code is not equal to 1000, the request is failed or wrong
ParameterValueDescription
code1000Success
code1003Parameter error or Parameter can not be empty
code1005Operation is too frequent
code1006Your quota is not enough
code1007The number of people who can have their faces changed cannot exceed 8
code1101Invalid authorization or The request token has expired
code1102Authorization cannot be empty
code1200The account has been banned