curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-video-1.5",
"prompt": "將這張產品圖生成電影感商業視頻,輕微鏡頭推進",
"image": "https://example.com/product.jpg",
"duration": 10,
"aspect_ratio": "16:9"
}'
import requests
task = requests.post(
"https://toapis.com/v1/videos/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "grok-video-1.5",
"prompt": "將這張產品圖生成電影感商業視頻",
"image": "https://example.com/product.jpg",
"duration": 15,
"aspect_ratio": "16:9",
},
).json()
print(task["id"])
{
"id": "video_abc123def456",
"object": "generation.task",
"model": "grok-video-1.5",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
Grok Video
Grok Video 1.5 視頻生成
使用 grok-video-1.5 從單張必填首圖生成視頻
POST
/
v1
/
videos
/
generations
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-video-1.5",
"prompt": "將這張產品圖生成電影感商業視頻,輕微鏡頭推進",
"image": "https://example.com/product.jpg",
"duration": 10,
"aspect_ratio": "16:9"
}'
import requests
task = requests.post(
"https://toapis.com/v1/videos/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "grok-video-1.5",
"prompt": "將這張產品圖生成電影感商業視頻",
"image": "https://example.com/product.jpg",
"duration": 15,
"aspect_ratio": "16:9",
},
).json()
print(task["id"])
{
"id": "video_abc123def456",
"object": "generation.task",
"model": "grok-video-1.5",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
中國大陸用戶請注意: 中國大陸用戶請使用
https://toapis.cn 作為接口地址(Base URL)。文檔示例中的 https://toapis.com 請替換為 https://toapis.cn。- 僅支持圖生視頻,不支持文生視頻。
- 必須且只能傳入 1 張公網首圖。
- 視頻時長支持
1–15秒,默認8秒。 - 支持
480p和720p。 - 異步任務 API:提交後使用任務 ID 查詢視頻生成狀態。
不要直接傳入 base64 圖片數據。請先使用 上傳圖片接口 上傳本地圖片,再將返回的公網 URL 放入
image。Authorizations
string
必填
所有接口均需要 Bearer Token 認證。
Authorization: Bearer YOUR_API_KEY
Body
string
預設值:"grok-video-1.5"
必填
固定使用
grok-video-1.5。string
必填
描述參考圖需要生成的動態效果、鏡頭運動和視覺方向。
string
必填
必須傳入且只能傳入 1 個公網首圖 URL。
- 最多:
1 - 支持 URL 協議:
http://、https://
integer
預設值:"8"
視頻時長。支持範圍:
1–15 秒string
預設值:"720p"
視頻分辨率。支持值:
480p、720p。string
預設值:"16:9"
視頻畫面比例。支持值:
1:1、16:9、9:16、3:2、2:3。Pricing
| 計費單位 | 價格 |
|---|---|
| 每生成 1 秒 | $0.01 / second |
Response
string
用於查詢任務狀態的任務 ID。
string
對象類型,固定爲
generation.task。string
本次任務使用的模型名。
string
任務狀態:
queued、in_progress、completed 或 failed。創建視頻任務
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "grok-video-1.5",
"prompt": "將這張產品圖生成電影感商業視頻,輕微鏡頭推進",
"image": "https://example.com/product.jpg",
"duration": 10,
"aspect_ratio": "16:9"
}'
import requests
task = requests.post(
"https://toapis.com/v1/videos/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "grok-video-1.5",
"prompt": "將這張產品圖生成電影感商業視頻",
"image": "https://example.com/product.jpg",
"duration": 15,
"aspect_ratio": "16:9",
},
).json()
print(task["id"])
{
"id": "video_abc123def456",
"object": "generation.task",
"model": "grok-video-1.5",
"status": "queued",
"progress": 0,
"created_at": 1768380224,
"metadata": {}
}
查詢任務狀態
使用返回的id 調用 視頻任務狀態接口。