编辑图像
OpenAI Images API 兼容的图像编辑接口。默认同步返回编辑后的图片结果;如需异步提交,在请求 URL 上携带 ?async=true,接口会返回图片任务 ID,可通过 /v1/tasks/{id} 查询结果。
GPT Image 2.5 / 2.6 支持 JSON images 引用数组,或 multipart image / image[] 文件上传;输入图片支持 PNG、JPEG、WebP,最多 16 张。
markup 是单独上传的透明 PNG 标注层,与 mask 互斥。GPT Image 2.6 可输出 GIF;编辑接口不支持 SVG 输出或 SVG 输入。
stream=true 时返回 image_edit.partial_image 和 image_edit.completed SSE 事件;GIF 不支持流式输出。
官方参数说明:https://developers.openai.com/api/reference/resources/images/methods/edit 。
Authorization
bearerAuth 使用 Authorization Bearer API Key 进行鉴权。
In: header
Query Parameters
是否异步提交。
falseTypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://example.com/v1/images/edits?async=true" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2.6-flare", "prompt": "将标注圈出的花瓶改为蓝色,保留其他细节", "images": [ { "image_url": "https://example.com/source.webp" } ], "markup": { "image_url": "https://example.com/markup.png" }, "complexity": "low", "output_format": "png" }'{
"created": 0,
"data": [
{
"b64_json": "string"
}
],
"background": "opaque",
"output_format": "png",
"quality": "low",
"size": "string",
"safety_identifier": "string",
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
},
"total_tokens": 0
},
"svg_usage": {
"model": "string",
"input_tokens": 0,
"output_tokens": 0,
"reasoning_tokens": 0,
"total_tokens": 0
}
}{
"error": {
"code": "string",
"message": "string",
"request_id": "string"
}
}图像生成
OpenAI Images API 兼容的图像生成接口。默认同步返回图片结果;如需异步提交,在请求 URL 上携带 `?async=true`,接口会返回图片任务 ID,可通过 `/v1/tasks/{id}` 查询结果。 GPT Image 2.5 / 2.6 使用专用 GPT Image 请求定义;Seedream 等模型使用各自的参数定义。 GPT Image 2.6 支持 complexity、动画 GIF 和 SVG;SVG 仅用于此生成接口。 `stream=true` 时返回 SSE,包含 `image_generation.partial_image` 和 `image_generation.completed` 事件。 官方参数说明:https://developers.openai.com/api/docs/guides/image-generation 。
异步任务查询
仅适用于在 `/v1/images/generations?async=true` 或 `/v1/images/edits?async=true` 提交后返回的图片任务 ID。 建议客户端按固定间隔轮询该接口:当任务为 `succeeded` 且 `data.images` 非空时读取图片结果;当任务为 `failed` 时读取 `error` 字段并停止轮询。图片结果可能包含 `url` 或 `b64_json`,具体取决于模型、渠道能力和提交请求中的 `response_format`。