↓
Rivya AI 文件
模型 API 接入文件

Kling 4.0 Flash API 接入文件

透過 Rivya Public API v1 呼叫 Kling 4.0 Flash,包含模型 ID kling-4-0-flash、輸入類型、參數、Files API 規則、點數和回應範例。

API 可呼叫文字或 URL 可用;參考模式使用 Files API影片
API 模型 ID

kling-4-0-flash

輸入類型

text, file

Files API

參考素材模式需要

基礎點數

點數費率: 17 / 秒輸出 任務最終用量會向上取整為整數點數。

能力類型

影片

計費方式

METERED

Prompt 上限

8000 字元

請求欄位

模型 ID 放在頂層欄位。模型專屬控制項放入 params。

Key類型必填預設值說明
modelstring是kling-4-0-flash使用 kling-4-0-flash 作為 API 模型 ID。
promptstring是-這個模型最多 8000 個字元。
paramsobject否-模型專屬參數物件。可用 keys 請見下方參數表。
client_request_idstring否-可選的用戶端請求 ID,方便你在自己的系統中追蹤請求。

模型參數

Key類型必填預設值範圍選項說明
kling4_sceneselect否keyframe-keyframe, reference輸入模式
resolutionselect否720p-720p解析度
durationnumber否5min 3 / max 20 / step 1-時長(秒)
aspect_ratioselect否16:9-16:9, 9:16, 1:1, 21:9長寬比

上傳策略

先上傳參考文件,再把回傳的 URL 和 durationToken 放入 params.referenceMediaItems。

參考素材規則

參考圖片: 選擇首幀模式,透過文字或一張首幀圖產生影片;選擇參考模式,可使用文字或最多 10 張參考圖。時長為 3–20 秒,解析度為 720p。用 @first_frame 或 @image_1、@image_2 引用已提供的圖片。此處暫不支援參考影片、命名主體、音色以及中間幀或尾幀。

最大文件數

10

支援文件類型

image

時長 Token

影片和音訊參考素材需要時長驗證時,應攜帶 /api/v1/files 回傳的 durationToken。

kind大小上限MIME 類型
image10 MBimage/jpeg, image/png, image/webp

最小請求

{
  "model": "kling-4-0-flash",
  "prompt": "鏡頭緩慢環繞攝影棚桌面上的產品瓶。",
  "params": {
    "kling4_scene": "keyframe",
    "resolution": "720p",
    "duration": 5,
    "aspect_ratio": "16:9"
  }
}

參考文件請求

{
  "model": "kling-4-0-flash",
  "prompt": "鏡頭緩慢環繞攝影棚桌面上的產品瓶。",
  "params": {
    "kling4_scene": "keyframe",
    "resolution": "720p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "referenceMediaItems": [
      {
        "url": "https://cdn.example.com/reference-image.png",
        "kind": "image",
        "name": "reference-image.png",
        "mimeType": "image/png",
        "width": 1024,
        "height": 1024,
        "sizeBytes": 1048576,
        "imageDimensionsToken": "image_dimensions_token_from_original_files_api_upload_response"
      }
    ]
  }
}

建立回應

建立 endpoint 會回傳公開 task id。繼續輪詢狀態 endpoint,直到任務成功或失敗。

{
  "id": "task_kling_4_0_flash_example",
  "status": "queued",
  "model": "kling-4-0-flash",
  "reserved_credits": 85,
  "final_credits": 0,
  "settlement_status": "RESERVED",
  "created_at": "2026-05-11T00:00:00.000Z",
  "updated_at": "2026-05-11T00:00:00.000Z",
  "result": null,
  "error": null
}

常見錯誤

validation_failed, insufficient_credits, idempotency_conflict, rate_limited, not_found

部分模式需要透過 Files API 上傳參考素材。