AI Tools Suite
Face Swap
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.
Image Faceswap
POST https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | Your API Key used for request authorization |
Body Attributes
Parameter | Type | Value | Description |
---|---|---|---|
targetImage | Array | [{path:"",opts:""}] | A collection of faces in the original image(Each array element is an object, and the object contains 2 properties, path:Links to faces detected in the original image.opts: Key information of faces detected in original pictures(You can get it through the face https://sg3.akool.com/detect API,You can get the landmarks_str value returned by the api interface as the value of opts) |
sourceImage | Array | [{path:"",opts:""}] | Replacement target image information.(Each array element is an object, and the object contains 2 properties, path:Links to faces detected in target images.opts: Key information of the face detected in the target image(You can get it through the face https://sg3.akool.com/detect API,You can get the landmarks_str value returned by the api interface as the value of opts) |
face_enhance | Int | 0 or 1 | Whether facial enhancement: 1 means open, 0 means close |
modifyImage | String | Modify the link address of the image | |
webhookUrl | String | Callback url address based on HTTP request |
Response Attributes
Parameter | Type | Value | Description |
---|---|---|---|
code | int | 1000 | Interface returns business status code(1000: success) |
msg | String | Interface returns status information | |
data | Object | {_id:"",url: "",job_id: ""} | _id: Interface returns data url: faceswwap result url job_id: Task processing unique id |
Example
Body
{
"targetImage": [ // A collection of faces in the original image
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png", // Links to faces detected in the original image
"opts": "262,175:363,175:313,215:272,279" // Key information of faces detected in original pictures【You can get it through the face https://sg3.akool.com/detect API,You can get the landmarks_str value returned by the api interface as the value of opts
}
],
"sourceImage": [ // Replacement target image information
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png", // Links to faces detected in target images
"opts": "239,364:386,366:317,472:266,539" // Key information of the face detected in the target image【You can get it through the face https://sg3.akool.com/detect API,You can get the landmarks_str value returned by the api interface as the value of opts
}
],
"face_enhance": 0, // Whether facial enhancement: 1 means open, 0 means close
"modifyImage": "https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg", // Modify the link address of the image
"webhookUrl":"http://localhost:3007/api/webhook" // Callback url address based on HTTP request
}
Request
Response
{
"code": 1000, // Interface returns business status code
"msg": "Please be patient! If your results are not generated in three hours, please check your input image.", // Interface returns status information
"data": {
"_id": "6593c94c0ef703e8c055e3c8", // Interface returns data
"url": "https://***.cloudfront.net/final_71688047459_.pic-1704184129269-4947-f8abc658-fa82-420f-b1b3-c747d7f18e14-8535.jpg", // faceswwap result url
"job_id": "20240102082900592-5653" // Task processing unique id
}
}
Video Faceswap
POST https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | Your API Key used for request authorization |
Body Attributes
Parameter | Type | Value | Description |
---|---|---|---|
sourceImage | Array | [{path:"",opts:""}] | Replacement target image information:sourceImage means that you need to change it to the link collection of the face you need. You need to pass your image through the https://sg3.akool.com/detect interface. Obtain the link and key point data and fill them here, and ensure that they correspond to the order of the targetImage. You need to pay attention to that each picture in the sourceImage must be a single face, otherwise the face change may fail. (Each array element is an object, and the object contains 2 properties, path:Links to faces detected in the original image. opts: Key information of faces detected in original pictures【You can get it through the face https://sg3.akool.com/detect API, You can get the landmarks_str value returned by the api interface as the value of opts) |
targetImage | Array | [{path:"",opts:""}] | A collection of faces in the original video: targetImage represents the collection of faces after face detection using modifyVideo. When the original video has multiple faces, here is the image link and key point data of each face. You need to pass https://sg3.akool.com/detect interface to obtain data.(Each array element is an object, and the object contains 2 properties, path:Links to faces detected in target images. opts: Key information of the face detected in the target image【You can get it through the face https://sg3.akool.com/detect API, You can get the landmarks_str value returned by the api interface as the value of opts) |
face_enhance | Int | 0 or 1 | Whether facial enhancement: 1 means open, 0 means close |
modifyVideo | String | modifyImage represents the original image you need to change the face | |
webhookUrl | String | Callback url address based on HTTP request |
Response Attributes
Parameter | Type | Value | Description |
---|---|---|---|
code | int | 1000 | Interface returns business status code(1000: success) |
msg | String | Interface returns status information | |
data | Object | {_id:"",url: "",job_id: ""} | _id : Interface returns data url: faceswwap result url job_id: Task processing unique id |
Example
Body
{
"sourceImage": [ // Replacement target image information: sourceImage means that you need to change it to the link collection of the face you need. You need to pass your image through the https://sg3.akool.com/detect interface. Obtain the link and key point data and fill them here, and ensure that they correspond to the order of the targetImage. You need to pay attention to that each picture in the sourceImage must be a single face, otherwise the face change may fail.
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png", // Links to faces detected in the original image
"opts": "239,364:386,366:317,472:266,539" // Key information of faces detected in original pictures【You can get it through the face https://sg3.akool.com/detect API,You only need to enter the first 4 items of the content array of the landmarks field of the returned data, and concatenate them into a string through ":", like this: ["434,433","588,449","509,558","432,614", "0,0", "0,0"] to "434,433:588,449:509,558:432,614"】
}
],
"targetImage": [ // A collection of faces in the original video: targetImage represents the collection of faces after face detection using modifyVideo. When the original image has multiple faces, here is the image link and key point data of each face. You need to pass https://sg3.akool.com/detect interface to obtain data
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png", // Links to faces detected in target images
"opts": "176,259:243,259:209,303:183,328" // Key information of the face detected in the target image【You can get it through the face https://sg3.akool.com/detect API,You only need to enter the first 4 items of the content array of the landmarks field of the returned data, and concatenate them into a string through ":", like this: ["1622,759","2149,776","1869,1085","1875,1345", "0,0", "0,0"] to "1622,759:2149,776:1869,1085:1875,1345"】
}
],
"face_enhance":0,
"modifyVideo": "https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4", // modifyImage represents the original image you need to change the face;
"webhookUrl":"http://localhost:3007/api/webhook2" // Callback url address based on HTTP request
}
Request
Response
{
"code": 1000, // Interface returns business status code
"msg": "Please be patient! If your results are not generated in three hours, please check your input image.", // Interface returns status information
"data": {
"_id": "6582bf774e47940151d8fa1e", // db id
"url": "https://***.cloudfront.net/final_1703067481578-7151-1703067481578-7151-470fbfbc-ab77-4868-a7f4-dbba1ec4f1c9-3478.jpg", // faceswwap result url
"job_id": "20231220101831489-3860" // Task processing unique id
}
}
Get Faceswap Result List Byids
GET https://openapi.akool.com/api/open/v3/faceswap/result/listbyids?_ids=64ef2f27b33f466877701c6a
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | Your API Key used for request authorization. You can get from https://openapi.akool.com/api/open/v3/getToken api. |
Query Attributes
Parameter | Type | Value | Description |
---|---|---|---|
_ids | String | result ids are strings separated by commas【You can get it by returning the _id field from https://openapi.akool.com/api/open/v3/faceswap/highquality/imgreage or https://openapi.akool.com/api/open/v3/faceswap/highquality/vidreage api.】 |
Response Attributes
Parameter | Type | Value | Description |
---|---|---|---|
code | int | 1000 | Interface returns business status code(1000: success) |
msg | String | Interface returns status information | |
data | Object | result: [{faceswap_status:"",url: "",createdAt: ""}] | faceswap_status: faceswap result status: 1 In Queue 2 Processing 3 Success 4 failed url: faceswwap result url createdAt: current faceswap action created time |
Example
Request
Response
{
"code": 1000, // error code
"msg": "OK", // api message
"data": {
"result": [
{
"faceswap_type": 1,
"faceswap_quality": 2,
"faceswap_status": 1, // faceswap result status: 1 In Queue 2 Processing 3 Success 4 failed
"deduction_status": 1,
"image": 1,
"video_duration": 0,
"deduction_duration": 0,
"update_time": 0,
"_id": "64dae65af6e250d4fb2bca63",
"userId": "64d985c5571729d3e2999477",
"uid": 378337,
"url": "https://d21ksh0k4smeql.cloudfront.net/final_material__d71fad6e-a464-43a5-9820-6e4347dce228-80554b9d-2387-4b20-9288-e939952c0ab4-0356.jpg", // faceswwap result url
"createdAt": "2023-08-15T02:43:38.536Z" // current faceswap action created time
}
]
}
}
GET Faceswap User Credit Info
GET https://openapi.akool.com/api/open/v3/faceswap/quota/info
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | Your API Key used for request authorization |
Response Attributes
Parameter | Type | Value | Description |
---|---|---|---|
code | int | 1000 | Interface returns business status code(1000: success) |
msg | String | Interface returns status information | |
data | Object | {"credit": 0 } | credit: Account balance |
Example
Request
Response
{
"code": 1000, // Business status code
"msg": "OK", // The interface returns status information
"data": {
"credit": 0 // Account balance
}
}
POST Faceswap Result Del Byids
POST https://openapi.akool.com/api/open/v3/faceswap/result/delbyids
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | Your API Key used for request authorization |
Body Attributes
Parameter | Type | Value | Description |
---|---|---|---|
_ids | String | result ids are strings separated by commas |
Response Attributes
Parameter | Type | Value | Description |
---|---|---|---|
code | int | 1000 | Interface returns business status code(1000:success) |
msg | String | Interface returns status information |
Example
Body
{
"_ids":""//result ids are strings separated by commas
}
Request
Response
{
"code": 1000, // Business status code
"msg": "OK" // The interface returns status information
}
Face Detect
POST https://sg3.akool.com/detect
Request Headers
Parameter | Value | Description |
---|---|---|
Authorization | Bearer token | Your API Key used for request authorization |
Body Attributes
Parameter | Type | Value | Description |
---|---|---|---|
single_face | Boolean | true/false | Is it a single face picture: This should be true when the incoming picture has only one face, and false when the incoming picture has multiple faces. |
image_url | String | image link: You can choose to enter this parameter or the img parameter. | |
img | String | Image base64 information: You can choose to enter this parameter or the image_url parameter. |
Response Attributes
Parameter | Type | Value | Description |
---|---|---|---|
error_code | int | 0 | Interface returns business status code(0:success) |
error_msg | String | error message of this api | |
landmarks | Array | [] | Key point data of face |
Example
Body
{
"single_face": false, // Is it a single face picture: This should be true when the incoming picture has only one face, and false when the incoming picture has multiple faces.
"image_url":"https://d21ksh0k4smeql.cloudfront.net/IMG_6150-1696984459910-0610.jpeg", // image link:You can choose to enter this parameter or the img parameter.
"img": "data:image/jpeg;base64***" // Image base64 information:You can choose to enter this parameter or the image_url parameter.
}
Request
Response
{
"error_code": 0, // error code: 0 is seccuss
"error_msg": "SUCCESS", // error message of this api
"landmarks": [ // Key point data of face
[
[
238,365
],
[
386,363
],
[
318,470
],
[
267,539
],
[
0,0
],
[
0,0
]
]
],
"landmarks_str": [
"238,365:386,363:318,470:267,539"
],
"region": [
[
150,195,317,429
]
],
"seconds": 0.04458212852478027, // API time-consuming
"trx_id": "74178dc5-199a-479a-89d0-4b0e1c161219"
}
Response Code Description
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 |