Documentation Index
Fetch the complete documentation index at: https://docs.akool.com/llms.txt
Use this file to discover all available pages before exploring further.
video_url must match the URL used in Submit Person Analysis. Each obj_id must exist in analysis_result.media for that analysis.
Endpoint
POST https://openapi.akool.com/api/open/v4/headswap/task/create
| Parameter | Value | Description |
|---|
| x-api-key | API Key | Request authorization. If both Authorization and x-api-key are set, platform rules determine precedence. |
| Authorization | Bearer {token} | Optional Bearer token. Get Token |
| Content-Type | application/json | Required |
Body Attributes
| Parameter | Type | Required | Description |
|---|
| video_url | String | true | Identical source video URL as used in analysis |
| mappings | Array | true | At least 1 object, at most 5 |
| - obj_id | Number | true | Subject id from analysis_result.media[].obj_id |
| - img_url | String | true | Single reference face image URL (http / https) for that obj_id |
| model_name | String | true | Model id — see Model names below |
| resolution | String | true | Output resolution: 480p or 720p |
| template_id | String | false | Template id when enabled for your tenant |
| keep_original_sound | Boolean | false | Keep source audio (default true) |
| webhookUrl | String | false | HTTPS recommended; final-state callback (format per platform / support) |
Model names
| Value | Description |
|---|
| akool-premium | Head swap generation model |
If the account does not support the model, you may receive 1003 with a message such as Your current account does not support this feature.
Response Attributes
| Parameter | Type | Description |
|---|
| code | Integer | Business status code (1000 = success) |
| msg | String | Status message |
| data | Object | Created task |
| - _id | String | Task id — use with Get Head Swap Task Detail |
| - create_time | Long | Creation time (ms) |
| - uid | Integer | User id |
| - team_id | String | Team id |
| - video_duration | Number | Associated video duration (seconds) |
| - task_id | String | Internal processing id |
| - resolution | String | Output resolution |
| - status | Integer | Usually 1 (queue) when created |
| - deduction_lock_duration | Number | Pre-hold / lock value (billing semantics per agreement) |
| - model_name | String | Model used |
| - file_name | String | Output file name (platform-generated) |
| - video_url | null | Often null at create time; poll Get Head Swap Task Detail for the result URL |
Example
Request Body
{
"video_url": "https://example.com/videos/source.mp4",
"mappings": [
{
"obj_id": 0,
"img_url": "https://example.com/faces/reference.jpeg"
}
],
"model_name": "akool-premium",
"resolution": "720p",
"keep_original_sound": true,
"webhookUrl": "https://example.com/your-webhook"
}
Request
curl --location 'https://openapi.akool.com/api/open/v4/headswap/task/create' \
--header 'x-api-key: {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
"video_url": "https://example.com/videos/source.mp4",
"mappings": [
{
"obj_id": 0,
"img_url": "https://example.com/faces/reference.jpeg"
}
],
"model_name": "akool-premium",
"resolution": "720p",
"keep_original_sound": true,
"webhookUrl": "https://example.com/your-webhook"
}'
Response
{
"code": 1000,
"msg": "OK",
"data": {
"_id": "6a066dc58570ecbf64f761a5",
"create_time": 1778806213962,
"uid": 101400,
"team_id": "6805fb69e92d9edc7ca0b409",
"video_duration": 10,
"task_id": "6a066dc52872921bde86b745",
"resolution": "720p",
"status": 1,
"deduction_lock_duration": 100,
"model_name": "akool-premium",
"file_name": "Headswap_1778806213962.mp4",
"video_url": null
}
}
Important Notes
- More than 5 mappings may return an error such as:
Up to 5 characters can be replaced at one time.
- Credits are validated on create; insufficient balance often returns
1104.
- Store
data._id and poll Get Head Swap Task Detail (or wait for webhookUrl) for the output video_url.