Skip to content
Sign Up Free
Wan

Wan video API: text, image, reference and editing

Connect to Wan with a BetterToken API Key and choose fields, media and generation methods by Model ID and operation.

Generate videos from text, a first frame or reference media, or edit an existing video. 3.0 and Prime support three generation operations. For 2.7, choose separate Model IDs for text-to-video, image-to-video, reference generation and editing.

Prepare your BetterToken API Key. The Base URL is https://bettertoken.ai/v1, with Authorization: Bearer YOUR_API_KEY for authentication. Copy the Model ID exactly, including capitalization.

Every request.json below follows the same workflow: quote, confirm creation, poll and download. A quote does not start generation; creating a task submits a paid request. See current costs in the model plaza.

Models and operations

The table below lists available values by operation. See each subsection for field defaults, media counts and combination constraints. Media sizes use 1 MB = 1048576 bytes.

Model IDOperationDuration (seconds)Output levelAspect ratioAudioMedia roles
wan2.7-i2vimage_to_video2–15, step 1720p, 1080pomitprovider_defaultfirst_frame, last_frame, driving_audio
wan2.7-r2vreference_to_video2–15, step 1720p, 1080p16:9, 9:16, 1:1, 4:3, 3:4provider_defaultreference_image, reference_video
wan2.7-t2vtext_to_video2–15, step 1720p, 1080p16:9, 9:16, 1:1, 4:3, 3:4provider_defaultdriving_audio
wan2.7-videoeditvideo_edit2–15, step 1; supports auto720p, 1080pomitprovider_defaultbase_video
wan3.0-video-primeimage_to_video2–30, step 1; supports auto480p, 720p, 1080padaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16on, offfirst_frame, last_frame
wan3.0-video-primereference_to_video2–30, step 1; supports auto480p, 720p, 1080padaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16on, offreference_image, reference_video, reference_audio
wan3.0-video-primetext_to_video2–30, step 1; supports auto480p, 720p, 1080padaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16on, offNone
wan3.0-videoimage_to_video2–30, step 1; supports auto480p, 720p, 1080padaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16on, offfirst_frame, last_frame
wan3.0-videoreference_to_video2–30, step 1; supports auto480p, 720p, 1080padaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16on, offreference_image, reference_video, reference_audio
wan3.0-videotext_to_video2–30, step 1; supports auto480p, 720p, 1080padaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16on, offNone

For image-to-video (wan2.7-i2v, and wan3.0-video / wan3.0-video-prime with adaptive) and reference-to-video with adaptive, the output follows the input image’s aspect ratio; the output tier sets the total pixel count, not fixed dimensions. With this page’s 1:1 sample image, 720p returned 960×960 and 480p returned 640×640 in our tests. To get a fixed landscape or portrait frame, set output.aspect_ratio explicitly (wan2.7-i2v does not accept this field; use an input image with the ratio you need).

Sample media

The image-to-video and image-reference examples use a blue ceramic mug on a white table. Keep the sample image to try them, or first replace it with public HTTPS media that you have the right to use and that meets this page’s limits.

Video generation reference: a blue ceramic mug on a white table

The editing example uses a video of a boy in a city square, about 5.04 seconds, 1280 × 720, at 24 fps. It is supplied as base_video, not as a reference image.

Text-to-video

wan2.7-t2v

Use this operation when you have only a text description.

Set model to this subsection’s Model ID and operation to text_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoprovider_defaultprovider_default
duration.modestringNofixedfixed
duration.secondsintegerNo2–15, step 1 s; only for fixed duration5
output.aspect_ratiostringNo16:9, 9:16, 1:1, 4:3, 3:416:9
output.formatstringNomp4mp4
output.resolutionstringNo720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
driving_audioaudio, optional, at most 1wav, mp3size at most 15 MB; duration 2–30 s

Whether media is required also depends on the combination constraints below.

The optional driving_audio role supplies driving audio and uses type="audio". It is a different media role from reference_audio in reference generation.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan2.7-t2v",
"operation": "text_to_video",
"prompt": "A blue ceramic mug on a white table. Slowly move the camera closer in soft daylight.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "16:9"
}
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

wan3.0-video-prime

Use this operation when you have only a text description.

Set model to this subsection’s Model ID and operation to text_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoon, offon
duration.modestringNofixed, autofixed
duration.secondsintegerNo2–30, step 1 s; only for fixed duration5
output.aspect_ratiostringNoadaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16adaptive
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

This operation does not accept media.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Do not send duration.seconds when using duration.mode="auto".

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan3.0-video-prime",
"operation": "text_to_video",
"prompt": "A blue ceramic mug on a white table. Slowly move the camera closer in soft daylight.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "16:9"
}
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
excludesRemove fields that conflict with automatic duration or the last frame.

wan3.0-video

Use this operation when you have only a text description.

Set model to this subsection’s Model ID and operation to text_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoon, offon
duration.modestringNofixed, autofixed
duration.secondsintegerNo2–30, step 1 s; only for fixed duration5
output.aspect_ratiostringNoadaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16adaptive
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

