API for Couple Face Swapper
Authentication
An API key is required for all requests. You can generate an API key from the developers tab in your dashboard.
Header Attributes
Parameter | Value |
---|---|
X-source | web |
X-api-key | YOUR_API_KEY |
Couple Face Swap
Request URL
Method | URL |
---|---|
POST | http://aiapi.aiphotocraft.com/api/faceswap/faceswap2 (opens in a new tab) |
Body Parameters
Parameter | Type | Description | Required |
---|---|---|---|
srcimage | file | Source image for swap | Yes* |
targetimage | file | Target image for swap | Yes* |
swap_index | string | Tuple of indexes to swap (Example: "2,1") | No |
enhance | string | Either 'true' or 'false'. Enhance the result after swap | Yes* |
*Required parameters
Face Position and Swap Index
By default, the API swaps faces based on position (left-to-left, right-to-right). This means:
- If both images have similar face positioning (e.g., female on left, male on right in both images), no swap_index is needed.
- If face positions differ between images (e.g., female on left in source but on right in target), you should use
swap_index=2,1
to correctly swap the faces.
The swap_index parameter controls which face in the target image gets mapped to which face in the source image:
- Default (no swap_index): Maps in position order (1→1, 2→2)
- swap_index=2,1: Reverses the mapping (1→2, 2→1)
Response
The API returns the processed image with the faces swapped according to the specified parameters.
Response Content Type
application/json
Response Codes
Code | Description |
---|---|
201 | Swap successful |
400 | Bad request |
Error Handling
The API will return appropriate error codes and messages if there's an issue with your request.
Example
curl -X POST \
http://aiapi.aiphotocraft.com/api/faceswap/faceswap2 \
-H 'X-source: web' \
-H 'X-api-key: YOUR_API_KEY' \
-F 'srcimage=@/path/to/source.jpg' \
-F 'targetimage=@/path/to/target.jpg' \
-F 'swap_index=2,1' \
-F 'enhance=true'