Skip to main content
POST
Dùng route này để tạo hình ảnh từ văn bản bằng các mô hình hình ảnh Grok. Phần thân yêu cầu sử dụng application/json. Yêu cầu hỗ trợ model, prompt, n, aspect_ratio, resolutionresponse_format.

Chọn một mô hình

Chọn một ID mô hình hình ảnh Grok từ trang Models. Các ví dụ API sử dụng grok-imagine-image-quality.

Cấu hình đầu ra

  • Dùng aspect_ratio để chọn hình dạng đầu ra hoặc dùng auto để mô hình tự chọn hình dạng.
  • Dùng resolution để yêu cầu đầu ra 1k hoặc 2k.
  • Dùng n để yêu cầu tối đa 10 hình ảnh.
  • Dùng response_format để trả về URL tạm thời hoặc dữ liệu hình ảnh được mã hóa Base64.
Để biết chi tiết về tham số của nhà cung cấp, hãy xem hướng dẫn tạo hình ảnh của xAI.
Tải xuống kết quả URL sau khi yêu cầu hoàn tất. URL hình ảnh được tạo có thể hết hạn.

Ủy quyền

Authorization
string
header
bắt buộc

Use your CometAPI API key as the bearer value.

Nội dung

application/json
model
enum<string>
bắt buộc

The Grok image model ID. See the Models page for available model IDs.

Tùy chọn có sẵn:
grok-imagine-image,
grok-imagine-image-quality
Ví dụ:

"grok-imagine-image-quality"

prompt
string
bắt buộc

A text description of the image to generate.

Minimum string length: 1
Ví dụ:

"A glass observatory above a quiet alpine lake at sunrise"

n
integer
mặc định:1

The number of images to generate. Use an integer from 1 through 10.

Phạm vi bắt buộc: 1 <= x <= 10
aspect_ratio
enum<string>

The output shape. Use auto to let the model select the aspect ratio.

Tùy chọn có sẵn:
1:1,
3:4,
4:3,
9:16,
16:9,
2:3,
3:2,
9:19.5,
19.5:9,
9:20,
20:9,
1:2,
2:1,
auto
Ví dụ:

"16:9"

resolution
enum<string>

The requested output resolution.

Tùy chọn có sẵn:
1k,
2k
Ví dụ:

"1k"

response_format
enum<string>
mặc định:url

The image representation in each response item. Use url for a temporary download URL or b64_json for Base64-encoded image bytes.

Tùy chọn có sẵn:
url,
b64_json

Phản hồi

200 - application/json

The generated image results.

data
object[]
bắt buộc

The generated images.

Minimum array length: 1
usage
object
bắt buộc

Usage details for the request.