创建图像编辑
在 CometAPI 中使用 POST /v1/images/edits 通过 multipart 上传、mask、GPT 图像模型和编码图像输出控制来编辑图像。
在以下情况使用此路由
- 你已经有一张源图像,并希望基于 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 路由后遵循提供商特定的编辑行为
授权
Bearer token authentication. Use your CometAPI key.
请求体
Source image file. Start with one PNG or JPG input for the simplest flow.
Edit instruction describing the change you want.
"Add a small red ribbon to the paper boat."
The image editing model to use. Choose a supported model from the Models page.
Optional PNG mask. Transparent areas mark the regions to edit. The mask dimensions must match the source image exactly.
Number of edited images to return.
Quality setting for models that support it.
high, medium, low 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 Encoded image type for GPT image edit results returned in data[].b64_json. For example, use jpeg for a JPEG payload.
"jpeg"
Requested output size when supported by the selected model.
响应
Edited image result.
Background mode returned by models that expose it.
Encoded image type returned by GPT image models.
Quality level returned by models that expose it.
Output size returned by models that expose it.