# Image to Video - Documentation

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown is available with `Accept: text/markdown` and `.md` URL variants.

Source: /docs/api-reference/model-apis-img2video

# Image to Video

POST

/

v3

/

async

/

img2video

Try it

Image to Video

cURL

```
curl --request POST \
--url https://api.novita.ai/v3/async/img2video \
--header 'Authorization: &#x3C;authorization>' \
--header 'Content-Type: &#x3C;content-type>' \
--data '
{
"extra": {
"response_video_type": "&#x3C;string>",
"webhook": {
"url": "&#x3C;string>",
"test_mode": {
"enabled": true,
"return_task_status": "&#x3C;string>"
}
},
"enterprise_plan": {
"enabled": true
}
},
"model_name": "&#x3C;string>",
"image_file": "&#x3C;string>",
"frames_num": 123,
"frames_per_second": 123,
"image_file_resize_mode": "&#x3C;string>",
"steps": 123,
"seed": 123,
"motion_bucket_id": 123,
"cond_aug": 123,
"enable_frame_interpolation": true
}
'
```

```
import requestsurl = "https://api.novita.ai/v3/async/img2video"payload = { "extra": { "response_video_type": "&#x3C;string>", "webhook": { "url": "&#x3C;string>", "test_mode": { "enabled": True, "return_task_status": "&#x3C;string>" } }, "enterprise_plan": { "enabled": True } }, "model_name": "&#x3C;string>", "image_file": "&#x3C;string>", "frames_num": 123, "frames_per_second": 123, "image_file_resize_mode": "&#x3C;string>", "steps": 123, "seed": 123, "motion_bucket_id": 123, "cond_aug": 123, "enable_frame_interpolation": True}headers = { "Content-Type": "&#x3C;content-type>", "Authorization": "&#x3C;authorization>"}response = requests.post(url, json=payload, headers=headers)print(response.text)
```

```
const options = { method: 'POST', headers: {'Content-Type': '&#x3C;content-type>', Authorization: '&#x3C;authorization>'}, body: JSON.stringify({ extra: { response_video_type: '&#x3C;string>', webhook: {url: '&#x3C;string>', test_mode: {enabled: true, return_task_status: '&#x3C;string>'}}, enterprise_plan: {enabled: true} }, model_name: '&#x3C;string>', image_file: '&#x3C;string>', frames_num: 123, frames_per_second: 123, image_file_resize_mode: '&#x3C;string>', steps: 123, seed: 123, motion_bucket_id: 123, cond_aug: 123, enable_frame_interpolation: true })};fetch('https://api.novita.ai/v3/async/img2video', options) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.error(err));
```

```
&#x3C;?php$curl = curl_init();curl_setopt_array($curl, [ CURLOPT_URL => "https://api.novita.ai/v3/async/img2video", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode([ 'extra' => [ 'response_video_type' => '&#x3C;string>', 'webhook' => [ 'url' => '&#x3C;string>', 'test_mode' => [ 'enabled' => true, 'return_task_status' => '&#x3C;string>' ] ], 'enterprise_plan' => [ 'enabled' => true ] ], 'model_name' => '&#x3C;string>', 'image_file' => '&#x3C;string>', 'frames_num' => 123, 'frames_per_second' => 123, 'image_file_resize_mode' => '&#x3C;string>', 'steps' => 123, 'seed' => 123, 'motion_bucket_id' => 123, 'cond_aug' => 123, 'enable_frame_interpolation' => true ]), CURLOPT_HTTPHEADER => [ "Authorization: &#x3C;authorization>", "Content-Type: &#x3C;content-type>" ],]);$response = curl_exec($curl);$err = curl_error($curl);curl_close($curl);if ($err) { echo "cURL Error #:" . $err;} else { echo $response;}
```

```
package mainimport (	"fmt"	"strings"	"net/http"	"io")func main() {	url := "https://api.novita.ai/v3/async/img2video"	payload := strings.NewReader("{\n \"extra\": {\n \"response_video_type\": \"&#x3C;string>\",\n \"webhook\": {\n \"url\": \"&#x3C;string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"&#x3C;string>\"\n }\n },\n \"enterprise_plan\": {\n \"enabled\": true\n }\n },\n \"model_name\": \"&#x3C;string>\",\n \"image_file\": \"&#x3C;string>\",\n \"frames_num\": 123,\n \"frames_per_second\": 123,\n \"image_file_resize_mode\": \"&#x3C;string>\",\n \"steps\": 123,\n \"seed\": 123,\n \"motion_bucket_id\": 123,\n \"cond_aug\": 123,\n \"enable_frame_interpolation\": true\n}")	req, _ := http.NewRequest("POST", url, payload)	req.Header.Add("Content-Type", "&#x3C;content-type>")	req.Header.Add("Authorization", "&#x3C;authorization>")	res, _ := http.DefaultClient.Do(req)	defer res.Body.Close()	body, _ := io.ReadAll(res.Body)	fmt.Println(string(body))}
```

