Before you can make API calls, you need to obtain your API key from the API Management Page.
**POST api/aifaceswap/v1/faceswap**
Body Attributes
| Parameter | Type | Description |
|---|---|---|
source_image |
string or file |
URL or file of the original image to be face-swapped. |
face_image |
string or file |
URL or file of the face image to be used for the swap. |
webhook |
string |
Callback URL address for HTTP requests. |
curl -X POST 'https://aifaceswap.io/api/aifaceswap/v1/faceswap' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"source_image": "https://temp.aifaceswap.io/aifaceswap/static_img/8a1bce5ea303791589165a5f607e7399.webp",
"face_image": "https://temp.aifaceswap.io/aifaceswap/static_img/1f153b1ab8d134f1eff57eb527467137.webp",
"webhook": "https://b245fc85af95.ngrok-free.app/api/aifaceswap/v1/task_callback"
}'
Note: If source_image or face_image is not a URL on the aifaceswap server, please provide the complete URL.
Response Example
{
"code": 200,
"data": {
"points": 2,
"task_id": "ac3eb7ab5852233a3d2076031103b4fe"
},
"extra_data": {},
"message": "OK"
}
**POST api/aifaceswap/v1/extract_face**
For multiple person face swaps, extract all faces from the image.

Body Attributes
| Parameter | Type | Description |
|---|---|---|
img |
string or file |
URL or file of the image. |
curl -X POST 'https://aifaceswap.io/api/aifaceswap/v1/extract_face' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"img": "https://temp.aifaceswap.io/aifaceswap/static_img/1f153b1ab8d134f1eff57eb527467137.webp"
}'
Response Example
{
"code": 200,
"data": {
"faces": [
[146, 256, 240, 381],
[297, 521, 371, 621],
[441, 208, 529, 332]
],
"points": 2
},
"message": "OK"
}
**POST api/aifaceswap/v1/multi_faceswap**
Replace one or more faces in an image containing multiple faces.
Body Attributes
| Parameter | Type | Description |
|---|---|---|
source_image |
string |
URL of the image containing multiple faces. |
face_image |
list |
Array of face images to be swapped. |
index |
list |
Index corresponding to each face image. |
webhook |
string |
Callback URL for HTTP requests. |
curl -X POST 'https://aifaceswap.io/api/aifaceswap/v1/multi_faceswap' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"source_image": "https://art-global.yimeta.ai/aifaceswap/image/face_b07365091f488682662cbebc08721616.webp",
"face_image": ["https://temp.aifaceswap.io/aifaceswap/static_img/8a1bce5ea303791589165a5f607e7399.webp", "https://temp.aifaceswap.io/aifaceswap/static_img/1f153b1ab8d134f1eff57eb527467137.webp"],
"index": [0, 2],
"webhook": "https://698f-221-234-179-244.ngrok-free.app/api/aifaceswap/v1/task_callback"
}'
Response Example
{
"code": 200,
"data": {
"points": 5,
"task_id": "6c3ce398d9e2bdd6abed6d636ec2ac03"
},
"message": "OK"
}
When the results are generated, the aifaceswap server will call the webhook to return the results. Therefore, developers need to define an API endpoint for this purpose.
**POST https:xxxx.xx/api/task_callback**
Body Attributes
| Parameter | Type | Description |
|---|---|---|
success |
int |
1 for success, 0 for failure. |
type |
int |
1 for single person face swap, 2 for multiple person face swap. |
task_id |
string |
The unique ID of the task. |
result_image |
string |
The URL of the result image. |
**POST api/aifaceswap/v1/video_faceswap**
Body Attributes
| Parameter | Type | Description |
|---|---|---|
source_video |
string |
Original video URL |
face_image |
string |
Swapped face image URL |
duration |
float |
Video duration. We will deduct credits according to the duration. |
enhance |
int |
0 - No enhance 1 - resolution <= 1080p, enhance face 2 - resolution <= 2k, enhance face |
webhook |
string |
Callback URL address for HTTP requests. |
curl -X POST 'https://aifaceswap.io/api/aifaceswap/v1/video_faceswap' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"source_video": "https://temp.aifaceswap.io/aifaceswap/image/videoswap-template/3-b800d4689751060d3765a58518c26c1a.mp4",
"face_image": "https://temp.aifaceswap.io/aifaceswap/static_img/1f153b1ab8d134f1eff57eb527467137.webp",
"duration": 5,
"enhance": 0,
"webhook": "https://b245fc85af95.ngrok-free.app/api/aifaceswap/v1/task_callback"
}'
Response Example
{
"code": 200,
"data": {
"points": 10,
"task_id": "30d22e3a163d023a40e3e13327999ce3"
},
"extra_data": {},
"message": "OK"
}
**POST api/aifaceswap/v1/extract_base64_face**
Note: This api is only used for Multi Video Face Swap. Extract face points from a certain frame of the video.
Body Attributes
| Parameter | Type | Description |
|---|---|---|
base64_img |
string |
Video frame image base64 string |
curl -X POST 'https://aifaceswap.io/api/aifaceswap/v1/extract_base64_face' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"base64_img": "data:image/webp;base64,UklGRtDnA..."
}'
Response Example
{
"code": 200,
"data": {
"pos": [
[
568,
332,
655,
476
],
[
1078,
170,
1169,
290
],
]
},
"extra_data": {},
"message": "OK"
}
**POST api/aifaceswap/v1/multi_video_faceswap**
Body Attributes
| Parameter | Type | Description |
|---|---|---|
source_video |
string |
Original video URL |
ref_info |
list |
It is an array of ref_image object |
duration |
float |
Video duration. We will deduct credits according to the duration. |
enhance |
int |
0 - No enhance 1 - resolution <= 1080p, enhance face 2 - resolution <= 2k, enhance face |
webhook |
string |
Callback URL address for HTTP requests. |
Body Attributes of "ref_image"
| Parameter | Type | Description |
|---|---|---|
face_ref |
string |
Image base64, the face reference to be replaced; Intercepted by extracting the points returned by the base64 face image API |
face_url |
string |
Swapped face image URL |
curl -X POST 'https://aifaceswap.io/api/aifaceswap/v1/multi_video_faceswap' \
-H 'Authorization: Bearer your_api_key' \
-H 'Content-Type: application/json' \
-d '{
"source_video": "https://temp.aifaceswap.io/aifaceswap/image/videoswap-template/3-b800d4689751060d3765a58518c26c1a.mp4",
"ref_info": [
{
"face_ref": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAA...",
"face_url": "https://temp.aifaceswap.io/aifaceswap/static_img/1f153b1ab8d134f1eff57eb527467137.webp"
}
],
"duration": 5,
"enhance": 0,
"webhook": "https://14e47e61df64.ngrok-free.app/api/aifaceswap/v1/task_callback"
}'
Note: Multiple video face swapping supports up to 3 faces. So the maximum length of ref_info is no more than 3.
Response Example
{
"code": 200,
"data": {
"points": 20,
"task_id": "59c71eb51b181d56dfbb5e9e3fb6832d"
},
"extra_data": {},
"message": "OK"
}
| enhance | cost | |
|---|---|---|
| Face swap | - | 2 credits |
| Extract faces (for multiple face swap) | - | 2 credits |
| Multiple face swap | - | 5 credits |
| Basic video face swap | No enhance | 2 credits / s |
| 1080p | 4 credits / s | |
| 2k | 6 credits / s | |
| Extract faces from video frame (for multiple video face swap) | - | 2 credits |
| Multiple video face swap | No enhance | (face count + 1) * 2 credits / s |
| 1080p | (face count + 2) * 2 credits / s | |
| 2k | (face count + 3) * 2 credits / s |
| # | Question | Answer |
|---|---|---|
| 1 | Is the API service free to use? | Sorry, currently only available for vip users to use coins. |
| 2 | Does the video face swap API service support uploading videos or pictures? | The video face swap API service does not involve uploading videos, cropping videos, or uploading pictures. The videos or pictures provided by users must be publicly accessible CDN URLs. |
| 3 | Does the API service support video cropping? | Our API service does not provide video cropping. Developers need to use ffmpeg or other libraries for cropping. |