# Grok Imagine Video API เอกสารอ้างอิง API ฉบับสมบูรณ์สำหรับโมเดลสร้างวิดีโอ Grok Imagine Video โดย xAI. ## ตัวเลือกโมเดล API นี้รองรับโมเดล 2 ตัวเลือก: | โมเดล | ID | คำอธิบาย | |-------|-----|-------------| | **Grok Imagine Text to Video** | `grok-imagine-text-to-video` | การสร้าง text-to-video | | **Grok Imagine Image to Video** | `grok-imagine-image-to-video` | การสร้างแอนิเมชันวิดีโอโดยใช้รูปภาพ reference | ## เปรียบเทียบอย่างรวดเร็ว | ฟีเจอร์ | Text to Video | Image to Video | |---------|---------------|----------------| | อินพุต | พรอมต์ข้อความ | อาร์เรย์รูปภาพ reference + พรอมต์ข้อความ | | Reference Images | ไม่รองรับ | จำเป็น (`images`) | ## Grok Imagine ข้อความเป็นวิดีโอ ### จุดเชื่อมต่อ ``` POST /api/v1/video/task ``` ### พารามิเตอร์คำขอ #### จำเป็น | พารามิเตอร์ | ประเภท | คำอธิบาย | |-----------|------|-------------| | `model_name` | string | ต้องเป็น `"grok-imagine-text-to-video"` | | `prompt` | string | พรอมต์สำหรับสร้างวิดีโอ | #### ไม่บังคับ | พารามิเตอร์ | ประเภท | คำอธิบาย | |-----------|------|-------------| | `duration` | number | ระยะเวลาวิดีโอเป็นวินาที: `6` หรือ `10` | | `resolution` | string | ความละเอียดเอาต์พุต: `"480p"` หรือ `"720p"` | | `aspect_ratio` | string | อัตราส่วนภาพวิดีโอ: `"16:9"`, `"1:1"` หรือ `"9:16"` | ### ตัวอย่างคำขอ ```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-text-to-video', prompt: 'A robot walking through a futuristic city', duration: 6, resolution: '720p', aspect_ratio: '16:9' }) }); const { data } = await response.json(); const taskId = data.task_id; ``` ## Grok Imagine รูปภาพเป็นวิดีโอ ### พารามิเตอร์คำขอ #### จำเป็น | พารามิเตอร์ | ประเภท | คำอธิบาย | |-----------|------|-------------| | `model_name` | string | ต้องเป็น `"grok-imagine-image-to-video"` | | `prompt` | string | พรอมต์สำหรับสร้างวิดีโอ | | `images` | string[] | อาร์เรย์ URL รูปภาพ reference สำหรับอินพุตแอนิเมชัน | #### ไม่บังคับ | พารามิเตอร์ | ประเภท | คำอธิบาย | |-----------|------|-------------| | `duration` | number | ระยะเวลาวิดีโอเป็นวินาที: `6` หรือ `10` | | `resolution` | string | ความละเอียดเอาต์พุต: `"480p"` หรือ `"720p"` | ### ตัวอย่างคำขอ ```javascript { model_name: 'grok-imagine-image-to-video', images: ['https://example.com/reference.jpg'], prompt: 'Camera slowly zooms in on the subject', duration: 6, resolution: '720p' } ``` ## รูปแบบการตอบกลับ ### การตอบกลับเริ่มต้น ทั้งสองโมเดลส่งคืน `task_id` สำหรับการ Poll: ```json { "code": 0, "message": "success", "data": { "task_id": "{task_id}", "response_url": "https://api.flaq.ai/api/v1/video/{task_id}", "task_status": "submitted" } } ``` ### การตอบกลับจากการ Poll Poll `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. **พรอมต์เชิงสร้างสรรค์**: Grok Imagine Video ทำได้ดีเมื่อใช้คำอธิบายฉากที่มีจินตนาการและละเอียด 2. **คำอธิบายการเคลื่อนไหว**: ใส่การเคลื่อนไหวของกล้องและวัตถุในพรอมต์ 3. **คุณภาพรูปภาพ**: สำหรับ image-to-video ให้ใช้รูปภาพอินพุตคุณภาพสูง