```
HttpResponse&#x3C;String> response = Unirest.post("https://api.novita.ai/v3/async/img2video") .header("Content-Type", "&#x3C;content-type>") .header("Authorization", "&#x3C;authorization>") .body("{\n \"extra\": {\n \"response_video_type\": \"&#x3C;string>\",\n \"webhook\": {\n \"url\": \"&#x3C;string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"&#x3C;string>\"\n }\n },\n \"enterprise_plan\": {\n \"enabled\": true\n }\n },\n \"model_name\": \"&#x3C;string>\",\n \"image_file\": \"&#x3C;string>\",\n \"frames_num\": 123,\n \"frames_per_second\": 123,\n \"image_file_resize_mode\": \"&#x3C;string>\",\n \"steps\": 123,\n \"seed\": 123,\n \"motion_bucket_id\": 123,\n \"cond_aug\": 123,\n \"enable_frame_interpolation\": true\n}") .asString();
```

```
require 'uri'require 'net/http'url = URI("https://api.novita.ai/v3/async/img2video")http = Net::HTTP.new(url.host, url.port)http.use_ssl = truerequest = Net::HTTP::Post.new(url)request["Content-Type"] = '&#x3C;content-type>'request["Authorization"] = '&#x3C;authorization>'request.body = "{\n \"extra\": {\n \"response_video_type\": \"&#x3C;string>\",\n \"webhook\": {\n \"url\": \"&#x3C;string>\",\n \"test_mode\": {\n \"enabled\": true,\n \"return_task_status\": \"&#x3C;string>\"\n }\n },\n \"enterprise_plan\": {\n \"enabled\": true\n }\n },\n \"model_name\": \"&#x3C;string>\",\n \"image_file\": \"&#x3C;string>\",\n \"frames_num\": 123,\n \"frames_per_second\": 123,\n \"image_file_resize_mode\": \"&#x3C;string>\",\n \"steps\": 123,\n \"seed\": 123,\n \"motion_bucket_id\": 123,\n \"cond_aug\": 123,\n \"enable_frame_interpolation\": true\n}"response = http.request(request)puts response.read_body
```

200

```
{
"task_id": "&#x3C;string>"
}
```

This API seamlessly transforms an image into a cohesive video. It is designed to create smooth transitions and animations from static images, making it ideal for producing dynamic visual content for presentations, social media, and marketing campaigns.

This is an asynchronous API; only the task_id will be returned. You should use the task_id to request the [Task Result API](/docs/api-reference/model-apis-task-result) to retrieve the video generation results.

##

