xAI Grok Imagine 影片生成, 非同步任務. 提交返回任務 ID, 輪詢查詢狀態獲取影片 URL.
POST /v1/videos/generations
## Grok Imagine 影片生成 (非同步) xAI Grok Imagine 影片模型, 非同步任務模式: `POST /v1/videos/generations` 提交後**立即返回任務 ID**, 通過 `GET /v1/videos/generations/{id}` 輪詢查詢狀態, 任務 `succeeded` 時響應含影片 URL。 **模型** - `grok-imagine-video` — 文生影片 (t2v) / 圖生影片 (i2v) - `grok-imagine-video-1.5-preview` — **僅圖生影片 (i2v)**, 必須傳 `image` **圖生影片 (i2v)**: 傳 `image` 欄位 (首幀參考圖)。⚠️ `image` 必須是物件 `{"url": "https://..."}`。 **查詢狀態**: 見「查詢影片任務」(`GET /v1/videos/generations/{id}`), 任務 `succeeded` 時響應含影片 URL (可直接存取下載)。
model | string | required | 影片模型 ID |
prompt | string | required | 文本描述; 文生影片必填, 圖生影片可選 (描述運動/風格) |
duration | number | 影片時長 (秒) | |
resolution | string | 解析度 | |
aspect_ratio | string | 畫面比例 | |
image | object | 圖生影片 (i2v) 首幀參考圖。⚠️ 必須是物件 `{"url": "https://..."}`。`grok-imagine-video-1.5-preview` 必填。 |
200 — 任務已提交 (非同步)。用返回的 id 輪詢查詢狀態。402 — 餘額不足# 文生视频 (t2v)
curl -X POST https://api.router.ai/v1/videos/generations \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video",
"prompt": "一只柯基在草地上奔跑, 阳光明媚",
"resolution": "720p",
"duration": 5
}'
# 图生视频 (i2v) — image 必须是 {"url":...} 对象
curl -X POST https://api.router.ai/v1/videos/generations \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video-1.5-preview",
"prompt": "镜头缓慢推近",
"image": { "url": "https://example.com/first_frame.jpg" },
"resolution": "720p"
}'
# 查询任务状态
curl https://api.router.ai/v1/videos/generations/gt-20260629130818-9b3a2f \
-H "Authorization: Bearer $YOUR_API_KEY"