建立 Flux 3 影片
從文字、參考圖片或首尾影格建立 Flux 3 影片,並使用 720p 或 1080p 尺寸預設集。
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
--form-string 'model=flux-3' \
--form-string 'prompt=A paper boat glides across a still pond while the camera moves forward.' \
--form-string 'seconds=5' \
--form-string 'size=1280x720'{
"id": "<task_id>",
"task_id": "<task_id>",
"object": "video",
"model": "flux-3",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}id,以輪詢工作並下載完成的影片。
POST /v1/videos 使用 multipart/form-data。請將控制項作為表單欄位傳送。對於圖片輸入,請使用參考圖片 URL 或開頭與結尾影格。
請將 input_reference 與 first_frame 及 last_frame 分開。
選擇輸入模式
| 目標 | 必要欄位 | 選用欄位 |
|---|---|---|
| 文字轉影片 | model=flux-3, prompt | seconds, size |
| HTTPS 圖片轉影片 | model=flux-3, prompt、一個 input_reference URL | seconds, size |
| 依序排列的關鍵影格 | model=flux-3, prompt、重複的 input_reference URL | seconds, size |
| 已上傳的開頭影格 | model=flux-3, prompt、一個 first_frame 檔案 | seconds, size |
| 首尾影格影片 | model=flux-3, prompt, first_frame, last_frame | seconds, size |
使用參考圖片
input_reference 欄位僅接受可公開存取的 HTTPS 圖片 URL。單一圖片請傳送一次;多張圖片則依關鍵影格順序重複傳送。每個欄位使用一個 URL,總計最多 10 個 URL。
描述生成影片應從參考圖片保留的動作、攝影機行為及視覺細節。
本頁頂端的請求範例顯示單張圖片與多張圖片輸入。以下請求依提交順序使用兩張圖片:
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
--form-string 'model=flux-3' \
--form-string 'prompt=Move smoothly through the supplied reference images in their given order. Preserve recognizable subjects and visual details as the scene changes. Keep the camera movement gentle.' \
--form-string 'seconds=5' \
--form-string 'size=1280x720' \
--form-string 'input_reference=https://apidoc.cometapi.com/images/image/gemini/6100640_569429.png' \
--form-string 'input_reference=https://apidoc.cometapi.com/images/image/gemini/6100640_569420.png'
設定首尾影格
傳送first_frame 以設定開頭圖片。若也要設定結尾圖片,請加入 last_frame,並在 prompt 中描述兩個影格之間的動作。
若僅使用開頭影格,請省略 last_frame。結尾影格需要同時提供 first_frame 和 last_frame。
每個欄位接受一個可公開存取的 HTTPS URL,或一個 PNG 或 JPEG 檔案。每個欄位僅傳送一次,可使用 URL 或檔案。每個檔案必須小於或等於 20 MiB(20 × 1024 × 1024 位元組).
本頁頂端的影格範例顯示 URL 輸入和檔案上傳,並明確設定 seconds 和 size。
設定時長與尺寸
將seconds 明確設為介於 5 到 20 的整數。
將 size 設為以下其中一個完全相符的 WxH 預設值:
| 解析度等級 | 尺寸 |
|---|---|
720p | 1280x720 |
1080p | 1920x1080 |
工作流程
建立工作
id。輪詢工作
status 為 completed 或 failed。下載結果
completed 時,呼叫 下載 Flux 3 影片內容 以儲存 MP4 檔案。主體
Flux 3 multipart request. Choose text, input_reference URLs, or first_frame and last_frame inputs. Keep reference-image and frame inputs separate.
Reference image URLs. Send one publicly accessible HTTPS image URL per input_reference field. For multiple images, repeat the field in keyframe order, up to 10 URLs. This field accepts URLs only. Keep it separate from first_frame and last_frame.
^https://Opening-frame image as one publicly accessible HTTPS URL or one PNG or JPEG file. Keep each file at or below 20 MiB (20 × 1024 × 1024 bytes). Send the field once, using either a URL or a file. Pair with last_frame to set both boundaries. Keep frame inputs separate from input_reference.
^https://Closing-frame image as one publicly accessible HTTPS URL or one PNG or JPEG file. Keep each file at or below 20 MiB (20 × 1024 × 1024 bytes). Send the field once, using either a URL or a file. To specify the closing image through this endpoint, send last_frame together with first_frame. Keep frame inputs separate from input_reference.
^https://回應
Task created. Store the returned id and poll GET /v1/videos/{task_id}.
curl \
https://api.cometapi.com/v1/videos \
-H "Authorization: Bearer $COMETAPI_KEY" \
--form-string 'model=flux-3' \
--form-string 'prompt=A paper boat glides across a still pond while the camera moves forward.' \
--form-string 'seconds=5' \
--form-string 'size=1280x720'{
"id": "<task_id>",
"task_id": "<task_id>",
"object": "video",
"model": "flux-3",
"status": "queued",
"progress": 0,
"created_at": 1779938152
}