Skip to main content

Face Swap with URL Models and Uploaded Face

POST /api/images/swap_file_urls

This endpoint enables the swapping of faces between a model array hosted at public URLs and an image uploaded from the client device. The processed images are stored in Google Cloud Storage and returned as an array of URLs.

Use this endpoint

Recommended when your model images are hosted online and the client uploads the face image directly.

This method improves performance by avoiding repeated uploads of the same model images, which is especially useful for mobile devices with limited bandwidth.

๐Ÿ” 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 containing the face to be swapped.
modelsstringA JSON array or comma-separated list of model URLs.
watermarkintegerOptional watermark ID to apply on the output images.
appintegerThe application ID initiating the request.

Example cURLโ€‹

curl -X POST https://api.storyface.ai/api/images/swap_file_urls \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-F "face=@/path/to/your/selfie.jpg" \
-F "models=https://example.com/model1.jpg,https://example.com/model2.jpg" \
-F "watermark=1" \
-F "app=123"
caution

Ensure the models field contains valid public URLs accessible by our servers. Invalid or private URLs will lead to request failure.

๐Ÿ“ค 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

All uploaded files must be under 10MB. Larger files will be rejected with a 400 error.


๐Ÿงช Test this Endpointโ€‹

We're building an embedded tester to allow real-time testing.

Coming Soon

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