Skip to main content

Face Swap with Model ID Array

POST /api/images/swap_file_ids

This endpoint enables the swapping of faces between an image containing a face uploaded from the client device and a set of model images also uploaded as files. The processed results are stored and returned as an array of URLs.

Use this endpoint

Best for scenarios where the model library is already preloaded and identified by unique IDs.

Using model IDs avoids the need to upload model images with every request, reducing bandwidth and increasing processing speed.

๐Ÿ” Authenticationโ€‹

This endpoint requires a valid Bearer Token in the Authorization header.

Authorization: Bearer YOUR_API_TOKEN

๐Ÿ“ฅ Requestโ€‹

Content-Type: multipart/form-data

FieldTypeDescription
facefileThe selfie image to use as the source face.
model_idsstringComma-separated list of model IDs from the database.
appintegerThe application ID initiating the request.

Example cURLโ€‹

curl -X POST https://api.storyface.ai/api/images/swap_file_ids \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "face=@/path/to/selfie.jpg" \
-F "model_ids=12,45,102" \
-F "app=123"
caution

Ensure the provided model IDs are valid and belong to your application context. Invalid IDs will result in an error response.

๐Ÿ“ค Responseโ€‹

{
"urls": [
"https://cdn.storyface.ai/images/swap_result_1.jpg",
"https://cdn.storyface.ai/images/swap_result_2.jpg"
]
}

โš ๏ธ Error Responsesโ€‹

StatusDescriptionExample
400Bad request{ "field": "field error message" }
500Internal server error{ "general": "Internal server error" }
danger

The selfie image (face) must be a valid JPEG or PNG and under 10MB in size.


๐Ÿงช Test this Endpointโ€‹

An interactive test component will be embedded soon to allow real-time testing from this documentation.

Coming Soon

This documentation will include an interface to try out this endpoint without external tools.