换脸

namifusion/faceswap-v5

NamiFusion Faceswap v5 is a high-speed, cost-effective model designed for large-scale, real-time workflows, delivering lifelike results with automatic skin tone matching and professional quality.

Examples

换脸 example 1

Parameters

NameTypeDefaultConstraintsDescription
source_imageSource Image (Face)image_upload0–1 items
target_imageTarget Image (Body/Scene)image_upload0–1 items
additional_promptAdditional Prompttextarea
image_formatOutput Formatselectjpegpng | jpeg | webp
qualityImage Qualityslider9510 ~ 100 · step 1
seedSeednumber8005332

Output fields

FieldTypeDescription
imagesarray<string>

API

Call this model through one unified REST API. Get a key on the API Keys page.

cURL
# 1) Submit — returns { "task_uuid": "..." }
curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": {
    "source_image": [
      "https://segmind-resources.s3.amazonaws.com/input/d823dde1-aaae-4231-87b7-1d472bc71cef-faceswap-v5-input.png"
    ],
    "target_image": [
      "https://segmind-inference-inputs.s3.amazonaws.com/48892b17-762c-4de5-b6d8-f99d8e139115-black-man-image.jpeg"
    ],
    "image_format": "jpeg",
    "quality": 95,
    "seed": 8005332
  }
}'

# 2) Poll until status is "completed", then read the output URLs
curl "https://www.namifusion.com/api/v1/marketplace/run/tasks/TASK_UUID" \
  -H "Authorization: Bearer YOUR_API_KEY"
Python
import time, requests

API_KEY = "YOUR_API_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}

# 1) Submit
resp = requests.post(
    "https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5",
    headers=HEADERS,
    json={
        "input": {
            "source_image": [
                "https://segmind-resources.s3.amazonaws.com/input/d823dde1-aaae-4231-87b7-1d472bc71cef-faceswap-v5-input.png"
            ],
            "target_image": [
                "https://segmind-inference-inputs.s3.amazonaws.com/48892b17-762c-4de5-b6d8-f99d8e139115-black-man-image.jpeg"
            ],
            "image_format": "jpeg",
            "quality": 95,
            "seed": 8005332
        }
    },
)
resp.raise_for_status()  # 401/402/429/5xx stop here instead of polling a bad task
task = resp.json()

# 2) Poll until a terminal state (completed / failed / cancelled).
#    This model is allowed up to 300s server-side.
deadline = time.time() + 360
while task.get("status") not in ("completed", "failed", "cancelled"):
    if time.time() > deadline:
        raise TimeoutError(f"still {task.get('status')} — keep the task_uuid and poll later")
    time.sleep(3)
    poll = requests.get(f"https://www.namifusion.com/api/v1/marketplace/run/tasks/{task['task_uuid']}", headers=HEADERS)
    poll.raise_for_status()
    task = poll.json()

print(task["status"], task.get("output"))
JavaScript
const API_KEY = "YOUR_API_KEY";
const HEADERS = { Authorization: `Bearer ${API_KEY}` };

// 1) Submit
const resp = await fetch("https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5", {
  method: "POST",
  headers: { ...HEADERS, "Content-Type": "application/json" },
  body: JSON.stringify({
    "input": {
      "source_image": [
        "https://segmind-resources.s3.amazonaws.com/input/d823dde1-aaae-4231-87b7-1d472bc71cef-faceswap-v5-input.png"
      ],
      "target_image": [
        "https://segmind-inference-inputs.s3.amazonaws.com/48892b17-762c-4de5-b6d8-f99d8e139115-black-man-image.jpeg"
      ],
      "image_format": "jpeg",
      "quality": 95,
      "seed": 8005332
    }
  }),
});
if (!resp.ok) throw new Error(`submit failed: ${resp.status} ${await resp.text()}`);
let task = await resp.json();

// 2) Poll until a terminal state (completed / failed / cancelled).
//    This model is allowed up to 300s server-side.
const deadline = Date.now() + 360 * 1000;
while (!["completed", "failed", "cancelled"].includes(task.status)) {
  if (Date.now() > deadline) throw new Error(`still ${task.status} — keep the task_uuid and poll later`);
  await new Promise((r) => setTimeout(r, 3000));
  const poll = await fetch(`https://www.namifusion.com/api/v1/marketplace/run/tasks/${task.task_uuid}`, { headers: HEADERS });
  if (!poll.ok) throw new Error(`poll failed: ${poll.status}`);
  task = await poll.json();
}

