Skip to main content
POST
Verwende diese Route, um ein oder mehrere Bilder mit Grok-Bildmodellen zu bearbeiten. Der Anfragetext verwendet application/json.

Bildeingabe bereitstellen

  • Sende genau eines von image oder images.
  • Verwende image für ein Quellbild.
  • Verwende images für zwei oder drei Quellbilder.
  • Verwende in jedem Bildobjekt url für eine öffentliche URL oder Daten-URI. image_url ist ein Kompatibilitätsalias für url.
  • Verwende aspect_ratio, um die Form der Ausgabe für Bearbeitungen mit mehreren Bildern zu steuern.
Wähle eine Grok-Bildmodell-ID auf der Modellseite. Die API-Beispiele verwenden grok-imagine-image-quality.
Sende Grok-Anfragen zur Bildbearbeitung als JSON. Multipart-Formulardaten bilden diese Anfrageform nicht ab.
Die Methode images.edit() des OpenAI SDK sendet Multipart-Formulardaten. Verwende eine direkte HTTP-Anfrage für Grok-JSON-Bildbearbeitungen. Details zu Anbieterparametern findest du im xAI-Leitfaden zur Bildbearbeitung.

Autorisierungen

Authorization
string
header
erforderlich

Use your CometAPI API key as the bearer value.

Body

application/json
model
enum<string>
erforderlich

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

Verfügbare Optionen:
grok-imagine-image,
grok-imagine-image-quality
Beispiel:

"grok-imagine-image-quality"

prompt
string
erforderlich

A text instruction that describes the requested edit.

Minimum string length: 1
Beispiel:

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

image
object
erforderlich

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

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

Erforderlicher Bereich: 1 <= x <= 10
aspect_ratio
enum<string>

The output shape for a multi-image edit.

Verfügbare Optionen:
1:1,
3:4,
4:3,
16:9,
2:3,
3:2,
9:19.5,
19.5:9,
9:20,
20:9,
1:2
Beispiel:

"16:9"

resolution
enum<string>

The requested output resolution.

Verfügbare Optionen:
1k,
2k
Beispiel:

"1k"

response_format
enum<string>
Standard:url

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

Verfügbare Optionen:
url,
b64_json

Antwort

200 - application/json

The edited image results.

data
object[]
erforderlich

The edited images.

Minimum array length: 1
usage
object
erforderlich

Usage details for the request.