Use cases of Face Swap API

Face Swap API can be used to generate convincing videos or images by swapping faces or altering visual elements. This technology can be applied in various fields, such as entertainment, advertising, education, and security.

icon
Education

In language learning apps, face swapping technology can be utilized to provide educational applications. By swapping faces with a native speaker of a language they are trying to learn, users can practice speaking in real time.

icon
E-commerce

E-commerce platforms can integrate face swapping technology to provide virtual try-on experiences. Customers can view how different products, such as glasses or makeup, look on their faces before making a purchase.

icon
Entertainment

The technology of face swapping can create entertaining content for social media platforms or entertainment applications. Users can swap their faces with their favorite celebrity, resulting in engaging and fun content to share with their friends.

How to Make a Deepfake Video or Image with Face Swap API

Use Face Swap API to batch face detect and replace

Images Face Swap
Step 1
Analyze an Asset Image

Kick things off by analyzing your
base image. You'll need to use th
e POST method at the following endpoint:

https://api.heygen.com/v1/image/analyze

In the request body, input the 'asset_id', which represents the image you want to analyze.This API call returns a mapping of face IDs to face thumbnails in the image.

Step 2
Upload the Replacement Face

Next, upload the face you want to swap
in. For this, you need to use the POST
method at this endpoint:

https://upload.heygen.com/v1/face

In the request body, specify the local file path of the image you want to upload. The responsewill give you a unique 'face_id' and the 'face_url' of the uploaded face.

Step 3
Execute the Image Face Swap

Once the faces are ready, it's time to do
the actual face swapping. Make a POST call to:

https://api.heygen.com/v1/image/
faceswap

Here, in the request body, you input the 'asset_id' of your initial image and the'faceswap_mapping', which is a JSON mapping from the face in the image to the newly uploadedface. This call will give you a new 'asset_id' and 'output_url' of the image with theswapped face.

Videos Face Swap
Step 1
Analyze an Asset Video

Just like with images, start by analyzing the video asset with the POST method at:

https://api.heygen.com/v1/video/analyze

Include the 'asset_id' of the video in the request body. This request will return an'asset_id' for the video currently in analysis.

Step 2
Check Video Analysis

Keep track of your video analysis with a GET call to:

https://api.heygen.com/v1/video/analyze.check

Again, you need the 'asset_id' of
the video in the request body. The response will provide
you the status of the analysis and
a mapping from the face ID to the
face thumbnail.

Step 3
Execute the Video Face Swap

Once the analysis is complete, proceed to face swapping. Use the POST method at:

https://api.heygen.com/v1/video/faceswap

In the request body, input the 'asset_id'of the video and 'faceswap_mapping' (a JSON)mapping from the face in the video to the new uploaded face). You receive an 'asset_id' for the video currently undergoing the face swap.

Step 4
Check the Video Face Swap

Lastly, keep an eye on the face swap status. Use a GET call to:

https://api.heygen.com/v1/video/faceswap.check

Include the 'asset_ id' of the video in the request body. The response will return the statusof the face swap and the URL of the video with the swapped face.And there you have it! A simple, step-by-step guide to using the HeyGen Face Swap API.Enjoy creating fun, engaging content by swapping faces on images and videos. Get creativeand share your masterpieces with the world!

Customer Reviews

What do HeyGen users think?