Chuyển đến nội dung chính
POST
/
grok
/
v1
/
videos
/
generations
curl --request POST \ --url https://api.cometapi.com/grok/v1/videos/generations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data ' { "prompt": "A candle flickers on a wooden table." } '
{
  "request_id": "4b2cd27e-0b0d-3dec-c31c-7572daf74bb3"
}
Sử dụng endpoint này để khởi tạo một tác vụ video Grok từ văn bản, hoặc từ văn bản cộng với một ảnh nguồn. Endpoint này trả về request_id ngay lập tức, vì vậy hãy coi đây là bước đầu tiên trong một quy trình async.

Bắt đầu với một yêu cầu nhỏ

  • Sử dụng model: grok-imagine-video
  • Với yêu cầu đầu tiên, giữ duration1resolution480p
  • Chỉ thêm image.url khi bạn muốn dùng image-to-video
  • Nếu bạn gửi base64, hãy giữ nguyên định dạng trong tài liệu và ví dụ OpenAPI là data:image/png;base64,<BASE64_IMAGE_DATA>

Luồng tác vụ

1

Tạo tác vụ

Gửi prompt và lưu request_id được trả về.
2

Truy vấn cho đến khi hoàn tất

Gọi Get Video Generation Results cho đến khi trạng thái provider lồng nhau trở thành done.
3

Lưu trữ đầu ra

Sao chép video.url cuối cùng vào nơi lưu trữ của riêng bạn nếu bạn cần dùng nó sau khoảng thời gian phân phối tạm thời của provider.

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI key.

Nội dung

application/json
prompt
string
bắt buộc

Prompt for the video job.

Ví dụ:

"A candle flickers on a wooden table."

aspect_ratio
enum<string>

Output aspect ratio.

Tùy chọn có sẵn:
1:1,
16:9,
9:16,
4:3,
3:4,
3:2,
2:3
duration
integer
mặc định:1

Output duration in seconds. xAI documents a range of 1 to 15 seconds.

image
object

Optional source image for image-to-video.

model
string
mặc định:grok-imagine-video

xAI video model id.

Ví dụ:

"grok-imagine-video"

output
object
resolution
enum<string>

Output resolution.

Tùy chọn có sẵn:
480p,
720p
size
string

Deprecated size field. Prefer aspect_ratio and resolution.

user
string

Optional end-user identifier.

Phản hồi

200 - application/json

Request accepted.

request_id
string
bắt buộc

Deferred request id used for polling.