This operation does not accept media.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Do not send duration.seconds when using duration.mode="auto".

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan3.0-video",
"operation": "text_to_video",
"prompt": "A blue ceramic mug on a white table. Slowly move the camera closer in soft daylight.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "16:9"
}
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
excludesRemove fields that conflict with automatic duration or the last frame.

Image-to-video

wan2.7-i2v

Use this operation to set the opening frame or both the first and last frames with images.

Set model to this subsection’s Model ID and operation to image_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoprovider_defaultprovider_default
duration.modestringNofixedfixed
duration.secondsintegerNo2–15, step 1 s; only for fixed duration5
output.formatstringNomp4mp4
output.resolutionstringNo720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
first_frameimage, 1 (required)jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px
last_frameimage, optional, at most 1jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px
driving_audioaudio, optional, at most 1wav, mp3size at most 15 MB; duration 2–30 s

Whether media is required also depends on the combination constraints below.

The optional driving_audio role supplies driving audio and uses type="audio". It is a different media role from reference_audio in reference generation.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • You must provide first_frame.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan2.7-i2v",
"operation": "image_to_video",
"prompt": "Slowly move the camera closer to the blue ceramic mug. Preserve its shape and the white table.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p"
},
"media": [
{
"id": "first",
"type": "image",
"role": "first_frame",
"source": "https://docs.bettertoken.ai/images/nano-banana-guide/sample-07.png"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

wan3.0-video-prime

Use this operation to set the opening frame or both the first and last frames with images.

Set model to this subsection’s Model ID and operation to image_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoon, offon
duration.modestringNofixed, autofixed
duration.secondsintegerNo2–30, step 1 s; only for fixed duration5
output.aspect_ratiostringNoadaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16adaptive
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
first_frameimage, 1 (required)jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px
last_frameimage, optional, at most 1jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px

Whether media is required also depends on the combination constraints below.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Do not send duration.seconds when using duration.mode="auto".
  • Provide at least one of these roles: first_frame, last_frame.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan3.0-video-prime",
"operation": "image_to_video",
"prompt": "Slowly move the camera closer to the blue ceramic mug. Preserve its shape and the white table.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "adaptive"
},
"media": [
{
"id": "first",
"type": "image",
"role": "first_frame",
"source": "https://docs.bettertoken.ai/images/nano-banana-guide/sample-07.png"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
excludesRemove fields that conflict with automatic duration or the last frame.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

wan3.0-video

Use this operation to set the opening frame or both the first and last frames with images.

Set model to this subsection’s Model ID and operation to image_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoon, offon
duration.modestringNofixed, autofixed
duration.secondsintegerNo2–30, step 1 s; only for fixed duration5
output.aspect_ratiostringNoadaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16adaptive
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
first_frameimage, 1 (required)jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px
last_frameimage, optional, at most 1jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px

Whether media is required also depends on the combination constraints below.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Do not send duration.seconds when using duration.mode="auto".
  • Provide at least one of these roles: first_frame, last_frame.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan3.0-video",
"operation": "image_to_video",
"prompt": "Slowly move the camera closer to the blue ceramic mug. Preserve its shape and the white table.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "adaptive"
},
"media": [
{
"id": "first",
"type": "image",
"role": "first_frame",
"source": "https://docs.bettertoken.ai/images/nano-banana-guide/sample-07.png"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
excludesRemove fields that conflict with automatic duration or the last frame.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

Reference generation

wan2.7-r2v

Use this operation to preserve subject or motion characteristics from reference media.

Set model to this subsection’s Model ID and operation to reference_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoprovider_defaultprovider_default
duration.modestringNofixedfixed
duration.secondsintegerNo2–15, step 1 s; only for fixed duration5
output.aspect_ratiostringNo16:9, 9:16, 1:1, 4:3, 3:416:9
output.formatstringNomp4mp4
output.resolutionstringNo720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
reference_imageimage, optional, at most 10jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px
reference_videovideo, optional, at most 5mp4, movsize at most 100 MB; width 240–4096 px; height 240–4096 px; duration 1–15 s; frame rate at least 16 fps; total for this role at most 15 s

Whether media is required also depends on the combination constraints below.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Provide at least one of these roles: reference_image, reference_video.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan2.7-r2v",
"operation": "reference_to_video",
"prompt": "Create a product video of the blue ceramic mug in the reference image. Keep its shape and color.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "16:9"
},
"media": [
{
"id": "reference",
"type": "image",
"role": "reference_image",
"source": "https://docs.bettertoken.ai/images/nano-banana-guide/sample-07.png"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

wan3.0-video-prime

Use this operation to preserve subject or motion characteristics from reference media.

Set model to this subsection’s Model ID and operation to reference_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoon, offon
duration.modestringNofixed, autofixed
duration.secondsintegerNo2–30, step 1 s; only for fixed duration5
output.aspect_ratiostringNoadaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16adaptive
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
reference_imageimage, optional, at most 10jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px
reference_videovideo, optional, at most 5mp4, movsize at most 100 MB; width 240–4096 px; height 240–4096 px; duration 1–15 s; frame rate at least 16 fps; total for this role at most 15 s
reference_audioaudio, optional, at most 5wav, mp3size at most 15 MB; duration 1–15 s; total for this role at most 15 s

Whether media is required also depends on the combination constraints below.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Do not send duration.seconds when using duration.mode="auto".
  • Provide at least one of these roles: reference_image, reference_video, reference_audio.
  • With reference video, the total input-video duration plus output duration must not exceed 30 seconds. Automatic output duration is also capped by this remaining allowance.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan3.0-video-prime",
"operation": "reference_to_video",
"prompt": "Create a product video of the blue ceramic mug in the reference image. Keep its shape and color.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "adaptive"
},
"media": [
{
"id": "reference",
"type": "image",
"role": "reference_image",
"source": "https://docs.bettertoken.ai/images/nano-banana-guide/sample-07.png"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
excludesRemove fields that conflict with automatic duration or the last frame.
sum_lteShorten the total reference-video duration or output duration so their sum does not exceed 30 seconds.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

wan3.0-video

Use this operation to preserve subject or motion characteristics from reference media.

Set model to this subsection’s Model ID and operation to reference_to_video. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoon, offon
duration.modestringNofixed, autofixed
duration.secondsintegerNo2–30, step 1 s; only for fixed duration5
output.aspect_ratiostringNoadaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16adaptive
output.formatstringNomp4mp4
output.resolutionstringNo480p, 720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
reference_imageimage, optional, at most 10jpeg, jpg, png, bmp, webpsize at most 20 MB; width 240–8000 px; height 240–8000 px
reference_videovideo, optional, at most 5mp4, movsize at most 100 MB; width 240–4096 px; height 240–4096 px; duration 1–15 s; frame rate at least 16 fps; total for this role at most 15 s
reference_audioaudio, optional, at most 5wav, mp3size at most 15 MB; duration 1–15 s; total for this role at most 15 s

Whether media is required also depends on the combination constraints below.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • Do not send duration.seconds when using duration.mode="auto".
  • Provide at least one of these roles: reference_image, reference_video, reference_audio.
  • With reference video, the total input-video duration plus output duration must not exceed 30 seconds. Automatic output duration is also capped by this remaining allowance.

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan3.0-video",
"operation": "reference_to_video",
"prompt": "Create a product video of the blue ceramic mug in the reference image. Keep its shape and color.",
"duration": {
"mode": "fixed",
"seconds": 5
},
"output": {
"resolution": "720p",
"aspect_ratio": "adaptive"
},
"media": [
{
"id": "reference",
"type": "image",
"role": "reference_image",
"source": "https://docs.bettertoken.ai/images/nano-banana-guide/sample-07.png"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
excludesRemove fields that conflict with automatic duration or the last frame.
sum_lteShorten the total reference-video duration or output duration so their sum does not exceed 30 seconds.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

Video editing

wan2.7-videoedit

Use this operation to change the visuals of an existing video. Prepare a source video that meets the limits first.

Set model to this subsection’s Model ID and operation to video_edit. Use only the generation fields listed below. Put media in the media array.

FieldTypeRequiredAllowed values or rangeDefault
audio.modestringNoprovider_defaultprovider_default
duration.modestringNofixed, autoauto
duration.secondsintegerNo2–15, step 1 s; only for fixed durationNone
output.formatstringNomp4mp4
output.resolutionstringNo720p, 1080p1080p
promptstringYesstringNone
provider_options.alibaba.prompt_extendbooleanNotrue / false; controls prompt expansiontrue
seedintegerNo0–2147483647, step 1; random seed; may be 0None
watermarkbooleanNofalse, truefalse

Media requirements

Media roleType and countFormatsPer-file limits
base_videovideo, 1 (required)mp4, movsize at most 100 MB; width 240–4096 px; height 240–4096 px; duration 1–15 s; frame rate at least 16 fps; total for this role at most 15 s

Whether media is required also depends on the combination constraints below.

Combination constraints

  • duration.mode="fixed" requires duration.seconds. Include the number of seconds whenever you explicitly set fixed.
  • You must provide base_video.
  • Do not send duration.seconds when using duration.mode="auto".

Request example

Save the JSON below as request.json, then follow the shared workflow to quote first and create after confirmation.

{
"model": "wan2.7-videoedit",
"operation": "video_edit",
"prompt": "Keep the boy and his motion in the source video. Give the city plaza warmer evening lighting.",
"duration": {
"mode": "auto"
},
"output": {
"resolution": "720p"
},
"media": [
{
"id": "base",
"type": "video",
"role": "base_video",
"source": "https://bettertoken.ai/video-api/shared/kling-hero-3.0.mp4"
}
]
}

Common 422 errors

422 error codeAction
enum / range / stepAdjust values and increments to match this subsection’s field table.
unsupported_fieldRemove fields absent from this operation’s field table.
requiresAdd seconds, aspect ratio, audio settings or media as required by this subsection’s combination constraints.
excludesRemove fields that conflict with automatic duration or the last frame.
count / media_roleAdjust roles and counts to match this subsection’s media table.
video_input_unsupportedCheck the public HTTPS URL, Content-Type and file format, then quote again.

Official resources

When calling BetterToken, use this page’s fields and the corresponding operation in the live model catalog.