编辑 gpt-image-2
POST /v1/images/edits
说明
给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。
为提供的提示和参数创建完成
官方文档:https://platform.openai.com/docs/api-reference/images/createEdit
概览
| Method | POST |
|---|---|
| Path | /v1/images/edits |
| Type | http |
| Status | 1 |
| Module | 2102810 |
| Folder | 84826875 |
参数
{ "query": [], "path": [], "cookie": [], "header": [ { "id": "qb8tEQbCty", "name": "Accept", "required": true, "description": "", "type": "string", "enable": true, "sampleValue": "application/json" }, { "required": false, "description": "", "type": "string", "id": "gBxcCbXhsa", "enable": true, "name": "Authorization", "sampleValue": "Bearer {{YOUR_API_KEY}}" } ] }
请求体
{ "type": "multipart/form-data", "parameters": [ { "required": true, "description": "要编辑的图片。必须是受支持的图片文件或图片数组。图片应小于16张、50MB以内。\n", "type": "file", "id": "b3jXL90sE5", "enable": true, "name": "image", "schema": { "format": "binary", "type": "string" } }, { "required": true, "description": "所需图像的文本描述。\n", "type": "string", "id": "TeGM3GrLP9", "enable": true, "name": "prompt", "sampleValue": "将他们合并在一个图片里面" }, { "required": false, "description": "一张附加图片,其完全透明区域(例如,alpha 值为零)指示应编辑 image 位置。如果提供了多张图片,则遮罩将应用于第一张图片。必须是有效的 PNG 文件,小于 4MB,且尺寸与 image 相同。\n", "type": "string", "id": "i7NJKm41S6", "enable": false, "name": "mask", "sampleValue": "" }, { "required": false, "description": "用于生成图像的模型。仅 gpt-image-1, gpt-image-1-all , flux-kontext-pro , flux-kontext-max,gpt-image-2 ,gpt-image-2-all", "type": "string", "id": "9puBSlhkv8", "enable": true, "name": "model", "sampleValue": "gpt-image-2" }, { "required": false, "description": "要生成的图像数量。必须介于 1 到 10 之间。\n", "type": "string", "id": "UwcVbSRbom", "enable": true, "name": "n", "sampleValue": "1" }, { "required": false, "description": "图片画质\n可选:low 、 medium 、 high 、 auto(默认)", "type": "string", "id": "NnJEH3V1Lk", "enable": false, "name": "quality", "sampleValue": "" }, { "required": false, "description": "图片尺寸\n1024x1024 正方形\n1536x1024 横版\n1024x1536 竖版\n2048x2048 2K正方形\n2048x1152 2K横版\n3840x2160 4K横版\n2160x3840 4K竖版\nauto 默认\n尺寸严格限制规则\n1.\n图片最大边长 ≤ 3840px\n2.\n宽高两边像素均为 16px 的倍数\n3.\n长边 / 短边 比值 ≤ 3:1\n4.\n总像素范围:最小 655360 ~ 最大 8294400", "type": "string", "id": "cBVZfsBqpM", "enable": true, "name": "size", "sampleValue": "1024x1536" }, { "required": false, "description": "允许为生成的图像的背景设置透明度。其值必须为 “不透明(opaque)” 或 “自动(auto)”(默认值)之一。当使用 “自动(auto)” 时,模型将自动为图像确定最佳背景。\n", "type": "string", "id": "eWjSCaxckX", "enable": false, "name": "background", "sampleValue": "transparent" }, { "required": false, "description": "控制由 gpt-image-2 生成的图像的内容审核级别。可以设置为 “low” 以进行限制较少的过滤,也可以设置为 “auto”(默认值)。\n", "type": "string", "id": "R3LlLzVkmp", "enable": false, "name": "moderation", "sampleValue": "low" } ], "jsonSchema": { "type": "object", "properties": { "image": { "description": "要编辑的图片。必须是受支持的图片文件或图片数组。对于 gpt-image-1,每张图片应为小于 25MB 的 png、webp 或 jpg 文件。对于 dall-e-2,您只能提供一张图片,并且该图片应为小于 4MB 的方形 png 文件。", "type": "string" }, "prompt": { "description": "所需图像的文本描述。dall-e-2 的最大长度为 1000 个字符,gpt-image-1 的最大长度为 32000 个字符。", "type": "string" }, "mask": { "description": "一张附加图片,其完全透明区域(例如,alpha 值为零)指示应编辑 image 位置。如果提供了多张图片,则遮罩将应用于第一张图片。必须是有效的 PNG 文件,小于 4MB,且尺寸与 image 相同。", "type": "string" }, "model": { "description": "用于生成图像的模型。仅支持 dall-e-2 和 gpt-image-1。除非使用特定于 gpt-image-1 参数,否则默认为 dall-e-2。", "type": "string" }, "n": { "description": "要生成的图像数量。必须介于 1 到 10 之间。", "type": "integer" }, "quality": { "description": "生成图像的质量。只有 gpt-image-1 支持 high、medium 和 low 质量。dall-e-2 仅支持 standard 质量。默认为 auto。", "type": "string" }, "response_format": { "description": "返回生成图像的格式。必须是 url 或 b64_json 之一。URL 在图像生成后 60 分钟内有效。此参数仅适用于 dall-e-2,因为 gpt-image-1 始终返回 base64 编码的图像。", "type": "string" }, "size": { "description": "生成图像的尺寸。对于 gpt-image-1,必须为 1024x1024、1536x1024(横向)、1024x1536(纵向)或 auto(默认值)之一;对于 dall-e-2,必须为 256x256、512x512 或 1024x1024 之一。", "type": "string" } }, "required": [ "image", "prompt", "mask", "model", "n", "quality", "response_format", "size" ], "x-apifox-orders": [ "image", "prompt", "mask", "model", "n", "quality", "response_format", "size" ] }, "required": false, "mediaType": "", "examples": [ { "value": "{\n \"size\": \"1024x1024\",\n \"prompt\": \"一直可爱的小猪\",\n \"model\": \"gpt-image-1\",\n \"n\": 1\n}", "mediaType": "application/json" }, { "value": "{\n \"size\": \"1024x1024\",\n \"prompt\": \"一直可爱的小猪\",\n \"model\": \"gpt-image-1\",\n \"n\": 1\n}", "mediaType": "multipart/form-data", "description": "" } ], "oasExtensions": "" }
响应
[ { "id": 666472624, "name": "OK", "code": 200, "contentType": "json", "jsonSchema": { "type": "object", "properties": { "created": { "type": "integer" }, "background": { "type": "string" }, "data": { "type": "object", "properties": { "b64_json": { "type": "string" } }, "x-apifox-orders": [ "b64_json" ], "required": [ "b64_json" ] }, "output_format": { "type": "string" }, "quality": { "type": "string" }, "size": { "type": "string" } }, "required": [ "created", "background", "data", "output_format", "quality", "size" ], "x-apifox-orders": [ "created", "background", "data", "output_format", "quality", "size" ] }, "itemSchema": {}, "description": "", "mediaType": "", "headers": [], "oasExtensions": "" } ]