Skip to main content
POST
このルートを使用して、Grok画像モデルで1枚以上の画像を編集します。リクエスト本文ではapplication/jsonを使用します。

画像入力を指定

  • imageまたはimagesのいずれか一方のみを送信します。
  • 1枚のソース画像にはimageを使用します。
  • 2枚または3枚のソース画像にはimagesを使用します。
  • 各画像オブジェクトでは、公開URLまたはdata URIにurlを使用します。image_urlurlの互換性エイリアスです。
  • 複数画像編集の出力形式を制御するにはaspect_ratioを使用します。
Grok画像モデルIDは、 モデルページで選択します。APIの例ではgrok-imagine-image-qualityを使用しています。
Grok画像編集リクエストはJSONとして送信します。multipart form dataではこのリクエスト形式を表現できません。
OpenAI SDKのimages.edit()メソッドはmultipart form dataを送信します。Grok JSON画像編集には直接HTTPリクエストを使用してください。 プロバイダーパラメータの詳細については、 xAI画像編集ガイドを参照してください。.

承認

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 instruction that describes the requested edit.

Minimum string length: 1
:

"Replace the daytime sky with a soft sunset and preserve the building"

image
object
必須

One source image. Use this field instead of images.

images
object[]

Two or three source images. Use this field instead of image.

Required array length: 2 - 3 elements

A source image represented by url or the compatibility alias image_url.

n
integer
デフォルト:1

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

必須範囲: 1 <= x <= 10
aspect_ratio
enum<string>

The output shape for a multi-image edit.

利用可能なオプション:
1:1,
3:4,
4:3,
16:9,
2:3,
3:2,
9:19.5,
19.5:9,
9:20,
20:9,
1:2
:

"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 edited image results.

data
object[]
必須

The edited images.

Minimum array length: 1
usage
object
必須

Usage details for the request.