1const axios = require('axios');
3const fs = require('fs');
4const path = require('path');
6async function toB64(imgPath) {
7    const data = fs.readFileSync(path.resolve(imgPath));
8    return Buffer.from(data).toString('base64');
11const api_key = "YOUR API-KEY";
12const url = "";
14const data = {
15  "input_face_image": "toB64('')",
16  "target_face_image": "toB64('')",
17  "file_type": "gif",
18  "face_restore": true
21(async function() {
22    try {
23        const response = await, data, { headers: { 'x-api-key': api_key } });
24        console.log(;
25    } catch (error) {
26        console.error('Error:',;
27    }
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing


input_face_imageimage *

Your face goes here. A closeup shot would be ideal.

target_face_imageimage *

The face you want to swap with. Can be a gif too.

file_typestr ( default: png )

File type of the face you want to swap with.

face_restorebool ( default: true )

Run result frames through codeformer face restoration

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

GIF Faceswap

GIF Faceswap is an innovative application aimed at making the process of character animation and customization as seamless as possible. With this model, you no longer need a dataset or extensive training to bring your creations to life. By taking a GIF and a single image of the face you wish to incorporate, GIF Faceswap transforms your static image into a dynamic character, effectively "swapping" the face within the GIF. This unique application enables artists, designers, and creatives to animate a custom character or utilize the character as a model for clothing designs, amongst other potential uses. It is based on roop project by Somdev Sangwan.

The underlying technology behind GIF Faceswap is InsightFace, a versatile 2D and 3D face analysis project. InsightFace is a highly optimized framework that implements a myriad of state-of-the-art algorithms for face recognition, detection, and alignment. It serves as the backbone of GIF Faceswap, providing the necessary capabilities to identify and manipulate facial structures within a GIF and the input image. This makes the process of faceswapping extremely efficient and accurate, as the model leverages these algorithms to seamlessly integrate your desired face into the GIF.

GIF Faceswap offers numerous advantages that make it an excellent tool for a wide range of applications. Its primary advantage is its ability to replace a face in a GIF using just a single image, eliminating the need for a dataset or extensive training. This makes the model highly accessible and easy to use, even for those without extensive technical knowledge. Moreover, GIF Faceswap can significantly speed up the process of character animation and customization, making it an invaluable tool for artists, animators, and fashion designers. Its high accuracy and efficiency, made possible by the use of InsightFace, also ensure high-quality results.

GIF Faceswap use cases

  1. Character Animation: Artists can use GIF Faceswap to animate custom characters for use in digital media, such as games and animations.

  2. Fashion Design: Designers can use the model to swap the faces of models in GIFs, allowing them to showcase their clothing designs on various characters.

  3. Custom Emoji Creation: Individuals can create personalized emoji by swapping their face into existing GIFs.

  4. Marketing and Advertising: Businesses can use GIF Faceswap to create unique advertisements featuring their brand mascot or spokesperson in various scenarios.

  5. Educational Purposes: Educators can use GIF Faceswap to create engaging visual aids, such as historical figures in reenacted scenes.

GIF Faceswap license

GIF Faceswap (roop ) is covered under the GNU General Public License v3.0, a strong copyleft license. Under this license, users are allowed to copy, modify, and distribute the software. However, they are required to make the complete source code of the licensed works and any modifications available under the same license. This means that if you make changes to the software and distribute it, you must also distribute the modified source code under the GNU General Public License. All copyright and license notices must be preserved, and contributors provide an express grant of patent rights.