Skip to main content
POST
使用此路由透過 Grok 圖片模型編輯一或多張圖片。請求主體使用 application/json

提供圖片輸入

  • 請僅傳送 imageimages 其中之一。
  • 針對一張來源圖片,使用 image
  • 針對兩張或三張來源圖片,使用 images
  • 在每個圖片物件中,將 url 用於公開 URL 或資料 URI。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.