# Grok Imagine Video 1.5 API xAI Grok Imagine Video 1.5 生成模型的完整 API 參考。 ## 模型變體 此 API 支援一個模型變體: | 模型 | ID | 說明 | |-------|-----|-------------| | **Grok Imagine 1.5 Image to Video** | `grok-imagine-v1.5-image-to-video` | 由參考圖片引導的影片動畫 | ### 支援的長寬比 | 比例 | 說明 | |-------|-------------| | `2:3` | 直向 | | `3:2` | 橫向 | | `1:1` | 方形 | | `16:9` | 橫向(寬螢幕) | | `9:16` | 直向(垂直) | | `3:4` | 標準直向 | | `4:3` | 標準橫向 | ### 解析度選項 | 解析度 | 說明 | |------------|-------------| | `480p` | 標準畫質,處理更快 | | `720p` | 高畫質,兼顧品質與速度 | ## Grok Imagine 1.5 Image to Video ### 端點 ``` POST /api/v1/video/task ``` ### 請求參數 #### 必填 | 參數 | 類型 | 說明 | |-----------|------|-------------| | `model_name` | string | 必須是 `"grok-imagine-v1.5-image-to-video"` | | `image_url` | string | 動畫輸入所用的參考圖片 URL | | `prompt` | string | 影片生成提示詞 | | `duration` | number | 影片時長,以秒為單位 (1-15) | | `resolution` | string | 計費解析度:`"480p"` 或 `"720p"` | #### 選填 | 參數 | 類型 | 說明 | |-----------|------|-------------| | `aspect_ratio` | string | 影片長寬比:`"2:3"`、`"3:2"`、`"1:1"`、`"16:9"`、`"9:16"`、`"3:4"` 或 `"4:3"`(預設為 `"16:9"`) | ### 請求範例 ```javascript const response = await fetch('https://api.flaq.ai/api/v1/video/task', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model_name: 'grok-imagine-v1.5-image-to-video', image_url: 'https://example.com/reference.jpg', prompt: 'Subtle camera motion, subject holds pose', aspect_ratio: '16:9', duration: 10, resolution: '720p' }) }); const { data } = await response.json(); const taskId = data.task_id; ``` **僅 body 範例:** ```javascript { model_name: 'grok-imagine-v1.5-image-to-video', image_url: 'https://example.com/reference.jpg', prompt: 'Subtle camera motion, subject holds pose', aspect_ratio: '16:9', duration: 10, resolution: '720p' } ``` ## 回應格式 ### 初始回應 回傳用於輪詢的 `task_id`: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/video/{task_id}", "task_status": "submitted" } } ``` ### 輪詢回應 輪詢 `GET /api/v1/video/{taskId}` 以檢查狀態: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/video/{task_id}", "task_status": "succeed", "task_status_msg": null, "task_result": { "credit": 0.2, "videos": [ { "url": "https://example.com/generated-video.mp4" } ] } } } ``` ### 狀態值 - `submitted`: 任務已接受,正在等待處理 - `processing`: 影片生成進行中 - `succeed`: 影片生成完成 - `failed`: 影片生成失敗 ## 處理時間 典型處理時間:2-5 分鐘。 ## 最佳實踐 1. **動作描述**:在提示詞中包含鏡頭運動和主體動作 2. **圖片品質**:使用高品質輸入圖片,以獲得更好的動畫效果 3. **長寬比**:提交前,讓 `aspect_ratio` 符合你的目標輸出格式