LTX Video 圖片轉影片
使用 LTX 2.5 Fast 或 Pro,將來源圖片製作成影片。
概覽
使用圖像轉影片端點搭配支援的模型。使用回傳的 Task ID 擷取其狀態,或提供 callback_url 以接收下方說明的回呼通知。
快速入門
- 建立 API 金鑰並將其設定為 RUNAPI_API_KEY。
- 選擇支援的模型,並傳送本文符合該模型結構描述的 POST 請求。
- 儲存返回的任務 ID,然後輪詢直到終止狀態,或處理下方說明的回呼。
端點
- 基礎 URL
https://runapi.ai- API 版本
v1- 身分驗證
Authorization: Bearer YOUR_API_TOKEN
支援的模型
開啟模型頁面以查看目前的定價、速率限制及商業用途詳情。
請求綱要
欄位及允許值取決於所選模型。若提供 callback_url,其將接收下方記錄的 Task 交付內容。
ltx-2.5-fast-image-to-video8 個欄位
callback_urlstring用於接收任務最終結果的 RunAPI 回呼 URL。
duration_secondsinteger輸出時長,單位為秒。Fast 在 1440p 或 48/50 fps 時最長為 10 秒。
允許的值:6, 8, 10, 12, 14, 16, 18, 20
預設值: 10
fpsinteger每秒影格數。48/50 fps 時最長為 10 秒。影格率不影響每秒價格。
允許的值:24, 25, 48, 50
預設值: 24
modelstringLTX 2.5 模型識別碼。
output_resolutionstring輸出影片解析度。Fast 在 1440p 時最長為 10 秒。
允許的值:720p, 1080p, 1440p
預設值: 1080p
promptstring影片描述,長度為 1 至 5,000 個字元。
範圍:1 - 5000
seedinteger可選隨機種子。
範圍:0 - 2147483647
source_image_urlstring來源圖片的 HTTP(S) URL,支援 JPG、PNG 或 WEBP,檔案不超過 10 MB。供應商會驗證遠端檔案,並依圖片決定輸出長寬比。
ltx-2.5-pro-image-to-video8 個欄位
callback_urlstring用於接收任務最終結果的 RunAPI 回呼 URL。
duration_secondsinteger輸出時長,單位為秒,Pro 最長為 10 秒。
允許的值:6, 8, 10
預設值: 10
fpsinteger每秒影格數。48/50 fps 時最長為 10 秒。影格率不影響每秒價格。
允許的值:24, 25, 48, 50
預設值: 24
modelstringLTX 2.5 模型識別碼。
output_resolutionstring輸出影片解析度。
允許的值:720p, 1080p
預設值: 1080p
promptstring影片描述,長度為 1 至 5,000 個字元。
範圍:1 - 5000
seedinteger可選隨機種子。
範圍:0 - 2147483647
source_image_urlstring來源圖片的 HTTP(S) URL,支援 JPG、PNG 或 WEBP,檔案不超過 10 MB。供應商會驗證遠端檔案,並依圖片決定輸出長寬比。
條件規則
當所有列出的條件均符合時,這些需求即適用。
-
當
model = ltx-2.5-fast-image-to-video- 必填
- 不接受
aspect_ratio,source_audio_url
-
當
model = ltx-2.5-pro-image-to-video- 必填
- 不接受
aspect_ratio,source_audio_url
建立接受記錄
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
},
"task_replayed": {
"type": "boolean"
}
},
"required": [
"id",
"status"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"id": "tsk_reference_demo",
"status": "processing"
}
輪詢處理中
GET /api/v1/ltx_video/image_to_video/:id
回應綱要
{
"properties": {
"id": {
"type": "string"
},
"status": {
"enum": [
"processing"
],
"type": "string"
}
},
"required": [
"id",
"status"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"id": "tsk_reference_demo",
"status": "processing"
}
輪詢已完成
GET /api/v1/ltx_video/image_to_video/:id
回應綱要
{
"properties": {
"first_frame_image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"id": {
"type": "string"
},
"last_frame_image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"status": {
"enum": [
"completed"
],
"type": "string"
},
"usage": {
"properties": {
"cost": {
"type": "number"
}
},
"required": [
"cost"
],
"type": "object",
"unevaluatedProperties": false
},
"videos": {
"items": {
"properties": {
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
}
},
"required": [
"id",
"status",
"videos",
"usage"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"id": "tsk_reference_demo",
"status": "completed",
"usage": {
"cost": 0.05
},
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
輪詢失敗
GET /api/v1/ltx_video/image_to_video/:id
回應綱要
{
"properties": {
"error": {
"type": "string"
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Task processing failed.",
"id": "tsk_reference_demo",
"status": "failed"
}
客戶回呼:已完成
POST callback_url
回應綱要
{
"properties": {
"first_frame_image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"id": {
"type": "string"
},
"last_frame_image_url": {
"type": "string",
"x-runapi-generated-media": true
},
"status": {
"enum": [
"completed"
],
"type": "string"
},
"usage": {
"properties": {
"cost": {
"type": "number"
}
},
"required": [
"cost"
],
"type": "object",
"unevaluatedProperties": false
},
"videos": {
"items": {
"properties": {
"url": {
"type": "string",
"x-runapi-generated-media": true
}
},
"required": [
"url"
],
"type": "object",
"unevaluatedProperties": false
},
"type": "array"
}
},
"required": [
"id",
"status",
"videos",
"usage"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"id": "tsk_reference_demo",
"status": "completed",
"usage": {
"cost": 0.05
},
"videos": [
{
"url": "https://file.runapi.ai/reference-video.mp4"
}
]
}
客戶回呼:失敗
POST callback_url
回應綱要
{
"properties": {
"error": {
"oneOf": [
{
"type": "string"
},
{
"properties": {
"code": {
"type": "string"
},
"limit_cents": {
"type": "integer"
},
"message": {
"type": "string"
},
"reset_at": {
"format": "date-time",
"type": [
"string",
"null"
]
},
"used_cents": {
"type": "integer"
},
"window": {
"enum": [
"1h",
"1d",
"7d",
"daily",
"weekly",
"monthly",
"lifetime"
],
"type": "string"
}
},
"required": [
"code",
"message"
],
"type": "object",
"unevaluatedProperties": false
}
]
},
"id": {
"type": "string"
},
"status": {
"enum": [
"failed"
],
"type": "string"
}
},
"required": [
"id",
"status",
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": {
"code": "generation_failed",
"message": "Task processing failed."
},
"id": "tsk_reference_demo",
"status": "failed"
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Authentication required"
}
錯誤
GET /api/v1/ltx_video/image_to_video/:id
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Authentication required"
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"oneOf": [
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "人類可讀的驗證摘要。",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "以公開請求欄位為索引鍵的驗證訊息,每個欄位包含一組人類可讀的字串陣列。",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
回應範例
{
"error": "model must be one of: ltx-2.5-fast-image-to-video, ltx-2.5-pro-image-to-video"
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Insufficient balance"
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "API key credit limit exceeded"
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "The request uses features that are not supported for the selected model"
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Rate limit reached. Please retry later."
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Service under maintenance, please try again later"
}
錯誤
POST /api/v1/ltx_video/image_to_video
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "The request timed out"
}
錯誤
GET /api/v1/ltx_video/image_to_video/:id
回應綱要
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
{
"error": "Task with id 'tsk_reference_demo' not found"
}
產生的程式碼範例
直接使用 cURL,或為您的程式語言安裝 SDK。每個範例均會提交本參考中所示的已驗證請求。
安裝
pip install runapi-ltx-video
import os
from runapi.ltx_video import LtxVideoClient
client = LtxVideoClient(api_key=os.environ["RUNAPI_API_KEY"])
task = client.image_to_video.create(
model="ltx-2.5-fast-image-to-video",
prompt="The camera slowly moves forward.",
source_image_url="https://cdn.runapi.ai/public/samples/image.jpg",
output_resolution="720p",
duration_seconds=6,
fps=24
)