使用 Grok 编辑图像
通过在 JSON 请求中发送图像 URL 或数据 URI,使用 Grok 编辑一张或多张图像。
application/json。
提供图像输入
- 仅发送
image或images之一。 - 对一张源图像使用
image。 - 对两张或三张源图像使用
images。 - 在每个图像对象中,对公开 URL 或数据 URI 使用
url。image_url是url的兼容性别名。 - 使用
aspect_ratio控制多图像编辑的输出形状。
grok-imagine-image-quality。
OpenAI SDK 的 images.edit() 方法会发送 multipart form data。对于 Grok JSON 图像编辑,请使用直接 HTTP 请求。
有关提供商参数的详细信息,请参阅 xAI 图像编辑指南.授权
Use your CometAPI API key as the bearer value.
请求体
- Option 1
- Option 2
The Grok image model ID. See the Models page for available model IDs.
grok-imagine-image, grok-imagine-image-quality "grok-imagine-image-quality"
A text instruction that describes the requested edit.
1"Replace the daytime sky with a soft sunset and preserve the building"
One source image. Use this field instead of images.
- Option 1
- Option 2
Two or three source images. Use this field instead of image.
2 - 3 elementsA source image represented by url or the compatibility alias image_url.
- Option 1
- Option 2
The number of edited images to generate. Use an integer from 1 through 10.
1 <= x <= 10The 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"
The requested output resolution.
1k, 2k "1k"
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