console.log(task.status, task.output);

Documentation

NamiFusion Faceswap v5

AI Image FaceSwap v5: Ultra-fast face and smart head swapping with built-in skin tone matching for high-volume, production-ready workflows.

NamiFusion Faceswap v5 is an image face swap API designed for speed and scale. It delivers v2-level inference speed with significantly improved output quality, featuring automatic smart head swapping, built-in skin tone matching, and creative prompt support — all at the lowest cost in the NamiFusion faceswap lineup.


Key Features

  • Ultra-Fast Inference: Matches Faceswap v2's speed while delivering substantially better visual quality.
  • Smart Head Swap: Automatically determines whether face-only or full-head blending produces the most natural result — no manual mode selection required.
  • Built-In Skin Tone Matching: Adapts skin tones automatically for natural, seamless results without manual correction.
  • Creative Prompt Support: Use additional_prompt to guide subtle attribute changes like "wearing a hat" or "smiling".
  • Reproducible Outputs: Seed-based generation ensures consistent results across runs, ideal for A/B testing and batch workflows.
  • Cost-Optimized: The most affordable faceswap option in the NamiFusion lineup without sacrificing professional-level quality.

Technical Specifications

ParameterDetails
Core input fieldssource_image, target_image, seed
Optional fieldsadditional_prompt, image_format, quality
Image format optionspng, jpeg, webp
Quality range10 – 100 (default: 95)
Seed default8005332
Average inference time~9.63s

Quick Start

API Endpoint

EndpointMethodDescription
/api/v1/marketplace/run/namifusion/faceswap-v5POSTSubmit a Faceswap v5 task (synchronous)

Faceswap v5 uses a synchronous response model — the result is returned directly in the response body, no polling required.

Request Parameter Overview

The core Faceswap v5 fields in the request body are as follows:

{
  "source_image": "string (URL)",
  "target_image": "string (URL)",
  "additional_prompt": "string",
  "image_format": "png | jpeg | webp",
  "quality": 95,
  "seed": 8005332
}

Authentication

Include your API Key in the request header:

X-API-Key: sk-your-api-key

Standard Call Flow

Faceswap v5 uses a synchronous workflow — the result image is returned directly:

  1. Call POST /api/v1/marketplace/run/namifusion/faceswap-v5 with your input parameters.
  2. The response contains the result image directly.
  3. No polling step is needed.

Submit the Task and Get the Result

curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/namifusion/faceswap-v5" \
  -H "X-API-Key: sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "input": {
      "source_image": "https://example.com/source.jpg",
      "target_image": "https://example.com/target.jpg",
      "image_format": "png",
      "quality": 95,
      "seed": 8005332
    }
  }'

Example successful response:

{
  "status": "completed",
  "output": {
    "image_url": "https://cdn.namifusion.com/result/faceswap_v5_abc123.png"
  }
}

Example failed response:

{
  "status": "failed",
  "output": null,
  "error_message": "Face swap failed because no valid face was detected in source_image."
}

Scenario 1: Basic Face Swap (Minimal Parameters)

Suitable for quick testing or simple single-face swap scenarios where default quality and format are acceptable.

Request Example

{
  "source_image": "https://example.com/source.jpg",
  "target_image": "https://example.com/target.jpg"
}

Behavior

  • image_format defaults to png.
  • quality defaults to 95.
  • seed defaults to 8005332.
  • Smart head swap runs automatically — no mode selection needed.
  • Built-in skin tone matching is always active.

Scenario 2: Production Face Swap (Full Parameters)

Suitable for production pipelines, marketing campaigns, or content creation where output format, quality, and reproducibility matter.

Request Example

{
  "source_image": "https://example.com/source_face.jpg",
  "target_image": "https://example.com/target_person.jpg",
  "additional_prompt": "wearing a hat",
  "image_format": "jpeg",
  "quality": 95,
  "seed": 2023
}

