Skip to main content
POST
استخدم هذا المسار لإنشاء صور من النص باستخدام نماذج صور Grok. يستخدم نص الطلب application/json. يدعم الطلب model وprompt وn وaspect_ratio وresolution وresponse_format.

اختر نموذجًا

اختر معرّف نموذج صور Grok من صفحة النماذج. تستخدم أمثلة API القيمة grok-imagine-image-quality.

إعداد المخرجات

  • استخدم aspect_ratio لتحديد شكل المخرجات، أو استخدم auto للسماح للنموذج بتحديد الشكل.
  • استخدم resolution لطلب مخرجات 1k أو 2k.
  • استخدم n لطلب ما يصل إلى 10 صور.
  • استخدم response_format لإرجاع عناوين URL مؤقتة أو بيانات صور مرمّزة بتنسيق Base64.
للاطلاع على تفاصيل معلمات المزوّد، راجع دليل إنشاء الصور من xAI.
نزّل نتائج URL بعد اكتمال الطلب. قد تنتهي صلاحية عناوين URL للصور المُنشأة.

التفويضات

Authorization
string
header
مطلوب

Use your CometAPI API key as the bearer value.

الجسم

application/json
model
enum<string>
مطلوب

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

الخيارات المتاحة:
grok-imagine-image,
grok-imagine-image-quality
مثال:

"grok-imagine-image-quality"

prompt
string
مطلوب

A text description of the image to generate.

Minimum string length: 1
مثال:

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

n
integer
افتراضي:1

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

النطاق المطلوب: 1 <= x <= 10
aspect_ratio
enum<string>

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

الخيارات المتاحة:
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
مثال:

"16:9"

resolution
enum<string>

The requested output resolution.

الخيارات المتاحة:
1k,
2k
مثال:

"1k"

response_format
enum<string>
افتراضي:url

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

الخيارات المتاحة:
url,
b64_json

الاستجابة

200 - application/json

The generated image results.

data
object[]
مطلوب

The generated images.

Minimum array length: 1
usage
object
مطلوب

Usage details for the request.