Node.js 18+ · no runtime package install

FaceSwapAI Node.js API client

The reference client uses built-in fetch, FormData and Blob. It validates local files, applies request timeouts, preserves parsed API errors and unwraps the multiple-face response envelope.

Image workflow

Submit, then poll by task ID

  1. 1
    Set the keyexport FACESWAPAI_API_KEY="YOUR_API_KEY"
  2. 2
    Run the examplenode examples/node/image-swap.mjs source.jpg target.jpg
  3. 3
    Handle the terminal status

    Read the temporary result URL only after COMPLETED; surface the public error on FAILED.

Node.jsView source
import { FaceSwapAIClient } from './src/node/client.mjs';

const client = new FaceSwapAIClient({
  apiKey: process.env.FACESWAPAI_API_KEY,
});

const accepted = await client.submitImage({
  sourceImage: './source.jpg',
  targetImage: './target.jpg',
});

const task = await client.waitForTask('image', accepted.taskId);
console.log(task.result?.url);

Client surface

Methods mapped to production routes

submitImage()
Source and target image.
submitVideo()
Source image and target video.
submitGif()
Source image and target GIF.
submitMultiple()
Group image, replacement faces and optional detector boxes.
waitForTask()
Bounded polling with configurable interval and timeout.
listTasks()
Authenticated task history with filters.