Video Edit
Change an existing video as your prompt says, optionally with reference images and videos (Kling 4.0 Flash video_edit).
Kling 4.0 Flash changes an existing video as your prompt says, for example replacing an object or changing the style, optionally with reference images and reference videos.
Create a task
https://api.nanoapi.ai/v1/tasksUse the shared create endpoint with model: "kling-4.0-flash" and mode: "video_edit".
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <API key>, see Authentication. |
Content-Type | Yes | application/json |
Idempotency-Key | No | A unique string for every new task, ideally a UUID (1–255 characters). See Preventing duplicate tasks. |
Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | kling-4.0-flash |
mode | string | Yes | video_edit |
video_url | string | Yes | The video to edit: 3–30 seconds, 720p or higher (at least 720 pixels on its short side), aspect ratio at most 2.5:1. See Media. |
prompt | string | Yes | How to change it, at most 8000 characters. Refer to the files as @Video1 (the video to edit), @Video2 on (the reference videos) and @Image1 on, see Referring to files. |
image_urls | string[] | No | Up to 10 reference images (for example the object to put in). See Media. |
video_urls | string[] | No | Up to 4 reference videos (for example the moves to copy). Each 3–30 seconds, 720p or higher, aspect ratio at most 2.5:1; together with video_url at most 30 seconds, so a 30-second video_url can't carry any. See Media. |
aspect_ratio | string | Yes | auto, 21:9, 16:9, 9:16 or 1:1. auto follows the video you edit. |
resolution | string | Yes | 720p. |
duration | integer | No | Output length in seconds, 3–20. Billed per second, see Pricing. When you send it, it alone sets the output length, however long the video you edit is. Leave it out and the output follows the video you edit, see Without duration. |
webhook_url | string | No | Notified when the task succeeds or fails: https, up to 2048 characters, not a private, loopback or reserved address. See Webhooks. |
Without duration
- Output length: the length of the video you edit (the longer of its video and audio tracks), rounded up to a whole second; less than 0.05 seconds over doesn't count (10.02 s gives 10 seconds, 10.06 s gives 11). At most 20 seconds: a longer video gives 20 seconds.
- Billing: 20 × the price per second is frozen first; when the task succeeds, the actual output length is charged and the rest returned, see Pricing.
- Balance: your available balance must cover the 20 seconds (and so must the API key's spend limits), even if the video is shorter; otherwise the task fails with
insufficient_balance(orspend_limit_exceeded). Senddurationto freeze only what you ask for.
Replace the car with the one in the reference image, 8 seconds:
curl https://api.nanoapi.ai/v1/tasks \
-H "Authorization: Bearer $NANOAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-4.0-flash",
"mode": "video_edit",
"video_url": "https://example.com/source.mp4",
"image_urls": ["https://example.com/ref.jpg"],
"prompt": "Replace the car with the one in the reference image",
"aspect_ratio": "auto",
"resolution": "720p",
"duration": 8
}'With a reference video and no duration (the output follows the video you edit):
curl https://api.nanoapi.ai/v1/tasks \
-H "Authorization: Bearer $NANOAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-4.0-flash",
"mode": "video_edit",
"video_url": "https://example.com/main.mp4",
"video_urls": ["https://example.com/dance.mp4"],
"prompt": "Edit @Video1: make her move like the dancer in @Video2",
"aspect_ratio": "auto",
"resolution": "720p"
}'Response: 200 OK, the new task (fields). Keep data.id to get the result; the task can still fail, see Errors.
{
"code": 200,
"message": "success",
"data": {
"object": "task",
"id": "tk_01jbm3r8x5c2v9b6n4q7w1e3t5",
"model": "kling-4.0-flash",
"status": "queued",
"error": null,
"created_at": "2026-11-18T08:30:00Z"
}
}Pricing
cost = duration × price per secondLoading the current prices…
Without duration (the second request above), 20 × the price per second is frozen first. When the task succeeds, the output length × the price per second is charged and the rest returned: for an 11-second video, 11 seconds are charged and 9 returned. billing.billed_seconds is then the output length.
Billed seconds are the duration you ask for, however long the video you edit is; without duration, the output length. All Kling 4.0 Flash prices: Kling 4.0 Flash → Pricing. Current prices: GET /v1/products (product kling_flash, the prices row whose mode is video_edit). The task's billing.frozen is the amount that counts; freezing and charging: Billing.
Errors
See Kling 4.0 Flash → Errors. This mode's parameter rules are in the table above.
Reference to Video
Put the people, objects or scenes in your images into a new video, optionally guided by reference videos (Kling 4.0 Flash reference_to_video).
Seedance 2.5
Generate a video with sound from a prompt, frames or reference images, videos and audio, or edit or extend a video, billed by the output length.