Створення зображень за допомогою Grok
Створюйте зображення за допомогою Grok Imagine Image 2.0, зокрема керуйте якістю, співвідношенням сторін, роздільною здатністю, кількістю зображень і форматом відповіді.
application/json.
model і prompt є обов’язковими.
Виберіть модель
Виберіть ідентифікатор моделі зображень Grok на сторінці моделей. У прикладах API використовуєтьсяgrok-imagine-image-2.0.
quality доступна лише з grok-imagine-image-2.0 і приймає low або medium. Явно встановіть її, якщо ваш застосунок залежить від певного рівня якості. Якщо resolution не вказано для Image 2.0, CometAPI використовує 1k.
Налаштуйте вивід
- Використовуйте
aspect_ratio, щоб вибрати формат виводу, абоauto, щоб модель вибрала формат. - Використовуйте
resolution, щоб запитати вивід1kабо2k. - Використовуйте
n, щоб запитати від 1 до 10 зображень. Типове значення —1. - Використовуйте
response_format, щоб повертати тимчасові URL-адреси або дані зображень, закодовані в Base64.
b64_json, коли вашому застосунку потрібні байти зображення у відповіді API.Авторизації
Use your CometAPI API key as the bearer value.
Тіло
The Grok image model ID. See the Models page for available model IDs.
grok-imagine-image, grok-imagine-image-quality, grok-imagine-image-2.0 "grok-imagine-image-2.0"
A text description of the image to generate.
1"A glass observatory above a quiet alpine lake at sunrise"
The number of images to generate. Use an integer from 1 through 10.
1 <= x <= 10The 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"
The requested output resolution. Image 2.0 uses 1k when this field is omitted.
1k, 2k "1k"
Image quality for grok-imagine-image-2.0. This field is not available for the older Grok image model IDs.
low, medium "low"
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