> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qingbo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Kling 4.0

> Text-to-video, first/last/keyframe animation, multimodal reference, editing and extension, always with stereo audio.

Text-to-video, first/last/keyframe animation, multimodal reference, editing and extension, always with stereo audio.

## Quick start

```bash theme={"system"}
curl -X POST https://api.qingbo.ai/v1/tasks \
  -H "Authorization: Bearer $WAVE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: kling-v4-example-001" \
  -d '{
  "model": "kling-v4",
  "action": "generate",
  "prompt": "A paper boat drifts slowly on a quiet pond, gentle water sounds",
  "duration": 3,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}'
```

Submission returns a task\_id. Use [`GET /v1/tasks/{task_id}`](https://docs.qingbo.dev/en/api-reference/task/status) to poll the result. Reference assets must use publicly downloadable URLs.

## Parameters

| Parameter | Type or values | Description |
| - | - | - |
| model | `kling-v4` | Exact model ID. |
| `action` | generate / edit / extend | generate selects a generation mode from the assets; edit edits a source video; extend continues it. |
| `prompt` | string | Required outside image-to-video. Reference assets using @Image1, @Video1 and @Audio1 in the prompt. |
| `duration` | integer | Required for generate/extend, 3–30 seconds. For edit, omitted or 0 uses the measured source duration rounded up to a whole second for reservation and settlement. For extension, this is the new-segment duration. |
| `resolution` | 720p / 1080p | Defaults to 720p. |
| `aspect_ratio` | 16:9 / 9:16 / 1:1 / 21:9 / auto | Reference generation supports auto; ordinary text generation defaults upstream to 16:9. Not accepted for extend. |
| `image_urls` | string\[] | 1–2 first/last frames for ordinary image-to-video; up to 10 references for reference mode or editing. |
| `image_with_roles` | object\[] | Up to 10 `{url, role}` entries: first\_frame, last\_frame, keyframe, middle\_frame or reference\_image. Image-to-video needs exactly one first frame and at most 8 keyframes. Use instead of image\_urls/first\_frame\_image/last\_frame\_image. |
| `first_frame_image / last_frame_image` | string | First/last-frame URLs; extend accepts only last\_frame\_image as a target end frame. |
| `video_urls` | string\[] | Up to 5 references for generate, exactly one source for edit/extend. URLs must be readable; this route requires at least one second per clip and at least three seconds for edit sources. Input videos must total no more than 30 seconds; trim longer source videos before submission. Billed input duration is also capped at 30 seconds. |
| `audio_urls` | string\[] | Up to 3 reference clips for generate, each 5–30 seconds. Images, videos and audio together must total at most 15 reference assets. |
| `omni_reference_task_type` | auto / reference | Only for generate, default auto. Use reference explicitly for image-only reference generation. edit/extend modes are fixed by action. |
| `audio_setting` | origin / auto | Available for editing or video-reference generation: origin preserves video sound, auto creates new sound. Not accepted for extend. |
| `generate_audio` | true | Always with sound; false is rejected before reservation. |
| `watermark` | false | Enabling watermark is unsupported. |

Legacy mode, negative\_prompt, multi\_shot, multi\_prompt, element\_list, video\_list, camera\_control and voice\_list are unsupported. Input videos must be directly readable and at least one second long. Image roles and combined assets must also satisfy supplier validation.

## Edit a video

```json theme={"system"}
{
  "model": "kling-v4",
  "action": "edit",
  "prompt": "Change the scene to warm sunset light, keeping the boat.",
  "video_urls": [
    "https://cdn.example.com/source.mp4"
  ],
  "duration": 3,
  "resolution": "720p"
}
```

## Extend a video

```json theme={"system"}
{
  "model": "kling-v4",
  "action": "extend",
  "prompt": "Continue the boat drifting slowly on the pond.",
  "video_urls": [
    "https://cdn.example.com/source.mp4"
  ],
  "duration": 3,
  "resolution": "720p"
}
```

## Billing and results

Fixed per-second prices apply. Reservation and settlement use the tariff and measured media facts frozen at submission. Ordinary generation bills output seconds; extension bills only the new segment. Editing and video-reference generation bill output seconds + max(output seconds, billed input seconds). Raw input clip durations are summed, rounded up once, then capped at 30 seconds. Failed video probes are rejected before reservation.

| Mode | 720p (USD / second) | 1080p (USD / second) |
| - | - | - |
| Ordinary generation / extension segment | \$0.1575 | \$0.23625 |
| Billable seconds for editing / video-reference generation | \$0.0945 | \$0.14175 |

When editing with omitted `duration` or 0, the measured source duration rounded up determines both reservation and settlement, without a 30-second upper-bound hold. A 3.04-second source produces 4 billable output seconds: 4 + max(4, 4) = 8 seconds, so both the 720p reservation and successful charge are \$0.756. Container tail-frame padding does not add another billable second. Existing tasks retain their frozen tariff.

Read current rates in the model market or price\_config from GET /v1/models. Images are in result.images and videos in result.videos; url is an array. Failed or cancelled tasks receive a full reservation refund. Read final cost in integer quota (500,000 quota = 1 USD) and confirm billing\_status is settled.

For callbacks, waiting, idempotency and spending limits, see [Submit a task](https://docs.qingbo.dev/en/api-reference/task/submit.md)。


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