Behavior

  • additional_prompt guides subtle attribute changes in the output (e.g., accessories, expressions).
  • image_format: "jpeg" produces smaller files, ideal for web delivery.
  • quality: 95 ensures production-grade output fidelity.
  • A fixed seed guarantees identical results on repeated calls with the same inputs.

Scenario 3: High-Volume Batch Processing (Speed-Optimized)

Suitable for automation pipelines, dataset anonymization, or real-time applications where throughput and cost matter more than maximum quality.

Request Example

{
  "source_image": "https://example.com/source.jpg",
  "target_image": "https://example.com/target.jpg",
  "image_format": "webp",
  "quality": 75,
  "seed": 42
}

Behavior

  • quality: 75 reduces processing time and output size while maintaining acceptable visual quality.
  • image_format: "webp" offers the best balance of compression and quality for web-scale delivery.
  • A consistent seed across batch runs ensures reproducible outputs for caching and A/B testing.

Parameter and Return Value Details

Request Parameters

ParameterTypeRequiredDefaultDescription
source_imagestringYesURL of the source image providing the face identity.
target_imagestringYesURL of the target image where the face will be replaced.
additional_promptstringNo""Short descriptive prompt for subtle attribute guidance (e.g., "wearing a hat", "smiling").
image_formatstringNo"png"Output image format. Accepted values: "png", "jpeg", "webp".
qualityintegerNo95Output quality from 10 to 100. Higher values produce better fidelity at the cost of file size.
seedintegerNo8005332Random seed for reproducibility. Use the same seed with the same inputs to get identical outputs.

Validation Rules and Common Errors

source_image / target_image

  • Must be publicly accessible URLs.
  • The face in source_image provides the identity; the face in target_image is the one being replaced.
  • Use clear, front-facing images with visible facial features for best results.

additional_prompt

  • Keep prompts short and descriptive (e.g., "wearing sunglasses", "different hairstyle").
  • Avoid long or complex prompts — v5 is optimized for subtle, controlled variations.
  • Leave blank if no attribute modification is needed.

image_format

  • Accepted values: "png", "jpeg", "webp".
  • jpeg is recommended for speed and size efficiency.
  • png is recommended when maximum detail or post-editing flexibility is required.
  • webp offers the best balance of quality and compression.

quality

  • Integer between 10 and 100.
  • Recommended: 95 for production and final assets; 75–85 for fast testing and iteration.

Impact of Parameters on Output

Parameter combinationImpact on result
quality: 95Production-grade fidelity; larger file size.
quality: 75–85Faster processing and smaller files; suitable for testing.
image_format: "jpeg"Fastest processing and smallest file size.
image_format: "png"Maximum detail; best for post-editing.
image_format: "webp"Best quality-to-size ratio for web delivery.
additional_prompt providedGuides subtle attribute changes in the swapped face output.
additional_prompt emptyNo attribute modification; pure face/head swap.
Fixed seedIdentical outputs on repeated calls with the same inputs.
Random seedSlight variation in output across runs.

Recommended Settings by Use Case

Use Casequalityimage_formatseedadditional_prompt
Content Creation (Thumbnails, Social Media)85webp1001"wearing sunglasses"
Marketing & Advertising (Campaign Mockups)95jpeg2023"different hairstyle"
Privacy Protection (Dataset Anonymization)90png31415(leave blank)
Real-Time / High-Volume Batch Processing75jpeg or webp42(leave blank)

Notes

  1. Smart head swap is always on: Faceswap v5 automatically decides between face-only and full-head blending — no configuration needed.
  2. Skin tone matching is built-in: Manual color correction is rarely needed; the model adapts skin tones automatically.
  3. Keep images reasonably aligned: Source and target images with similar head angles and lighting produce the most natural results.
  4. Use fixed seeds for consistency: For A/B testing, caching, and batch pipelines, lock the seed to ensure reproducible outputs.
  5. Prefer publicly accessible URLs: This helps the service fetch image resources reliably.
  6. Avoid complex prompts: additional_prompt is designed for short, subtle attribute hints — not detailed scene descriptions.
换脸 API — Pricing, Playground & Docs | NamiFusion