Generieren Sie Bilder mit Grok Imagine Image 2.0, einschließlich Steuerungsmöglichkeiten für Qualität, Seitenverhältnis, Auflösung, Bildanzahl und Antwortformat.
POST
/
v1
/
images
/
generations
curl https://api.cometapi.com/v1/images/generations \ -H "Authorization: Bearer $COMETAPI_KEY" \ -H "Content-Type: application/json" \ --data-binary '{ "model": "grok-imagine-image-2.0", "prompt": "A glass observatory above a quiet alpine lake at sunrise", "aspect_ratio": "16:9", "resolution": "1k", "quality": "low", "response_format": "url" }'
Verwenden Sie diese Route, um mit Grok-Bildmodellen Bilder aus Text zu erstellen. Der Anfragetext verwendet application/json.
model und prompt sind erforderlich.
Ein Modell auswählen
Wählen Sie eine Grok-Bildmodell-ID auf der Modellseite. Die API-Beispiele verwenden grok-imagine-image-2.0.quality ist nur mit grok-imagine-image-2.0 verfügbar und akzeptiert low oder medium. Legen Sie sie explizit fest, wenn Ihre Anwendung von einer bestimmten Qualitätsstufe abhängt. Wenn resolution für Image 2.0 weggelassen wird, verwendet CometAPI 1k.
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 im Format 1k oder 2k anzufordern.
Verwenden Sie n, um 1 bis 10 Bilder anzufordern. Der Standardwert ist 1.
Verwenden Sie response_format, um temporäre URLs oder Base64-codierte Bilddaten zurückzugeben.
Laden Sie URL-Ergebnisse unverzüglich herunter, nachdem die Anfrage abgeschlossen ist. Generierte Bild-URLs sind temporär. Verwenden Sie b64_json, wenn Ihre Anwendung die Bild-Bytes in der API-Antwort benötigt.
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,
grok-imagine-image-2.0
Beispiel:
"grok-imagine-image-2.0"
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>
Standard:1k
The requested output resolution. Image 2.0 uses 1k when this field is omitted.
Verfügbare Optionen:
1k,
2k
Beispiel:
"1k"
quality
enum<string>
Image quality for grok-imagine-image-2.0. This field is not available for the older Grok image model IDs.
Verfügbare Optionen:
low,
medium
Beispiel:
"low"
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
Option 1
Option 2
Show child attributes
usage
object
Additional usage metadata returned for the request. Its contents can vary by model.
Zuletzt geändert am 21. August 2026
⌘I
curl https://api.cometapi.com/v1/images/generations \ -H "Authorization: Bearer $COMETAPI_KEY" \ -H "Content-Type: application/json" \ --data-binary '{ "model": "grok-imagine-image-2.0", "prompt": "A glass observatory above a quiet alpine lake at sunrise", "aspect_ratio": "16:9", "resolution": "1k", "quality": "low", "response_format": "url" }'