MuseSpark
MuseSpark
Models & toolsTools

Image Face Swap API guide

Image Face Swap API: Replace a face in an image using a separate face reference. Choose base or pro mode; indexed face targeting is available in base mode.

Model overview

Replace a face in an image using a separate face reference. Choose base or pro mode; indexed face targeting is available in base mode.

API integration

DocumentationValue
API invocation identifierimage-face-swap
IntegrationAsync task API

Use this invocation identifier in API requests. Check your authorized model catalog for access. Follow the Quickstart for your first complete call.

Request parameters

Studio presets describe the form setup, not guaranteed server defaults. Send preset values explicitly to reproduce them.

imagestringNon-nullRequired

The image that contains the face to be replaced.

Media types: image/*.

face_imagestringNon-nullRequired

The face image as reference.

Media types: image/*.

modestringNon-nullOptional

Sets mode for this item.

Allowed values: "base", "pro".

Studio preset: "base".

target_indexintegerNon-nullOptional

Base mode only: 0 selects the largest face; 1-10 select another target face. Pro mode does not accept target_index; retain the neutral default 0.

Value: minimum 0; maximum 10.

Studio preset: 0.

No parameters match. Clear the search or reset the filters.

Model rules

  • When mode is "pro", use 0 for target_index.

Parameter meaning

  • Base mode: image is the photo to edit, while face_image supplies the replacement face.
  • Base mode: In base mode, target_index selects the face to replace; 0 selects the largest face.
  • Pro mode: image is the photo to edit, while face_image supplies the replacement face.

Reference media

  • Base mode: Use clear, front-facing photos with comparable lighting for the base image and reference face.
  • Pro mode: Use clear, front-facing photos with comparable lighting for the base image and reference face.
  • When mode is pro, omit target_index or leave its neutral value at 0. The public condition allows only 0 in pro mode; a nonzero target_index is a base-mode control.

Integration notes

Use the following field formats and values in MuseSpark requests.

  • mode, target_index: Select mode within parameters. Use nonzero target_index only with base mode.

Request examples

Replace example media URLs and YOUR_... input identifiers with your own valid resources. Examples are checked against the exported item schema; media access and paid execution are separate runtime checks.

Set MUSESPARK_API_KEY and a stable MUSESPARK_REQUEST_ID before submitting. Preserve the request ID for retries of the same request and use a new ID for new work. Python examples use requests; JavaScript examples use Node.js 20 or later. The standalone Quickstart includes task polling and recovery.

Replace a face in base mode

curl --fail-with-body 'https://api.musespark.ai/api/v1/openapi/task' \
  -H "Authorization: Bearer $MUSESPARK_API_KEY" \
  -H "X-Idempotency-Key: $MUSESPARK_REQUEST_ID" \
  -H 'Content-Type: application/json' \
  -d '{
  "item_key": "image-face-swap",
  "parameters": {
    "mode": "base",
    "target_index": 1,
    "image": "https://example.com/adult-group-photo.jpg",
    "face_image": "https://example.com/adult-face-reference.jpg"
  }
}'

Parameters used: mode · target_index · image · face_image.

Replace a face in pro mode

curl --fail-with-body 'https://api.musespark.ai/api/v1/openapi/task' \
  -H "Authorization: Bearer $MUSESPARK_API_KEY" \
  -H "X-Idempotency-Key: $MUSESPARK_REQUEST_ID" \
  -H 'Content-Type: application/json' \
  -d '{
  "item_key": "image-face-swap",
  "parameters": {
    "mode": "pro",
    "image": "https://example.com/adult-portrait.jpg",
    "face_image": "https://example.com/adult-face-reference.jpg"
  }
}'

Parameters used: mode · image · face_image.

Output

The output is an edited image with the reference face composited into the target photo.

Creation returns a task ID inside data. Poll that task until completion, then save data.result.output_urls and any data.result.batch_results. See the task lifecycle for terminal states, result retention, and errors.

Troubleshooting

A nonzero target_index is rejected in pro mode. Use mode=base for indexed targeting, or omit target_index for pro mode.

mode · target_index

The wrong face is replaced in base mode. Use target_index to choose the intended face; 0 denotes the largest face.

target_index · mode

For rejected inputs, check the field type, accepted values, and conditional requirements in Request parameters and Model rules. Correct the affected fields before submitting again.

If creation times out, preserve the request identity and any known task ID. Follow Errors, timeouts and retries before submitting again.

The public input snapshot was exported on 2026-11-09. Current prices and availability are listed in the model center.