Skip to main content
POST
Gunakan rute ini untuk membuat gambar dari teks dengan model gambar Grok. Isi permintaan menggunakan application/json. Permintaan mendukung model, prompt, n, aspect_ratio, resolution, dan response_format.

Pilih model

Pilih ID model gambar Grok dari halaman Models. Contoh API menggunakan grok-imagine-image-quality.

Konfigurasikan output

  • Gunakan aspect_ratio untuk memilih bentuk output, atau gunakan auto agar model memilih bentuknya.
  • Gunakan resolution untuk meminta output 1k atau 2k.
  • Gunakan n untuk meminta hingga 10 gambar.
  • Gunakan response_format untuk mengembalikan URL sementara atau data gambar yang dienkode Base64.
Untuk detail parameter provider, lihat panduan pembuatan gambar xAI.
Unduh hasil URL setelah permintaan selesai. URL gambar yang dihasilkan dapat kedaluwarsa.

Otorisasi

Authorization
string
header
wajib

Use your CometAPI API key as the bearer value.

Body

application/json
model
enum<string>
wajib

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

Opsi yang tersedia:
grok-imagine-image,
grok-imagine-image-quality
Contoh:

"grok-imagine-image-quality"

prompt
string
wajib

A text description of the image to generate.

Minimum string length: 1
Contoh:

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

n
integer
default:1

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

Rentang yang diperlukan: 1 <= x <= 10
aspect_ratio
enum<string>

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

Opsi yang tersedia:
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
Contoh:

"16:9"

resolution
enum<string>

The requested output resolution.

Opsi yang tersedia:
1k,
2k
Contoh:

"1k"

response_format
enum<string>
default:url

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

Opsi yang tersedia:
url,
b64_json

Respons

200 - application/json

The generated image results.

data
object[]
wajib

The generated images.

Minimum array length: 1
usage
object
wajib

Usage details for the request.