生成图像
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 。
Authorization
bearerAuth 使用 Authorization Bearer API Key 进行鉴权。
In: header
Query Parameters
是否异步提交。
falseRequest Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://example.com/v1/images/generations?async=true" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2.5-flare", "prompt": "一张未来感 API 网关控制台截图", "size": "1024x1024" }'{
"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"
}
}GPT Image 2.6 对接说明
Previous Page
图像编辑
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 。