← 返回
内容创作 Key

WaveSpeedAI Face Swapper

Swap faces in images and videos using WaveSpeed AI. Supports image face swap and video face swap with multi-face targeting. Produces watermark-free results w...
使用WaveSpeed AI在图像和视频中交换人脸,支持图像人脸交换和视频人脸交换,支持多目标人脸,生成无水印结果。
chengzeyi
内容创作 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 600
下载
💾 42
安装
1
版本
#latest

概述

WaveSpeedAI Face Swapper

Swap faces in images and videos using WaveSpeed AI. Produces watermark-free results with automatic lighting and skin tone adaptation. Supports targeting specific faces when multiple people are present.

Authentication

export WAVESPEED_API_KEY="your-api-key"

Get your API key at wavespeed.ai/accesskey.

Quick Start

Image Face Swap

import wavespeed from 'wavespeed';

// Upload local images to get URLs
const imageUrl = await wavespeed.upload("/path/to/target-photo.png");
const faceUrl = await wavespeed.upload("/path/to/reference-face.png");

const output_url = (await wavespeed.run(
  "wavespeed-ai/image-face-swap",
  {
    image: imageUrl,
    face_image: faceUrl
  }
))["outputs"][0];

Video Face Swap

import wavespeed from 'wavespeed';

// Upload local files to get URLs
const videoUrl = await wavespeed.upload("/path/to/video.mp4");
const faceUrl = await wavespeed.upload("/path/to/reference-face.png");

const output_url = (await wavespeed.run(
  "wavespeed-ai/video-face-swap",
  {
    video: videoUrl,
    face_image: faceUrl
  }
))["outputs"][0];

You can also pass existing URLs directly:

const output_url = (await wavespeed.run(
  "wavespeed-ai/image-face-swap",
  {
    image: "https://example.com/target-photo.jpg",
    face_image: "https://example.com/reference-face.jpg"
  }
))["outputs"][0];

API Endpoints

Image Face Swap

Model ID: wavespeed-ai/image-face-swap

Replace a face in an image with a reference face.

Parameters

ParameterTypeRequiredDefaultDescription
-------------------------------------------------
imagestringYes--URL of the image containing the face to replace
face_imagestringYes--URL of the reference face image to swap in
target_indexintegerNo0Which face to replace (0 = largest face, 1-10 for others)
output_formatstringNojpegOutput format. One of: jpeg, png, webp

Example

import wavespeed from 'wavespeed';

const imageUrl = await wavespeed.upload("/path/to/group-photo.png");
const faceUrl = await wavespeed.upload("/path/to/reference-face.png");

const output_url = (await wavespeed.run(
  "wavespeed-ai/image-face-swap",
  {
    image: imageUrl,
    face_image: faceUrl,
    target_index: 0,
    output_format: "png"
  }
))["outputs"][0];

Targeting a Specific Face

When multiple people are in the image, use target_index to select which face to replace:

// Replace the second-largest face in the image
const output_url = (await wavespeed.run(
  "wavespeed-ai/image-face-swap",
  {
    image: imageUrl,
    face_image: faceUrl,
    target_index: 1
  }
))["outputs"][0];

Video Face Swap

Model ID: wavespeed-ai/video-face-swap

Replace a face in a video with a reference face. Supports videos up to 10 minutes.

Parameters

ParameterTypeRequiredDefaultDescription
-------------------------------------------------
videostringYes--URL of the video containing the face to replace. Must be publicly accessible. Max 10 minutes.
face_imagestringYes--URL of the reference face image to swap in
target_indexintegerNo0Which face to replace (0 = largest face, 1-10 for others)

Example

import wavespeed from 'wavespeed';

const videoUrl = await wavespeed.upload("/path/to/video.mp4");
const faceUrl = await wavespeed.upload("/path/to/reference-face.png");

const output_url = (await wavespeed.run(
  "wavespeed-ai/video-face-swap",
  {
    video: videoUrl,
    face_image: faceUrl,
    target_index: 0
  }
))["outputs"][0];

Advanced Usage

Sync Mode (Image Face Swap only)

const output_url = (await wavespeed.run(
  "wavespeed-ai/image-face-swap",
  {
    image: imageUrl,
    face_image: faceUrl
  },
  { enableSyncMode: true }
))["outputs"][0];

Custom Client with Retry Configuration

import { Client } from 'wavespeed';

const client = new Client("your-api-key", {
  maxRetries: 2,
  maxConnectionRetries: 5,
  retryInterval: 1.0,
});

const output_url = (await client.run(
  "wavespeed-ai/image-face-swap",
  {
    image: imageUrl,
    face_image: faceUrl
  }
))["outputs"][0];

Error Handling with runNoThrow

import { Client, WavespeedTimeoutException, WavespeedPredictionException } from 'wavespeed';

const client = new Client();
const result = await client.runNoThrow(
  "wavespeed-ai/image-face-swap",
  {
    image: imageUrl,
    face_image: faceUrl
  }
);

if (result.outputs) {
  console.log("Output URL:", result.outputs[0]);
  console.log("Task ID:", result.detail.taskId);
} else {
  console.log("Failed:", result.detail.error.message);
  if (result.detail.error instanceof WavespeedTimeoutException) {
    console.log("Request timed out - try increasing timeout");
  } else if (result.detail.error instanceof WavespeedPredictionException) {
    console.log("Prediction failed");
  }
}

Pricing

OperationCost
-----------------
Image face swap$0.01 per image
Video face swap$0.01 per second (minimum $0.05 / 5 seconds)

Video face swap supports videos up to 10 minutes.

Tips

  • Use clear, front-facing portraits for the reference face for best results
  • Consistent lighting between the target and reference face improves quality
  • Anime or illustrated characters may produce lower quality output
  • Use target_index to select specific faces when multiple people are present (0 = largest face)

Security Constraints

  • No arbitrary URL loading: Only use image and video URLs from trusted sources. Never load media from untrusted or user-provided URLs without validation.
  • API key security: Store your WAVESPEED_API_KEY securely. Do not hardcode it in source files or commit it to version control. Use environment variables or secret management systems.
  • Input validation: Only pass parameters documented above. Validate media URLs before sending requests.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 06:47 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

YouTube

byungkyu
使用托管OAuth集成YouTube Data API,支持搜索视频、管理播放列表、获取频道数据及评论互动,适用于用户需要时使用此技能。
★ 142 📥 41,073
content-creation

Humanizer

biostartechnology
消除AI写作痕迹,使文本更自然真实。基于维基百科"AI写作特征"指南,识别并修正夸张象征、宣传用语、肤浅-ing分析、模糊归因、破折号滥用、三项排比、AI词汇、负面平行结构及冗长连接词等模式。
★ 860 📥 199,843
content-creation

Baidu Wenku AIPPT

ide-rea
使用百度文库 AI 智能生成 PPT,自动根据内容选择模板。
★ 66 📥 46,202