Skip to main content
POST
このルートを使用して、Grok 画像モデルでテキストから画像を作成します。リクエスト本文では application/json を使用します。 リクエストでは modelpromptnaspect_ratioresolutionresponse_format をサポートしています。

モデルを選択

Grok 画像モデル ID は、 モデルページから選択します。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.