xAI
Lấy kết quả video xAI
Sử dụng GET /grok/v1/videos/ để thăm dò trạng thái tạo video xAI và truy xuất URL video cuối cùng sau khi quá trình xử lý hoàn tất.
GET
/
grok
/
v1
/
videos
/
{request_id}
cURL
curl "https://api.cometapi.com/grok/v1/videos/<request_id>" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import requests
request_id = "<request_id>"
response = requests.get(
f"https://api.cometapi.com/grok/v1/videos/{request_id}",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
)
print(response.json())
const requestId = "<request_id>";
const response = await fetch(`https://api.cometapi.com/grok/v1/videos/${requestId}`, {
headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
});
console.log(await response.json());
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/grok/v1/videos/{request_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/grok/v1/videos/{request_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/grok/v1/videos/{request_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/grok/v1/videos/{request_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"request_id": "<request_id>"
}Sử dụng endpoint này sau khi bạn đã có
request_id. Endpoint này cho biết liệu tác vụ xAI vẫn đang chạy hay không và trả về siêu dữ liệu video cuối cùng khi đã sẵn sàng.
Trước tiên, hãy kiểm tra các trường này
request_idkhi tác vụ đã được chấp nhận nhưng kết quả chưa sẵn sàngstatusđể biết trạng thái tác vụ xAI; tiếp tục thăm dò khi giá trị làpending, và dừng khi làdone,failedhoặcexpiredprogressđể biết phần trăm hoàn thành khi giá trị này được trả vềvideo.urlkhi quá trình render hoàn tất
Vòng lặp thăm dò
1
Trước tiên, hãy tạo hoặc chỉnh sửa video
Bắt đầu bằng Tạo video xAI hoặc Tạo bản chỉnh sửa video xAI, sau đó sao chép
request_id.2
Thăm dò cho đến khi tác vụ đạt trạng thái kết thúc
Nếu phản hồi chỉ lặp lại
request_id, hãy đợi vài giây rồi thăm dò lại. Tiếp tục khi status là pending; dừng khi là done, failed hoặc expired.3
Lưu tệp đã hoàn tất
Hãy tải xuống hoặc sao chép
video.url cuối cùng ngay, vì xAI ghi trong tài liệu rằng các URL được tạo chỉ có hiệu lực tạm thời.Tham số đường dẫn
Phản hồi
200 - application/json
The current Grok video task state.
Lần sửa đổi cuối 21 tháng 8, 2026
⌘I
cURL
curl "https://api.cometapi.com/grok/v1/videos/<request_id>" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import requests
request_id = "<request_id>"
response = requests.get(
f"https://api.cometapi.com/grok/v1/videos/{request_id}",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
)
print(response.json())
const requestId = "<request_id>";
const response = await fetch(`https://api.cometapi.com/grok/v1/videos/${requestId}`, {
headers: { Authorization: `Bearer ${process.env.COMETAPI_KEY}` },
});
console.log(await response.json());
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/grok/v1/videos/{request_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/grok/v1/videos/{request_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/grok/v1/videos/{request_id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/grok/v1/videos/{request_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"request_id": "<request_id>"
}