This API has been deprecated and is no longer available.
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
| Parameter | Value | Description |
|---|---|---|
| x-api-key | API Key | Your API Key used for request authorization. If both Authorization and x-api-key have values, Authorization will be used first and x-api-key will be discarded. |
| Authorization | Bearer {token} | Your API Key used for request authorization.Get Token |
| Parameter | isRequired | Type | Value | Description |
|---|---|---|---|---|
| color_code | false | String | eg: #aafbe3 | background color。 Use hexadecimal to represent colors |
| template_url | false | String | resource address of the background image | |
| origin_img | true | String | Foreground image address | |
| modify_template_size | false | String | eg:“3031x3372” | The size of the template image after expansion |
| modify_origin_img_size | true | String | eg: “3031x2894” | The size of the foreground image after scaling |
| overlay_origin_x | true | int | eg: 205 | The position of the upper left corner of the foreground image in the canvas |
| overlay_origin_y | true | int | eg: 497 | The position of the upper left corner of the foreground image in the canvas |
| overlay_template_x | false | int | eg: 10 | The position of the upper left corner of the template image in the canvas |
| overlay_template_y | false | int | eg: 497 | The position of the upper left corner of the template image in the canvas |
| canvas_size | true | String | eg:“3840x3840” | Canvas size |
| webhookUrl | true | String | Callback url address based on HTTP request | |
| removeBg | false | Boolean | true or false default false | Whether 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.
| Parameter | Type | Value | Description |
|---|---|---|---|
| code | int | 1000 | Interface returns business status code(1000:success) |
| msg | String | Interface returns status information | |
| data | Object | { _id: "", image_status: 1 } | _id: Interface returns data, image_status: the status of image: 【1:queueing, 2:processing, 3:completed,4:failed】 |
You have 4 combination parameters to choose from
The first combination of parameters: use template_url
{
"canvas_size": "3840x3840",
"template_url": "https://d3c24lvfmudc1v.cloudfront.net/public/background_change/ROne.png",
"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://d3c24lvfmudc1v.cloudfront.net/public/background_change/ROne.png",
"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
}
curl --location 'https://openapi.akool.com/api/open/v3/content/image/bg/replace' \
--header "x-api-key: {{API Key}}" \
--header 'Content-Type: application/json' \
--data '{
"canvas_size": "3840x3840",
"template_url": "https://d3c24lvfmudc1v.cloudfront.net/public/background_change/ROne.png",
"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
}
'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"canvas_size\": \"3840x3840\",\n \"template_url\": \"https://d3c24lvfmudc1v.cloudfront.net/public/background_change/ROne.png\",\n \"modify_template_size\": \"3830x3830\",\n \"overlay_template_x\": 5,\n \"overlay_template_y\": 5,\n \"origin_img\": \"https://drz0f01yeq1cx.cloudfront.net/1711939252580-7e40bd1a-e480-42ed-8585-3f9ffccf6bdb-5822.png\",\n \"modify_origin_img_size\": \"3830x2145\",\n \"overlay_origin_x\": 5,\n \"overlay_origin_y\": 849,\n}");
Request request = new Request.Builder()
.url("https://contentapi.akool.com/api/v3/content/image/bg/replace")
.method("POST", body)
.addHeader("x-api-key", "{{API Key}}")
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
const myHeaders = new Headers();
myHeaders.append("x-api-key", "{{API Key}}");
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
"canvas_size": "3840x3840",
"template_url": "https://d3c24lvfmudc1v.cloudfront.net/public/background_change/ROne.png",
"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
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://openapi.akool.com/api/open/v3/content/image/bg/replace", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$client = new Client();
$headers = [
'x-api-key' =>'{{API Key}}',
'Content-Type' => 'application/json'
];
$body = '{
"canvas_size": "3840x3840",
"template_url": "https://d3c24lvfmudc1v.cloudfront.net/public/background_change/ROne.png",
"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
}';
$request = new Request('POST', 'https://openapi.akool.com/api/open/v3/content/image/bg/replace', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
import requests
import json
url = "https://openapi.akool.com/api/open/v3/content/image/bg/replace"
payload = json.dumps({
"canvas_size": "3840x3840",
"template_url": "https://d3c24lvfmudc1v.cloudfront.net/public/background_change/ROne.png",
"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
})
headers = {
'x-api-key':'{{API Key}}',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
{
"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
| Parameter | Value | Description |
|---|---|---|
| x-api-key | API Key | Your API Key used for request authorization. If both Authorization and x-api-key have values, Authorization will be used first and x-api-key will be discarded. |
| Authorization | Bearer {token} | Your API Key used for request authorization.Get Token |
| Parameter | Type | Value | Description |
|---|---|---|---|
| image_model_id | String | image db id:You can get it based on the _id field returned by Background Replace API api. |
| Parameter | Type | Value | Description |
|---|---|---|---|
| code | int | 1000 | Interface returns business status code(1000:success) |
| msg | String | Interface returns status information | |
| data | Object | {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 |
curl --location 'https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=660d15b83ec46e810ca642f5' \
--header "x-api-key: {{API Key}}"
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=660d15b83ec46e810ca642f5")
.method("GET", body)
.addHeader("x-api-key", "{{API Key}}")
.build();
Response response = client.newCall(request).execute();
const myHeaders = new Headers();
myHeaders.append("x-api-key", "{{API Key}}");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=660d15b83ec46e810ca642f5", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$client = new Client();
$headers = [
'x-api-key' =>'{{API Key}}'
];
$request = new Request('GET', 'https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=660d15b83ec46e810ca642f5', $headers);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
import requests
url = "https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=660d15b83ec46e810ca642f5"
payload = {}
headers = {
'x-api-key':'{{API Key}}'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
{
"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
}
}
Please note that if the value of the response code is not equal to 1000, the request is failed or wrong
| Parameter | Value | Description |
|---|---|---|
| code | 1000 | Success |
| code | 1003 | Parameter error or Parameter can not be empty |
| code | 1005 | Operation is too frequent |
| code | 1006 | Your quota is not enough |
| code | 1007 | The number of people who can have their faces changed cannot exceed 8 |
| code | 1101 | Invalid authorization or The request token has expired |
| code | 1102 | Authorization cannot be empty |
| code | 1200 | The account has been banned |