Skip to main content
POST
/
api
/
open
/
v3
/
faceswap
/
highquality
/
specifyvideo
Video Faceswap
curl --request POST \
  --url https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "sourceImage": [
    {
      "path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png",
      "opts": "239,364:386,366:317,472:266,539"
    }
  ],
  "targetImage": [
    {
      "path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png",
      "opts": "176,259:243,259:209,303:183,328"
    }
  ],
  "face_enhance": 0,
  "modifyVideo": "https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4",
  "webhookUrl": ""
}
'
import requests

url = "https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo"

payload = {
"sourceImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png",
"opts": "239,364:386,366:317,472:266,539"
}
],
"targetImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png",
"opts": "176,259:243,259:209,303:183,328"
}
],
"face_enhance": 0,
"modifyVideo": "https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4",
"webhookUrl": ""
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sourceImage: [
{
path: 'https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png',
opts: '239,364:386,366:317,472:266,539'
}
],
targetImage: [
{
path: 'https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png',
opts: '176,259:243,259:209,303:183,328'
}
],
face_enhance: 0,
modifyVideo: 'https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4',
webhookUrl: ''
})
};

fetch('https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sourceImage' => [
[
'path' => 'https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png',
'opts' => '239,364:386,366:317,472:266,539'
]
],
'targetImage' => [
[
'path' => 'https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png',
'opts' => '176,259:243,259:209,303:183,328'
]
],
'face_enhance' => 0,
'modifyVideo' => 'https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4',
'webhookUrl' => ''
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo"

payload := strings.NewReader("{\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png\",\n \"opts\": \"176,259:243,259:209,303:183,328\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyVideo\": \"https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4\",\n \"webhookUrl\": \"\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png\",\n \"opts\": \"176,259:243,259:209,303:183,328\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyVideo\": \"https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4\",\n \"webhookUrl\": \"\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyvideo")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705475757658-3362-0-1705475757797-3713.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705479323786-0321-0-1705479323896-7695.png\",\n \"opts\": \"176,259:243,259:209,303:183,328\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyVideo\": \"https://d21ksh0k4smeql.cloudfront.net/avatar_01-1705479314627-0092.mp4\",\n \"webhookUrl\": \"\"\n}"

response = http.request(request)
puts response.read_body
{
  "code": 1000,
  "msg": "OK",
  "data": {
    "_id": "<string>",
    "url": "<string>",
    "job_id": "<string>"
  }
}
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.

Important Notes

  • sourceImage: You need to change it to the link collection of the face you need. Pass your image through the Face Detect API to obtain the link and key point data
  • 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
  • When using Face Detect API, set single_face: true to return only the largest face data, or false to return all detected faces
  • Ensure that each picture in the sourceImage is a single face, otherwise the face change may fail
  • You need to ensure that sourceImage and targetImage correspond to each other in order

Authorizations

x-api-key
string
header
required

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.

Body

application/json
sourceImage
object[]
required

Replacement target image information. You need to change it to the link collection of the face you need.

targetImage
object[]
required

A collection of faces in the original video. Represents the collection of faces after face detection using modifyVideo.

modifyVideo
string
required

The original video you need to change the face

face_enhance
enum<integer>
default:0

Whether facial enhancement (1 means open, 0 means close)

Available options:
0,
1
webhookUrl
string

Callback url address based on HTTP request

Response

200 - application/json

Video faceswap request submitted successfully

code
integer
required

Interface returns business status code (1000: success)

Example:

1000

msg
string
required

Interface returns status information

Example:

"OK"

data
object