imagesarray必填
1-10 reference images (JPG/PNG, up to 30 MB, min 300 px, aspect ratio 2:5-5:2), referenced as @Image1, @Image2, ...
kwaivgi/kling-image/v4/editKling Image V4 Edit by Kuaishou edits or recomposes 1 to 10 reference images from a text instruction at native 2K, 4K or 8K resolution.
試用這個模型
PNG, JPEG, WebP, or GIF · 20 MiB maximum each · up to 10
選擇一個範例,將其輸入與結果載入 playground。
{
"aspect_ratio": "16:9",
"images": [
"https://static.sandbase.ai/examples/af741566-8852-406d-be61-8044f265442c/input/ceb31edd-5be2-40d9-a2fa-7be80bf0160b.png"
],
"prompt": "Place the sneaker from @Image1 on a mossy rock beside a mountain stream at dawn, soft mist, keep the shoe design, colours and the KITO heel tab exactly."
}{
"aspect_ratio": "16:9",
"images": [
"https://static.sandbase.ai/examples/2cfc80be-f125-4f18-8644-bedf004feb6a/input/5bcf3e54-96c8-4a0f-9e71-46b534bf8821.png",
"https://static.sandbase.ai/examples/2cfc80be-f125-4f18-8644-bedf004feb6a/input/0ff16182-a90d-475f-b0c5-f88b3a1c7dc0.png"
],
"prompt": "Create a luxury magazine advertisement: the watch dial from @Image1 fitted with the strap from @Image2, lying on black velvet, headline \"AUREL — Time, Enamelled\" in elegant serif type."
}Kling Image V4 Edit edits or recomposes 1–10 reference images from a text instruction, at native 2K, 4K or 8K.
| Field | Type | Default | Notes |
|---|---|---|---|
prompt | string, required | — | Refer to inputs as @Image1, @Image2, … |
images | image URL[], required | — | 1–10 images (JPG/PNG, up to 30 MB, at least 300 px per side, aspect ratio 2:5–5:2). |
aspect_ratio | auto / 16:9 / 9:16 / 1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 21:9 | auto | auto picks a shape from the prompt and references. |
resolution | 2K / 4K / 8K | 2K | Native output resolution. |
num_images | 1–9 | 1 | Independent images, each billed. |
Per output image by resolution, plus $0.003 per reference image.
| Request | Price |
|---|---|
| 1 reference, 2K (default) | $0.066 |
| 3 references, 4K | $0.103 |
| 1 reference, 8K | $0.160 |
| Failed runs are not charged. |
Other Kling Image V4 endpoints: kwaivgi/kling-image/v4, kwaivgi/kling-image/v4/edit, kwaivgi/kling-image/v4/long-image.
開始建置
透過 SandBase Unified Run API 提交此模型。
# The quoted heredoc keeps Unicode and shell metacharacters unchanged.
result=$(curl --fail-with-body --silent \
-X POST "https://api.sandbase.ai/v1/run" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'SANDBASE_JSON'
{
"model": "kwaivgi/kling-image/v4/edit",
"prompt": "Turn the scene in @Image1 into a snowy winter evening with warm window light, keep the composition.",
"num_images": 1,
"resolution": "2K",
"aspect_ratio": "auto"
}
SANDBASE_JSON
)
run_id=$(printf '%s' "$result" | jq -r .id)
for attempt in $(seq 1 120); do
status=$(printf '%s' "$result" | jq -r .status)
case "$status" in completed|failed|timeout) break ;; esac
sleep 2
result=$(curl --fail-with-body --silent \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
"https://api.sandbase.ai/v1/run/$run_id")
done
status=$(printf '%s' "$result" | jq -r .status)
[ "$status" = completed ] || { echo "Generation ended: $status" >&2; exit 1; }
printf '%s\n' "$result"建立 SandBase API 金鑰,並將其設定在伺服器環境中。所有請求都使用 Bearer 驗證。
export SANDBASE_API_KEY="YOUR_API_KEY"請將金鑰保留在伺服器端,不要在瀏覽器程式碼中公開,也不要提交到儲存庫。
使用此模型 ID 及其輸入,向 /v1/run 發送 POST。上方的請求範例包含提交與輪詢。
使用回傳的執行 ID 持續輪詢,直到狀態為 completed、failed 或 timeout。只有在 completed 之後才讀取輸出。
curl "https://api.sandbase.ai/v1/run/$RUN_ID" \
-H "Authorization: Bearer $SANDBASE_API_KEY"在模型的 image、video 或 audio 欄位中傳入可公開存取的檔案 URL。支援格式與限制會顯示在每個 Playground 輸入欄位旁。
在 Playground 中支援的圖片欄位上使用上傳或取代控制項。影片 URL 欄位可接受託管的 driving video;它們不代表支援影片上傳。
imagesarray必填1-10 reference images (JPG/PNG, up to 30 MB, min 300 px, aspect ratio 2:5-5:2), referenced as @Image1, @Image2, ...
promptstring必填Describe the image. Refer to reference images as @Image1, @Image2, ...
num_imagesintegerNumber of independent images to generate (1-9).
預設:1
最小值:1
最大值:9
resolutionstringOutput resolution. 8K is native ultra-high resolution.
預設:"2K"
可能值:"2K", "4K", "8K"
aspect_ratiostringOutput frame shape. auto picks one from the prompt and references.
預設:"auto"
可能值:"auto", "16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9"
{
"model": "kwaivgi/kling-image/v4/edit",
"prompt": "Turn the scene in @Image1 into a snowy winter evening with warm window light, keep the composition.",
"num_images": 1,
"resolution": "2K",
"aspect_ratio": "auto"
}已完成的執行會在輸出中顯示結果。以下為模型已儲存的範例,並非新的生成結果。
[
{
"url": "https://static.sandbase.ai/examples/af741566-8852-406d-be61-8044f265442c/output/b778d304-ecaa-4f46-b016-a6a435c5a075.png"
}
]