Skip to main content
POST
Gunakan rute ini untuk mengedit satu atau beberapa gambar dengan model gambar Grok. Isi permintaan menggunakan application/json.

Sediakan input gambar

  • Kirim tepat salah satu dari image atau images.
  • Gunakan image untuk satu gambar sumber.
  • Gunakan images untuk dua atau tiga gambar sumber.
  • Dalam setiap objek gambar, gunakan url untuk URL publik atau URI data. image_url adalah alias kompatibilitas untuk url.
  • Gunakan aspect_ratio untuk mengontrol bentuk output bagi pengeditan multi-gambar.
Pilih ID model gambar Grok dari halaman Models. Contoh API menggunakan grok-imagine-image-quality.
Kirim permintaan pengeditan gambar Grok sebagai JSON. Data formulir multipart tidak merepresentasikan bentuk permintaan ini.
Metode images.edit() di OpenAI SDK mengirim data formulir multipart. Gunakan permintaan HTTP langsung untuk pengeditan gambar JSON Grok. Untuk detail parameter penyedia, lihat panduan pengeditan gambar xAI.

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 instruction that describes the requested edit.

Minimum string length: 1
Contoh:

"Replace the daytime sky with a soft sunset and preserve the building"

image
object
wajib

One source image. Use this field instead of images.

images
object[]

Two or three source images. Use this field instead of image.

Required array length: 2 - 3 elements

A source image represented by url or the compatibility alias image_url.

n
integer
default:1

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

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

The output shape for a multi-image edit.

Opsi yang tersedia:
1:1,
3:4,
4:3,
16:9,
2:3,
3:2,
9:19.5,
19.5:9,
9:20,
20:9,
1:2
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 edited image results.

data
object[]
wajib

The edited images.

Minimum array length: 1
usage
object
wajib

Usage details for the request.