> ## 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.

# Update Video Audio

> Add or replace audio on a generated Image to Video result

## Endpoint

```
POST https://openapi.akool.com/api/open/v4/image2Video/updateVideoAudio
```

## Request Headers

| **Parameter** | **Value** | **Description** |
| - | - | - |
| x-api-key | API Key | Your API Key used for request authorization. If both Authorization and x-api-key have values, Authorization will be used first and x-api-key will be discarded. |
| Authorization | Bearer `{token}` | Your API Key used for request authorization.[Get Token](https://docs.akool.com/authentication/usage.md#get-the-token) |

## Body Attributes

| **Parameter** | **Type** | **Required** | **Description** |
| - | - | - | - |
| pre\_video\_id | String | true | Image to Video result \_id |
| audio\_url | String | true | Audio URL, required when audio\_type = 2 |
| audio\_type | Integer | true | 1 = AI Generate, 2 = user custom upload |

## Response Attributes

| **Parameter** | **Type** | **Description** |
| - | - | - |
| code | Integer | Interface returns business status code (1000:success) |
| msg | String | Interface returns status information |
| data | Object | Response data object |
| - create\_time | Long | Creation timestamp |
| - uid | Integer | User ID |
| - team\_id | String | Team ID |
| - update\_time | Long | Last update time |
| - video\_duration | Number | Video duration |
| - webhookUrl | String | Callback URL |
| - resolution | String | Resolution |
| - file\_name | String | File name |
| - effect\_name | String | Effect name |
| - \_id | String | Document ID |
| - pre\_video\_id | String | Original video ID |
| - image\_url | String | Image URL |
| - prompt | String | Prompt text |
| - negative\_prompt | String | Negative prompt |
| - extend\_prompt | Boolean | Whether extended prompts were used |
| - audio\_type | Integer | Audio type |
| - audio\_url | String | Audio URL |
| - deduction\_credit | Integer | Credits deducted |
| - effect\_code | String | Effect code |
| - status | Integer | Status: 1=queueing, 2=processing, 3=completed, 4=failed |
| - only\_add\_audio | Boolean | Whether only audio was added |

## Example

### Request Body

```json theme={null}
{
  "pre_video_id": "6890830af27dfad2a3e6062d",
  "audio_url": "https://drz0f01yeq1cx.cloudfront.net/1753772497950-9213-1749809724426audio.mp3",
  "audio_type": 2
}
```

### Request

```bash cURL theme={null}
curl --location 'https://openapi.akool.com/api/open/v4/image2Video/updateVideoAudio' \
--header 'x-api-key: {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
  "pre_video_id": "6890830af27dfad2a3e6062d",
  "audio_url": "https://drz0f01yeq1cx.cloudfront.net/1753772497950-9213-1749809724426audio.mp3",
  "audio_type": 2
}'
```

```java Java theme={null}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n  \"pre_video_id\": \"6890830af27dfad2a3e6062d\",\n  \"audio_url\": \"https://drz0f01yeq1cx.cloudfront.net/1753772497950-9213-1749809724426audio.mp3\",\n  \"audio_type\": 2\n}");
Request request = new Request.Builder()
  .url("https://openapi.akool.com/api/open/v4/image2Video/updateVideoAudio")
  .method("POST", body)
  .addHeader("x-api-key", "{{API Key}}")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
```

```js Javascript theme={null}
const myHeaders = new Headers();
myHeaders.append("x-api-key", "{{API Key}}");
myHeaders.append("Content-Type", "application/json");

const raw = JSON.stringify({
  "pre_video_id": "6890830af27dfad2a3e6062d",
  "audio_url": "https://drz0f01yeq1cx.cloudfront.net/1753772497950-9213-1749809724426audio.mp3",
  "audio_type": 2
});

const requestOptions = {
  method: "POST",
  headers: myHeaders,
  body: raw,
  redirect: "follow"
};

fetch("https://openapi.akool.com/api/open/v4/image2Video/updateVideoAudio", requestOptions)
  .then((response) => response.text())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
```

```php PHP theme={null}
<?php
$client = new Client();
$headers = [
  'x-api-key' =>'{{API Key}}',
  'Content-Type' => 'application/json'
];
$body = '{
  "pre_video_id": "6890830af27dfad2a3e6062d",
  "audio_url": "https://drz0f01yeq1cx.cloudfront.net/1753772497950-9213-1749809724426audio.mp3",
  "audio_type": 2
}';
$request = new Request('POST', 'https://openapi.akool.com/api/open/v4/image2Video/updateVideoAudio', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
?>
```

```python Python theme={null}
import requests
import json

url = "https://openapi.akool.com/api/open/v4/image2Video/updateVideoAudio"

payload = json.dumps({
  "pre_video_id": "6890830af27dfad2a3e6062d",
  "audio_url": "https://drz0f01yeq1cx.cloudfront.net/1753772497950-9213-1749809724426audio.mp3",
  "audio_type": 2
})
headers = {
  'x-api-key':'{{API Key}}',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
```

### Response

```json theme={null}
{
  "code": 1000,
  "msg": "OK",
  "data": {
    "create_time": 1754374697629,
    "uid": 101400,
    "team_id": "6805fb69e92d9edc7ca0b409",
    "update_time": 1754374394023,
    "video_duration": 5.063,
    "webhookUrl": "",
    "resolution": "4k",
    "file_name": "Image2Video_Animate this image with .mp4",
    "effect_name": "Squish",
    "_id": "6891a2295d612f78c9204f77",
    "pre_video_id": "6891a07f5d612f78c9204f1c",
    "image_url": "https://drz0f01yeq1cx.cloudfront.net/1753772478686-9524-b6e4169bb1b44d5d8361936b3f6eddb8.png",
    "prompt": "Animate this image with smooth camera movement and subtle object motion.",
    "negative_prompt": "",
    "extend_prompt": false,
    "audio_type": 2,
    "audio_url": "https://drz0f01yeq1cx.cloudfront.net/1753772497950-9213-1749809724426audio.mp3",
    "deduction_credit": 5,
    "effect_code": "squish_89244231312",
    "status": 1,
    "only_add_audio": true
  }
}
```

## Important Notes

* The `pre_video_id` must be the `_id` of a completed video (status = 3) from a previous [Create Image to Video](https://docs.akool.com/ai-tools-suite/image2video/create-video.md) request
* When `audio_type` is 2 (custom upload), the `audio_url` parameter is required
* When `audio_type` is 1 (AI generate), the system will automatically generate matching audio
* The response creates a new video entry with its own `_id`; use this to track the audio update status via [Get Image to Video Results](https://docs.akool.com/ai-tools-suite/image2video/get-results.md)
* Video to Audio is charged separately (5 credits for 5s, 10 credits for 10s) unless included in the original Image to Video creation


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.