[​](#request-headers)

Request Headers

[​](#param-content-type)

Content-Type

string

required

Enum: `application/json`

[​](#param-authorization)

Authorization

string

required

Bearer authentication format, for example: Bearer {{API Key}}.

##

[​](#request-body)

Request Body

[​](#param-extra)

extra

object

Optional extra parameters for the request.

Show properties

[​](#param-response-video-type)

response_video_type

string

The returned video type. Default is mp4.Enum: `mp4, gif`

[​](#param-webhook)

webhook

object

Webhook settings. More details can be found at [Webhook Documentation](/docs/api-reference/model-apis-webhook).

Show properties

[​](#param-url)

url

string

required

The URL of the webhook endpoint. Novita AI will send the task generated outputs to your specified webhook endpoint.

[​](#param-test-mode)

test_mode

object

By specifying Test Mode, a mock event will be sent to the webhook endpoint.

Show properties

[​](#param-enabled)

enabled

boolean

required

Set to true to enable Test Mode, or false to disable it. The default is false.

[​](#param-return-task-status)

return_task_status

string

required

Control the data content of the mock event. When set to TASK_STATUS_SUCCEED, you’ll receive a normal response; when set to TASK_STATUS_FAILED, you’ll receive an error response.Enum: `TASK_STATUS_SUCCEED, TASK_STATUS_FAILED`

[​](#param-enterprise-plan)

enterprise_plan

object

Dedicated Endpoints settings, which only take effect for users who have already subscribed to the [Dedicated Endpoints Documentation](/docs/guides/model-apis-dedicated-endpoints).

Show properties

[​](#param-enabled-1)

enabled

boolean

Set to true to schedule this task to use your Dedicated Endpoints’s dedicated resources. Default is false.

[​](#param-model-name)

model_name

string

required

Specifies the model to be used for processing. SVD (Singular Value Decomposition): Ideal for applications involving matrix factorization and dimensionality reduction. This model is well-suited for tasks such as signal processing, recommendation systems, and data compression, offering robust feature extraction and data simplification capabilities. SVD-XT: This model is an extended version of the standard SVD, optimized for handling larger datasets and more complex computations. It provides enhanced performance and accuracy in environments requiring intensive data processing.Enum: `SVD-XT, SVD`

[​](#param-image-file)

image_file

string

required

The base64 of input image, with a maximum resolution of 2048 x 2048 and a maximum file size of 30 Mb.

[​](#param-frames-num)

frames_num

integer

required

Total number of video frames. When the parameter model_name=SVD_XT, then frames_num = 25; when the parameter model_name=SVD, then frames_num = 14.

[​](#param-frames-per-second)

frames_per_second

integer

required

Frames per second; the larger the frame rate, the smoother the video. Currently, only the number 6 is supported.

[​](#param-image-file-resize-mode)

image_file_resize_mode

string

required

The image file resize mode has two settings: When set to ORIGINAL_RESOLUTION, it retains the original image size but ensures the resolution is below 576 x 1024. When set to CROP_TO_ASPECT_RATIO, it maintains the original proportions of the image and crops it to fit within a 576 x 1024 resolution.Enum: `ORIGINAL_RESOLUTION, CROP_TO_ASPECT_RATIO`

[​](#param-steps)

steps

integer

required

The number of denoising steps. More steps usually produce higher quality content, but take more time to generate. Range [1, 50].

[​](#param-seed)

seed

integer

A seed is a number from which Stable Diffusion generates noise, which, makes generation deterministic. Using the same seed and set of parameters will produce identical content each time, minimum -1. Defaults to -1.

[​](#param-motion-bucket-id)

motion_bucket_id

integer

Identifies the specific motion bucket to be utilized during the img2video process. This parameter selects a predefined set of motion profiles, each corresponding to a unique identifier ranging from 1 to 255. Selecting an appropriate motion bucket can tailor the animation effects to better suit the specific characteristics or themes of the input images. Range [1, 255].

[​](#param-cond-aug)

cond_aug

number

The amount of noise added to the conditioning image. The higher the value, the less the video resembles the conditioning image. Increasing this value also enhances the motion in the generated video. Range [0, 1].

[​](#param-enable-frame-interpolation)

enable_frame_interpolation

boolean

Enables frame interpolation to standardize video output to 24 frames per second (fps). This feature smooths out motion by generating intermediate frames, enhancing the fluidity and continuity of the video sequence. This is particularly useful for converting lower frame rate footage to a more cinematic frame rate.

##

[​](#response)

Response

[​](#param-task-id)

task_id

string

Use the task_id to request the [Task Result API](/docs/api-reference/model-apis-task-result) to retrieve the generated outputs.

##

[​](#example)

Example

This API helps generate a video from an image. The returned video can be accessed via the API `/v3/async/task-result` using the `task_id`.
Try it in [playground](https://novita.ai/playground#img2video).
`Request:`

```
curl --location --request GET 'https://api.novita.ai/v3/async/img2video' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model_name": "SVD-XT",
"image_file": "{{Base64 encoded image}}",
"frames_num": 25,
"frames_per_second": 6,
"seed": 20231127,
"image_file_resize_mode": "CROP_TO_ASPECT_RATIO",
"steps": 20
}'
```

`Response:`

```
{
"task_id": "fa20dff3-18cb-4417-a7f8-269456a35154"
}
```

Use `task_id` to get videos
HTTP status codes in the 2xx range indicate that the request has been successfully accepted, while status codes in the 5xx range indicate internal server errors.
You can get the video URLs from the `videos` field in the response.
`Request:`

```
curl --location --request GET 'https://api.novita.ai/v3/async/task-result?task_id=fa20dff3-18cb-4417-a7f8-269456a35154' \
--header 'Authorization: Bearer {{API Key}}'
```

`Response:`

```
{
"task": {
"task_id": "fa20dff3-18cb-4417-a7f8-269456a35154",
"task_type": "IMG_TO_VIDEO",
"status": "TASK_STATUS_SUCCEED",
"reason": ""
},
"images": [],
"videos": [
{
"video_url": "https://faas-output-video.s3.ap-southeast-1.amazonaws.com/test/fa20dff3-18cb-4417-a7f8-269456a35154/e40de30e115947a0be2dfc78925e587d.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIASVPYCN6LRCW3SOUV%2F20231127%2Fap-southeast-1%2Fs3%2Faws4_request&X-Amz-Date=20231127T151757Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&x-id=GetObject&X-Amz-Signature=14faf7df34c2c2ff68fed102095af593844db7c5c5cd2d80e80beec0613192c7",
"video_url_ttl": "3600",
"video_type": "mp4"
}
]
}
```

Last modified on December 26, 2024
