Skip to main content
POST
Usa questo endpoint per modificare una o più immagini con i modelli di immagini Grok. Il corpo della richiesta utilizza application/json.

Fornisci immagini di input

  • Invia esattamente uno tra image e images.
  • Usa image per un’immagine di origine.
  • Usa images per due o tre immagini di origine.
  • In ogni oggetto immagine, usa url per un URL pubblico o un URI di dati. image_url è un alias di compatibilità per url.
  • Usa aspect_ratio per controllare la forma dell’output per le modifiche a più immagini.
Scegli un ID di modello di immagini Grok dalla pagina dei modelli. Gli esempi API usano grok-imagine-image-quality.
Invia le richieste di modifica delle immagini Grok come JSON. I dati dei moduli multipart non rappresentano questa struttura di richiesta.
Il metodo images.edit() dell’SDK OpenAI invia dati dei moduli multipart. Usa una richiesta HTTP diretta per le modifiche di immagini Grok in JSON. Per i dettagli sui parametri del provider, consulta la guida di xAI alla modifica delle immagini.

Autorizzazioni

Authorization
string
header
obbligatorio

Use your CometAPI API key as the bearer value.

Corpo

application/json
model
enum<string>
obbligatorio

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

Opzioni disponibili:
grok-imagine-image,
grok-imagine-image-quality
Esempio:

"grok-imagine-image-quality"

prompt
string
obbligatorio

A text instruction that describes the requested edit.

Minimum string length: 1
Esempio:

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

image
object
obbligatorio

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
predefinito:1

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

Intervallo richiesto: 1 <= x <= 10
aspect_ratio
enum<string>

The output shape for a multi-image edit.

Opzioni disponibili:
1:1,
3:4,
4:3,
16:9,
2:3,
3:2,
9:19.5,
19.5:9,
9:20,
20:9,
1:2
Esempio:

"16:9"

resolution
enum<string>

The requested output resolution.

Opzioni disponibili:
1k,
2k
Esempio:

"1k"

response_format
enum<string>
predefinito:url

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

Opzioni disponibili:
url,
b64_json

Risposta

200 - application/json

The edited image results.

data
object[]
obbligatorio

The edited images.

Minimum array length: 1
usage
object
obbligatorio

Usage details for the request.