Image Faceswap
curl --request POST \
--url https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"targetImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png",
"opts": "262,175:363,175:313,215:272,279"
}
],
"sourceImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png",
"opts": "239,364:386,366:317,472:266,539"
}
],
"face_enhance": 0,
"modifyImage": "https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg",
"webhookUrl": ""
}
'import requests
url = "https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage"
payload = {
"targetImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png",
"opts": "262,175:363,175:313,215:272,279"
}
],
"sourceImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png",
"opts": "239,364:386,366:317,472:266,539"
}
],
"face_enhance": 0,
"modifyImage": "https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg",
"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({
targetImage: [
{
path: 'https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png',
opts: '262,175:363,175:313,215:272,279'
}
],
sourceImage: [
{
path: 'https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png',
opts: '239,364:386,366:317,472:266,539'
}
],
face_enhance: 0,
modifyImage: 'https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg',
webhookUrl: ''
})
};
fetch('https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage', 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/specifyimage",
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([
'targetImage' => [
[
'path' => 'https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png',
'opts' => '262,175:363,175:313,215:272,279'
]
],
'sourceImage' => [
[
'path' => 'https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png',
'opts' => '239,364:386,366:317,472:266,539'
]
],
'face_enhance' => 0,
'modifyImage' => 'https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg',
'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/specifyimage"
payload := strings.NewReader("{\n \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png\",\n \"opts\": \"262,175:363,175:313,215:272,279\"\n }\n ],\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyImage\": \"https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg\",\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/specifyimage")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png\",\n \"opts\": \"262,175:363,175:313,215:272,279\"\n }\n ],\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyImage\": \"https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg\",\n \"webhookUrl\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage")
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 \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png\",\n \"opts\": \"262,175:363,175:313,215:272,279\"\n }\n ],\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyImage\": \"https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg\",\n \"webhookUrl\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"code": 1000,
"msg": "Please be patient! If your results are not generated in three hours, please check your input image.",
"data": {
"_id": "6593c94c0ef703e8c055e3c8",
"url": "https://***.cloudfront.net/final_71688047459_.pic-1704184129269-4947-f8abc658-fa82-420f-b1b3-c747d7f18e14-8535.jpg",
"job_id": "20240102082900592-5653"
}
}API Endpoints
Image Faceswap
Swap faces in images with high quality
POST
/
api
/
open
/
v3
/
faceswap
/
highquality
/
specifyimage
Image Faceswap
curl --request POST \
--url https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"targetImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png",
"opts": "262,175:363,175:313,215:272,279"
}
],
"sourceImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png",
"opts": "239,364:386,366:317,472:266,539"
}
],
"face_enhance": 0,
"modifyImage": "https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg",
"webhookUrl": ""
}
'import requests
url = "https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage"
payload = {
"targetImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png",
"opts": "262,175:363,175:313,215:272,279"
}
],
"sourceImage": [
{
"path": "https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png",
"opts": "239,364:386,366:317,472:266,539"
}
],
"face_enhance": 0,
"modifyImage": "https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg",
"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({
targetImage: [
{
path: 'https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png',
opts: '262,175:363,175:313,215:272,279'
}
],
sourceImage: [
{
path: 'https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png',
opts: '239,364:386,366:317,472:266,539'
}
],
face_enhance: 0,
modifyImage: 'https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg',
webhookUrl: ''
})
};
fetch('https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage', 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/specifyimage",
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([
'targetImage' => [
[
'path' => 'https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png',
'opts' => '262,175:363,175:313,215:272,279'
]
],
'sourceImage' => [
[
'path' => 'https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png',
'opts' => '239,364:386,366:317,472:266,539'
]
],
'face_enhance' => 0,
'modifyImage' => 'https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg',
'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/specifyimage"
payload := strings.NewReader("{\n \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png\",\n \"opts\": \"262,175:363,175:313,215:272,279\"\n }\n ],\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyImage\": \"https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg\",\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/specifyimage")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png\",\n \"opts\": \"262,175:363,175:313,215:272,279\"\n }\n ],\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyImage\": \"https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg\",\n \"webhookUrl\": \"\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://openapi.akool.com/api/open/v3/faceswap/highquality/specifyimage")
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 \"targetImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1694593694387-4562-0-1694593694575-0526.png\",\n \"opts\": \"262,175:363,175:313,215:272,279\"\n }\n ],\n \"sourceImage\": [\n {\n \"path\": \"https://d21ksh0k4smeql.cloudfront.net/crop_1705462509874-9254-0-1705462510015-9261.png\",\n \"opts\": \"239,364:386,366:317,472:266,539\"\n }\n ],\n \"face_enhance\": 0,\n \"modifyImage\": \"https://d21ksh0k4smeql.cloudfront.net/bdd1c994c4cd7a58926088ae8a479168-1705462506461-1966.jpeg\",\n \"webhookUrl\": \"\"\n}"
response = http.request(request)
puts response.read_body{
"code": 1000,
"msg": "Please be patient! If your results are not generated in three hours, please check your input image.",
"data": {
"_id": "6593c94c0ef703e8c055e3c8",
"url": "https://***.cloudfront.net/final_71688047459_.pic-1704184129269-4947-f8abc658-fa82-420f-b1b3-c747d7f18e14-8535.jpg",
"job_id": "20240102082900592-5653"
}
}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.
Experience our face swap technology in action by exploring our interactive demo on GitHub: AKool Face Swap Demo.
Important Notes
- You can get the
optsparameter (landmarks_str) through the Face Detect API - The Face Detect API returns a
landmarks_strvalue that should be used as the value ofopts - When using Face Detect API, set
single_face: trueto return only the largest face data, orfalseto return all detected faces - Ensure that the targetImage and sourceImage arrays are properly aligned and correspond to each other
- Model Selection: To use different face swap models available on the official website, set
face_enhance: 0for Classic Model, andface_enhance: 1for HD Optimized model. For Clarity Boost and Identity Keeper models, please contact our sales and technical support team
Authorizations
ApiKeyAuthBearerAuth
Body
application/json