Kling 4.0 Reference to Video
整合
模型 id
kling/v4/reference-to-video
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://vit.doitong.com/api/v1/run/kling/v4/reference-to-video?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://vit.doitong.com/api/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://vit.doitong.com/api/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/kling/v4/reference-to-video?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://vit.doitong.com/api/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/kling/v4/reference-to-video", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
# 1. Connect once (Claude Code; Cursor, VS Code, Claude Desktop: https://doitong.com/zh-TW/developers/docs/mcp)
claude mcp add --transport http doitong-models https://vit.doitong.com/api/v1/mcp \
--header "Authorization: Bearer $DOITONG_API_KEY"
# 2. Your agent calls the "run" tool with:
{
"model_id": "kling/v4/reference-to-video",
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
}
透過 Doitong API 呼叫 Kling 4.0 Reference to Video 模型(kling/v4/reference-to-video)。代理程式文件:https://doitong.com/zh-TW/developers/models/kling/v4/reference-to-video.md
POST https://vit.doitong.com/api/v1/run/kling/v4/reference-to-video?wait=20
Authorization: Bearer $DOITONG_API_KEY
Content-Type: application/json
{
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}
如果回應狀態為 "queued" 或 "running",請輪詢 GET https://vit.doitong.com/api/v1/requests/REQUEST_ID?wait=20,直到狀態變為 "succeeded";檔案位於 outputs[].url。使用相同主體傳送 POST https://vit.doitong.com/api/v1/quote/kling/v4/reference-to-video,可在執行前取得確切價格。
像範例一樣的檔案: $1.175 1,175 API 點數 您的檔案會在執行前計量 在此頁面執行
您的新 API 金鑰。 僅會在此時顯示,且已填入下方的程式碼與 API 金鑰欄位。請妥善保密:切勿將其放入在瀏覽器中執行的程式碼。
建立請求
控制項是根據模型結構描述生成的。變更設定時,程式碼和價格會同步更新。
POST
/run/kling/v4/reference-to-video?wait=20
報價 → $1.175
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://vit.doitong.com/api/v1/run/kling/v4/reference-to-video?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}'
# Still "queued" or "running"? Poll with the id from the response:
curl "https://vit.doitong.com/api/v1/requests/REQUEST_ID?wait=20" \
-H "Authorization: Bearer $DOITONG_API_KEY"
const API = "https://vit.doitong.com/api/v1";
const headers = {
"Authorization": "Bearer " + process.env.DOITONG_API_KEY,
"Content-Type": "application/json",
};
// Run the model; wait up to 20 s for the finished result in the same call
let res = await fetch(API + "/run/kling/v4/reference-to-video?wait=20", {
method: "POST",
headers,
body: JSON.stringify({
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
}),
});
let request = await res.json();
if (!res.ok) throw new Error(request.error.code + ": " + request.error.message);
// Not finished yet: long-poll until it is
while (request.status === "queued" || request.status === "running") {
res = await fetch(API + "/requests/" + request.id + "?wait=20", { headers });
request = await res.json();
}
if (request.status !== "succeeded") throw new Error(JSON.stringify(request.error));
console.log(request.outputs.map((o) => o.url), request.cost.credits + " API credits ($" + request.cost.usd + ")");
import os
import requests
API = "https://vit.doitong.com/api/v1"
headers = {"Authorization": "Bearer " + os.environ["DOITONG_API_KEY"]}
payload = {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field",
}
# Run the model; wait up to 20 s for the finished result in the same call
r = requests.post(API + "/run/kling/v4/reference-to-video", params={"wait": 20}, json=payload, headers=headers)
request = r.json()
if not r.ok:
raise RuntimeError(request["error"]["code"] + ": " + request["error"]["message"])
# Not finished yet: long-poll until it is
while request["status"] in ("queued", "running"):
request = requests.get(API + "/requests/" + request["id"], params={"wait": 20}, headers=headers).json()
if request["status"] != "succeeded":
raise RuntimeError(request["error"])
print([o["url"] for o in request["outputs"]], request["cost"]["credits"], "API credits", "$" + request["cost"]["usd"])
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "run",
"arguments": {
"model_id": "kling/v4/reference-to-video",
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
},
"wait_seconds": 20
}
}
}
關於 Kling 4.0 Reference to Video
從文字 `prompt` 加上參考圖像、參考影片及角色或物件元素建立影片;這些元素會在提示詞中以 @Image1、@Video1 或 @Element1 引用。長度為 3 至 30 秒(預設 5),輸出為 720p 或 1080p,長寬比可為 auto、16:9、9:16、1:1 或 21:9。使用 `multi_prompt` 可為每個鏡頭指定提示詞,此時總長度為各鏡頭長度之和。限制為 10 張圖像、5 部各 3-30s 的影片,以及 7 個元素,其中最多 3 個可帶有語音。
參數
請傳送標準名稱或原生名稱其中之一,不要同時傳送兩者。 標準名稱
名稱類型
預設值允許值
說明
prompt選填
類型string | null
≤ 2,500 個字元
符合必須提供 `prompt` 或 `multi_prompt` 要求的生成指示。若要引用提供的輸入,請使用 @Image1、@Video1、@Element1 等。
multi_prompt選填
類型object[]
逐鏡頭生成指示,每個提示詞定義一個鏡頭,其時長會計入影片總長度。
multi_prompt[].prompt必填
類型string
1 – 512 characters
目前鏡頭的文字指示。
multi_prompt[].duration選填
類型integer
預設值5
1 – 30
個別鏡頭的時長,以秒為單位。
duration選填
類型integer
預設值5
3 – 30
影片長度,以秒為單位,介於 3 到 30 之間。
start_image_url選填
image
類型url · image
選用的第一影格圖像,會計入圖像參考上限。檔案大小上限為 30.0 MB;寬度和高度各必須達到 300 px,寬高比介於 0.40 和 2.50 之間。
image_urls選填
images
類型url[] · image
≤ 10 個項目
使用 @Image1、@Image2 等引用的圖像參考,最多 10 張圖像。每個檔案限制為 30.0 MB,兩個尺寸至少為 300 px,寬高比必須介於 0.40 和 2.50 之間。
video_urls選填
videos
類型url[] · video
≤ 5 個項目
最多 5 部參考影片,使用 @Video1、@Video2 等引用;每部長度為 3–30 秒(最多 30.05 秒),其總長度與元素影片合計不得超過 30 秒。每個檔案不得大於 300 MB,寬度和高度各介於 700 px 和 4553 px 之間。寬高比必須介於 0.40 和 2.50 之間,影格率介於 23.9 和 60.05 FPS 之間。
elements選填
類型object[]
≤ 7 個項目
最多 7 個角色或物件的集合,其中最多 3 個可包含 `voice_id`,最多 3 個可使用影片。請以 @Element1、@Element2 等引用這些元素。
elements[].frontal_image_url選填
類型url · image
顯示元素主要視角的正面圖像。檔案大小上限為 30.0 MB;兩個尺寸都必須至少為 300 px,寬高比必須介於 0.40 和 2.50 之間。
elements[].reference_image_urls選填
類型url[] · image
≤ 3 items
顯示元素不同角度的補充圖像,提供 1 到 3 個視角。每個檔案最多 30.0 MB,兩個尺寸至少為 300 px,寬高比必須介於 0.40 和 2.50 之間。
elements[].video_url選填
類型url · video
以影片取代圖像呈現元素,長度為 3–30 秒(最多 30.05 秒)。檔案不得超過 300 MB;寬度和高度都必須介於 700–4553 px 之間。支援的寬高比為 0.40–2.50,影格率為 23.9–60.05 FPS。
elements[].voice_id選填
類型string | null
指派給元素的語音。
resolution選填
類型enum
預設值1080p
720p1080p
輸出的解析度。
aspect_ratio選填
類型enum
預設值16:9
auto16:99:161:121:9
影片比例,可明確選取,或選擇 'auto' 根據參考內容推導。
必填
標準名稱,也可使用
檔案參數接受公開的 https:// URL、最大 10 MB 的 data: URI,或上傳檔案的 file_url。 檔案
輸出
GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
"id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
"object": "request",
"model": "kling/v4/reference-to-video",
"status": "succeeded",
"created_at": "2026-10-20T12:00:00Z",
"started_at": "2026-10-20T12:00:02Z",
"completed_at": "2026-10-20T12:00:09Z",
"queue_position": null,
"cost": {
"credits": 1175,
"usd": "1.175",
"charged": 1175,
"refunded": 0
},
"input": {
"prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
},
"output": {
"video": {
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.mp4",
"content_type": "video/mp4",
"file_name": "0-output.mp4",
"file_size": 1843200
}
},
"outputs": [
{
"type": "video",
"url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.mp4",
"content_type": "video/mp4",
"file_size": 1843200,
"width": 1280,
"height": 720,
"duration": 5,
"stored": true
}
],
"error": null,
"metrics": {
"inference_seconds": 6.8
},
"urls": {
"self": "https://vit.doitong.com/api/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
"cancel": "https://vit.doitong.com/api/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
}
}
您的檔案,由您選擇每個 outputs[].url 都是儲存空間中的副本:可永久保留(按 GB-月計費),或免費保留 7 天;可透過帳戶設定或 ?storage= 設定。
所有模型使用相同結構圖片、影片和音訊皆包含 type、url、content_type、width、height 和 duration。output 是模型自己的結果物件。
輸出欄位
- video
- object {url, content_type, file_name, file_size}模型產生的影片。
其他 Kling 4.0 變體
更多模型:參考圖轉影片
給 AI 代理程式:此頁面的 Markdown 位於 https://doitong.com/zh-TW/developers/models/kling/v4/reference-to-video.md. 所有模型與指南: https://doitong.com/developers/llms.txt