Sử dụng GET /grok/v1/videos/ để thăm dò trạng thái tạo video của xAI và lấy URL video cuối cùng sau khi xử lý hoàn tất.
curl --request GET \
--url https://api.cometapi.com/grok/v1/videos/{request_id} \
--header 'Authorization: Bearer <token>'{
"code": "success",
"message": "",
"data": {
"task_id": "4b2cd27e-0b0d-3dec-c31c-7572daf74bb3",
"action": "VIDEO_GENERATION",
"status": "SUCCESS",
"fail_reason": "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-72924fdc-e6d7-4885-b318-8a367aaa9a02.mp4",
"submit_time": 1773297002,
"start_time": 0,
"finish_time": 1773297014,
"progress": "100%",
"data": {
"model": "grok-imagine-video",
"usage": {
"cost_in_usd_ticks": 500000000
},
"video": {
"url": "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-72924fdc-e6d7-4885-b318-8a367aaa9a02.mp4",
"duration": 1,
"respect_moderation": true
},
"status": "done"
}
}
}request_id. Endpoint này cho biết tác vụ xAI còn đang chạy hay không và trả về metadata video cuối cùng khi đã sẵn sàng.
code và message của wrapper để phát hiện lỗi cấp cao nhấtdata.status cho trạng thái tác vụ CometAPIdata.data.status cho trạng thái lồng nhau của nhà cung cấpdata.data.video.url khi quá trình render hoàn tấtTrước tiên hãy tạo hoặc chỉnh sửa video
request_id được trả về.Tiếp tục thăm dò cho đến khi trạng thái lồng nhau là done
Bearer token authentication. Use your CometAPI key.
Deferred request id returned by the create or edit endpoint.
curl --request GET \
--url https://api.cometapi.com/grok/v1/videos/{request_id} \
--header 'Authorization: Bearer <token>'{
"code": "success",
"message": "",
"data": {
"task_id": "4b2cd27e-0b0d-3dec-c31c-7572daf74bb3",
"action": "VIDEO_GENERATION",
"status": "SUCCESS",
"fail_reason": "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-72924fdc-e6d7-4885-b318-8a367aaa9a02.mp4",
"submit_time": 1773297002,
"start_time": 0,
"finish_time": 1773297014,
"progress": "100%",
"data": {
"model": "grok-imagine-video",
"usage": {
"cost_in_usd_ticks": 500000000
},
"video": {
"url": "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-72924fdc-e6d7-4885-b318-8a367aaa9a02.mp4",
"duration": 1,
"respect_moderation": true
},
"status": "done"
}
}
}