Image workflow
Submit, then poll by task ID
- 1Set the key
export FACESWAPAI_API_KEY="YOUR_API_KEY" - 2Run the example
node examples/node/image-swap.mjs source.jpg target.jpg - 3Handle the terminal status
Read the temporary result URL only after
COMPLETED; surface the public error onFAILED.
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.