Skip to main content
POST
使用此路由可在 CometAPI 上通过 OpenAI 兼容的 multipart 上传来编辑现有图像。

在以下情况使用此路由

  • 你已经有一张源图像,并希望基于 prompt 进行编辑
  • 你可能需要使用 mask 来进行定向修改
  • 你可以处理 multipart 文件上传,而不是纯 JSON 请求

安全的首次请求

  • 从一个 PNG 或 JPG 文件开始
  • 在基础编辑流程跑通之前先跳过 mask
  • 在此路由上发起 GPT 图像编辑请求时,使用 model: "gpt-image-2"
  • 使用一条简短指令,只要求一个可见变化
  • data[0].b64_json 读取编辑后的结果
  • 当你需要 JPEG 负载时,设置 output_format: "jpeg"
  • 预期会比普通图像生成有更长的延迟

模型行为

  • 此路由上的 GPT 图像编辑模型会返回内联的 base64 图像数据
  • output_format 控制 b64_json 中编码图像的类型
  • response_format 仅在模型支持 URL 输出时才有意义
  • qwen-image-edit 在同一个 CometAPI 路由后遵循提供商特定的编辑行为

授权

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

请求体

multipart/form-data
image
file
必填

Source image file. Start with one PNG or JPG input for the simplest flow.

prompt
string
必填

Edit instruction describing the change you want.

示例:

"Add a small red ribbon to the paper boat."

model
string
默认值:gpt-image-2

The image editing model to use. Choose a supported model from the Models page.

mask
file

Optional PNG mask. Transparent areas mark the regions to edit. The mask dimensions must match the source image exactly.

n
string
默认值:1

Number of edited images to return.

quality
enum<string>

Quality setting for models that support it.

可用选项:
high,
medium,
low
response_format
enum<string>

Requested response container when supported by the selected model. GPT image edit models return data[].b64_json; use output_format to choose the encoded image type.

可用选项:
url,
b64_json
output_format
string

Encoded image type for GPT image edit results returned in data[].b64_json. For example, use jpeg for a JPEG payload.

示例:

"jpeg"

size
string

Requested output size when supported by the selected model.

响应

200 - application/json

Edited image result.

created
integer
必填
usage
object
必填
data
object[]
必填
background
string

Background mode returned by models that expose it.

output_format
string

Encoded image type returned by GPT image models.

quality
string

Quality level returned by models that expose it.

size
string

Output size returned by models that expose it.