Skip to main content
POST
Verwenden Sie diese Route, um mit Grok-Bildmodellen Bilder aus Text zu erstellen. Der Request-Body verwendet application/json. Die Anfrage unterstützt model, prompt, n, aspect_ratio, resolution und response_format.

Modell auswählen

Wählen Sie eine Grok-Bildmodell-ID auf der Modellseite aus. Die API-Beispiele verwenden grok-imagine-image-quality.

Ausgabe konfigurieren

  • Verwenden Sie aspect_ratio, um die Ausgabeform auszuwählen, oder auto, damit das Modell die Form auswählt.
  • Verwenden Sie resolution, um eine Ausgabe als 1k oder 2k anzufordern.
  • Verwenden Sie n, um bis zu 10 Bilder anzufordern.
  • Verwenden Sie response_format, um temporäre URLs oder Base64-kodierte Bilddaten zurückzugeben.
Weitere Informationen zu Anbieterparametern finden Sie im xAI-Leitfaden zur Bildgenerierung.
Laden Sie URL-Ergebnisse herunter, nachdem die Anfrage abgeschlossen ist. Generierte Bild-URLs können ablaufen.

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 description of the image to generate.

Minimum string length: 1
Beispiel:

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

n
integer
Standard:1

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

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

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

Verfügbare Optionen:
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
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 generated image results.

data
object[]
erforderlich

The generated images.

Minimum array length: 1
usage
object
erforderlich

Usage details for the request.