Kling 4.0 Reference to Video
kwaivgi/kling-v4.0/reference-to-video
Generate 3–30 second videos using image, video and audio references, with native prompt references and 720p or 1080p output.
Examples
Parameters
| Name | Type | Default | Constraints | Description |
|---|---|---|---|---|
| prompt *Prompt | textarea | — | ≤ 5000 chars | The positive prompt for the generation. Refer to reference images as @Image1, @Image2, ... (in array order), to reference videos as @Video1, @Video2, ... and to reference audios as @Audio1, @Audio2, ... |
| imagesReference images | image_upload | — | image/* · 0–10 items | Reference images (up to 10). |
| audiosReference audio | audio_upload_group | — | audio/* · 0–3 items | Up to 3 reference audio clips, 5–30 seconds each, to guide the voice and sound. |
| keep_original_soundKeep original sound | boolean | false | — | Keep the reference video's original sound. Requires a reference video; otherwise new audio is generated. |
| resolutionResolution | select | 720p | 720p | 1080p | Output resolution. |
| durationDuration | select | 5 | 3 ~ 30 · step 1 · 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | … | The duration of the generated video in seconds (3-30). |
| aspect_ratioAspect ratio | select | auto | auto | 16:9 | 9:16 | 1:1 | 21:9 | Output aspect ratio. Auto follows the reference images or video. |
Output fields
| Field | Type | Description |
|---|---|---|
| videos | array<string> | Generated video URLs. |
API
Call this model through one unified REST API. Get a key on the API Keys page.
cURL
# 1) Submit — returns { "task_uuid": "..." }
curl -X POST "https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/reference-to-video" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A cinematic portrait, dramatic rim light, shallow depth of field",
"keep_original_sound": false,
"resolution": "720p",
"duration": 5,
"aspect_ratio": "auto"
}
}'
# 2) Poll until status is "completed", then read the output URLs
curl "https://www.namifusion.com/api/v1/marketplace/run/tasks/TASK_UUID" \
-H "Authorization: Bearer YOUR_API_KEY"Python
import time, requests
API_KEY = "YOUR_API_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
# 1) Submit
resp = requests.post(
"https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/reference-to-video",
headers=HEADERS,
json={
"input": {
"prompt": "A cinematic portrait, dramatic rim light, shallow depth of field",
"keep_original_sound": False,
"resolution": "720p",
"duration": 5,
"aspect_ratio": "auto"
}
},
)
resp.raise_for_status() # 401/402/429/5xx stop here instead of polling a bad task
task = resp.json()
# 2) Poll until a terminal state (completed / failed / cancelled).
# This model is allowed up to 1800s server-side.
deadline = time.time() + 1860
while task.get("status") not in ("completed", "failed", "cancelled"):
if time.time() > deadline:
raise TimeoutError(f"still {task.get('status')} — keep the task_uuid and poll later")
time.sleep(3)
poll = requests.get(f"https://www.namifusion.com/api/v1/marketplace/run/tasks/{task['task_uuid']}", headers=HEADERS)
poll.raise_for_status()
task = poll.json()
print(task["status"], task.get("output"))JavaScript
const API_KEY = "YOUR_API_KEY";
const HEADERS = { Authorization: `Bearer ${API_KEY}` };
// 1) Submit
const resp = await fetch("https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/reference-to-video", {
method: "POST",
headers: { ...HEADERS, "Content-Type": "application/json" },
body: JSON.stringify({
"input": {
"prompt": "A cinematic portrait, dramatic rim light, shallow depth of field",
"keep_original_sound": false,
"resolution": "720p",
"duration": 5,
"aspect_ratio": "auto"
}
}),
});
if (!resp.ok) throw new Error(`submit failed: ${resp.status} ${await resp.text()}`);
let task = await resp.json();
// 2) Poll until a terminal state (completed / failed / cancelled).
// This model is allowed up to 1800s server-side.
const deadline = Date.now() + 1860 * 1000;
while (!["completed", "failed", "cancelled"].includes(task.status)) {
if (Date.now() > deadline) throw new Error(`still ${task.status} — keep the task_uuid and poll later`);
await new Promise((r) => setTimeout(r, 3000));
const poll = await fetch(`https://www.namifusion.com/api/v1/marketplace/run/tasks/${task.task_uuid}`, { headers: HEADERS });
if (!poll.ok) throw new Error(`poll failed: ${poll.status}`);
task = await poll.json();
}
console.log(task.status, task.output);Documentation
Kling 4.0 · Reference to Video
Create a new 3–30 second video from a prompt with optional image, video and audio references. Output duration is chosen independently of reference-video duration.
Inputs
- prompt: required string.
- images: optional image-URL array, at most 10.
- videos: optional video-URL array, at most 5. Each source must be at least 3 seconds; at most 30 seconds of video is used in total.
- audios: optional audio-URL array, at most 3; each clip must be 5–30 seconds.
- keep_original_sound: boolean, default false. Set true to preserve reference-video audio; requires videos.
- resolution: "720p" (default) or "1080p".
- duration: integer from 3 through 30, default 5.
- aspect_ratio: "auto" (default), "16:9", "9:16", "1:1" or "21:9".
Limits and references
Use at most 15 reference files across images, videos and audios. Longer source footage is trimmed to the 30-second total budget. In prompt, @Image1, @Video1 and @Audio1 refer to the first item in their respective arrays; numbering starts at 1 separately for each media type. Explain the role of each reference.
List price and initial credit charge
| Input video | 720p | 1080p | Billing basis |
|---|---|---|---|
| None | $0.157 | $0.235 | Per output second |
| Present | $0.094 | $0.141 | Per counted second |
Without reference video: Cost = output seconds × resolution rate. A 5-second clip costs $0.785 at 720p or $1.175 at 1080p.
Let D be output seconds and V = ceil(min(total input-video seconds, 30)). With video input, cost = rate × (D + max(D, V)). At 720p, D=5 and an 8.2-second input give V=9 and a cost of $1.316; the initial charge is 131.60 credits.
1 USD = 100 Nami credits. Round the total charge upward to 0.01 credit: credits = ceil(cost_usd × 10000) / 100. These are list prices; no promotional discount is applied.
Images, reference audio, aspect ratio and audio-preservation settings add no separate charge under this formula.
MaaS mapping
images, videos and audios remain URL arrays in MaaS. Never send videos as a single string. All other named fields retain their names in MaaS. Send duration as an integer and keep_original_sound as a boolean where supported. Array order is preserved.
Nami API
Send a POST request with Authorization: Bearer YOUR_NAMI_API_KEY and Content-Type: application/json to:
https://www.namifusion.com/api/v1/marketplace/run/kwaivgi/kling-v4.0/reference-to-video
Example request body:
{
"input": {
"prompt": "Use the person from @Image1, follow the camera movement of @Video1, and use @Audio1 as the voice reference. The person greets the viewer in a quiet studio.",
"images": [
"https://example.com/person.jpg"
],
"videos": [
"https://example.com/camera-reference.mp4"
],
"audios": [
"https://example.com/voice-reference.mp3"
],
"keep_original_sound": false,
"resolution": "720p",
"duration": 5,
"aspect_ratio": "auto"
}
}
Replace example.com URLs with publicly accessible media URLs. Use the returned task_uuid to poll GET https://www.namifusion.com/api/v1/marketplace/run/tasks/{task_uuid} with the same authorization. On success, read generated video URLs from output.videos.
Related models
xAI Grok Imagine Video v1.5 Reference to Video
Generate a 1-15 second video from a prompt and 1-7 reference images at 480p or 720p.
Vidu Q4 Preview Reference to Video
Generate a 3–16 second video from a prompt with optional references: up to 15 images and 3 audio clips. Supports aspect ratio selection, audio generation and 540p–4k resolution.
MiniMax H3 Reference to Video
MiniMax H3 Reference to Video generates coherent 2K videos from natural-language prompts and multimodal references, including images, videos, and audio, guiding subject consistency, motion, timing, visual style, and scene continuity. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
MiniMax H3 Singularity Reference-to-Video LoRA
Generate videos with native stereo audio, 3–15 second durations and four resolution tiers. Supports custom LoRAs.
MiniMax H3 Singularity Reference-to-Video
Generate videos with native stereo audio, 3–15 second durations and four resolution tiers.
Gemini Omni Flash Reference to Video API
Gemini Omni Flash Reference to Video creates short AI videos with synchronized audio from one or more reference images and a text prompt, preserving visual identity and following the provided references for guided multimodal video generation. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Seedance 2.0 Mini Reference to Video
Seedance 2.0 Mini Reference-to-Video is a high-speed, cost-effective video generation model developed by ByteDance, engineered specifically for creating multi-shot videos with a cinematic feel. By seamlessly combining reference images with text prompts, it generates highly narrative video segments. The model features advanced AI camera control and ensures robust character consistency across different scenes. It supports multiple output resolutions from 480P up to 4K, durations ranging from 4 to 15 seconds, and flexible aspect ratios. Complete with an out-of-the-box REST inference API, it delivers exceptional performance with zero cold starts, offering an affordable yet premium solution for professional video creation.
Seedance 2.5 Reference to Video
The "Reference-to-Video" feature of Seedance 2.5 is the ultimate solution for visual stylistic unity. It precisely extracts artistic styles, lighting tones, or compositional intents from reference materials and seamlessly integrates them into newly generated videos, ensuring a highly consistent visual language for your creative series.