Skip to main content
POST
Metinden Grok image modelleriyle görseller oluşturmak için bu route’u kullanın. İstek gövdesinde application/json kullanılır. model ve prompt zorunludur.

Bir model seçin

Şuradan bir Grok image model ID seçin: Models sayfası. API örneklerinde grok-imagine-image-2.0 kullanılır. quality yalnızca grok-imagine-image-2.0 ile kullanılabilir ve low ya da medium kabul eder. Uygulamanız belirli bir kalite düzeyine bağlıysa bunu açıkça ayarlayın. Image 2.0 için resolution atlandığında CometAPI, 1k kullanır.

Çıktıyı yapılandırın

  • Çıktı şeklini seçmek için aspect_ratio kullanın veya modelin şekli seçmesine izin vermek için auto kullanın.
  • resolution ya da 1k çıktısı istemek için 2k kullanın.
  • 1 ile 10 arasında görsel istemek için n kullanın. Varsayılan değer 1 şeklindedir.
  • Geçici URL’ler veya Base64 kodlu görsel verileri döndürmek için response_format kullanın.
Modele özgü davranışlar için şu kaynağa bakın: xAI image generation guide.
İstek tamamlandıktan hemen sonra URL sonuçlarını indirin. Oluşturulan görsel URL’leri geçicidir. Uygulamanızın API yanıtındaki görsel baytlarına ihtiyacı varsa b64_json kullanın.

Yetkilendirmeler

Authorization
string
header
gerekli

Use your CometAPI API key as the bearer value.

Gövde

application/json
model
enum<string>
gerekli

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

Mevcut seçenekler:
grok-imagine-image,
grok-imagine-image-quality,
grok-imagine-image-2.0
Örnek:

"grok-imagine-image-2.0"

prompt
string
gerekli

A text description of the image to generate.

Minimum string length: 1
Örnek:

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

n
integer
varsayılan:1

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

Gerekli aralık: 1 <= x <= 10
aspect_ratio
enum<string>

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

Mevcut seçenekler:
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
Örnek:

"16:9"

resolution
enum<string>
varsayılan:1k

The requested output resolution. Image 2.0 uses 1k when this field is omitted.

Mevcut seçenekler:
1k,
2k
Örnek:

"1k"

quality
enum<string>

Image quality for grok-imagine-image-2.0. This field is not available for the older Grok image model IDs.

Mevcut seçenekler:
low,
medium
Örnek:

"low"

response_format
enum<string>
varsayılan:url

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

Mevcut seçenekler:
url,
b64_json

Yanıt

200 - application/json

The generated image results.

data
object[]
gerekli

The generated images.

Minimum array length: 1
usage
object

Additional usage metadata returned for the request. Its contents can vary by model.

Son değiştirilme tarihi 21 Ağustos 2026