Skip to main content
POST
使用此路由通过 Grok 图像模型编辑一张或多张图像。请求正文使用 application/json

提供图像输入

  • 仅发送 imageimages 之一。
  • 对一张源图像使用 image
  • 对两张或三张源图像使用 images
  • 在每个图像对象中,对公开 URL 或数据 URI 使用 urlimage_urlurl 的兼容性别名。
  • 使用 aspect_ratio 控制多图像编辑的输出形状。
选择一个 Grok 图像模型 ID,请参阅 模型页面。API 示例使用 grok-imagine-image-quality
以 JSON 格式发送 Grok 图像编辑请求。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.