Grokで画像を生成
Grok Imagine Image 2.0で画像を生成し、品質、アスペクト比、解像度、画像数、レスポンス形式を制御します。
application/jsonを使用します。
model promptとともに必須です。
モデルを選択
Grok画像モデルIDを モデルページから選択します。API例ではgrok-imagine-image-2.0を使用します。
quality はgrok-imagine-image-2.0でのみ利用でき、lowまたはmediumを受け入れます。アプリケーションが特定の品質レベルに依存する場合は、明示的に設定してください。Image 2.0でresolutionを省略すると、CometAPIは1kを使用します。
出力を設定
aspect_ratioを使用して出力形状を選択するか、autoを使用してモデルに形状を選択させます。resolutionを使用して、1kまたは2kの出力をリクエストします。nを使用して、1〜10枚の画像をリクエストします。デフォルトは1です。response_formatを使用して、一時URLまたはBase64エンコードされた画像データを返します。
b64_jsonを使用してください。承認
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