GPT-Image-2.6
使用下列任一模型生成或编辑图片。结果在同一次响应中返回,无需轮询任务。
| 模型 ID | 适用场景 |
|---|---|
gpt-image-2.6-flare | 交互创作与快速迭代。 |
gpt-image-2.6-sunburst | 精细构图与参考图编辑。 |
接口
使用 https://api.uniall.ai,通过 Authorization: Bearer $UNIAI_API_KEY 鉴权。请将示例中的 Key、参考图 URL 和本地文件路径替换为自己的值。
| 方法 | 路径 | 输入 |
|---|---|---|
| POST | /v1/images/generations | JSON 文生图请求。 |
| POST | /v1/images/edits | JSON 参考图或 multipart 图片文件。 |
参数
两个模型使用相同字段,JSON 参数放在顶层。complexity 控制规划计算量,与 quality 独立,可用于生图和编辑。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 上方两个精确模型 ID 之一。 |
prompt | string | 是 | 生图或编辑指令,最多 32,000 个字符。 |
images | object array | JSON 编辑时二选一 | 按顺序传入 1–16 个参考图对象,URL 放在 images[].image_url。 |
image_urls | string array | JSON 编辑时二选一 | 兼容写法,按顺序传入 1–16 个参考图 URL。 |
mask | object | 否 | 仅编辑,URL 放在 mask.image_url,作用于第一张参考图。 |
markup | object | 否 | 编辑标注层,URL 放在 markup.image_url;multipart 使用独立 markup 文件。 |
size | string | 否 | auto 或 WIDTHxHEIGHT,默认 auto。静态图和 GIF 限制见下方。 |
quality | string | 否 | auto、low、medium、high、xhigh、max;省略时使用默认质量。 |
complexity | string | 否 | low、medium、high,独立控制规划计算量。控制台默认选 high;API 可显式指定。 |
n | integer | 否 | 请求数量 1–10,默认 1。GIF 受总像素预算限制,建议为 1。 |
output_format | string | 否 | png(默认)、jpeg、webp、gif。编辑使用 PNG/JPEG/WebP;GIF 限制见下方。 |
background | string | 否 | auto、opaque、transparent。透明背景须使用 PNG 或 WebP。 |
output_compression | integer | 否 | 0–100,仅用于 JPEG/WebP;显式 0 会保留,省略时不设置默认值。 |
frame_count | integer | 否 | 仅 GIF,2–16;省略时按 9 帧计算请求像素预算。 |
frame_duration_ms | integer | 否 | 仅 GIF,20–2000 毫秒,默认 200;编码时按 10 毫秒取整。 |
safety_identifier | string | 否 | 终端用户标识散列,最多 128 个字符。 |
prompt_rewriter | JSON | 否 | 兼容 JSON,保留显式 0/false;结构及可用性依账户权限,未规定公共结构。 |
response_format | string | 否 | url 或 b64_json,建议显式指定返回方式。 |
moderation | string | 否 | auto 或 low。 |
JSON 编辑选择 images 对象数组或 image_urls 字符串数组。mask 和 markup 使用包含 image_url 的对象,见下方示例。
静态图使用明确宽高时,两边均须为 16 的倍数,最长边不超过 3,840 像素,宽高比在 1:3–3:1 之间,总像素为 655,360–8,294,400。例如 1024x1024、1024x1536、1536x1024、1536x864 或 2048x1152。
参考图支持 PNG、JPEG、WebP,每张不超过 50 MiB。URL 须保持可访问,不依赖登录、Cookie 或自定义请求头。也可以使用完整图片 Data URL,例如 data:image/png;base64,...。
生成图片
curl "https://api.uniall.ai/v1/images/generations" \
-H "Authorization: Bearer $UNIAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.6-flare",
"prompt": "A sculptural burgundy glass perfume bottle on ivory travertine, warm side lighting, no lettering",
"size": "1536x864",
"quality": "high",
"complexity": "high",
"n": 1,
"output_format": "png",
"response_format": "url"
}'
需要透明背景时,设置 background: "transparent",并使用 output_format: "png" 或 "webp"。
参考图与蒙版编辑
JSON 参考图字符串放在 image_urls,蒙版 URL 使用 mask.image_url:
curl "https://api.uniall.ai/v1/images/edits" \
-H "Authorization: Bearer $UNIAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.6-sunburst",
"prompt": "Replace only the masked background with a warm cream studio backdrop; keep the product unchanged",
"image_urls": ["https://images.example.com/product.png"],
"mask": {
"image_url": "https://images.example.com/mask.png"
},
"size": "1024x1024",
"quality": "high",
"complexity": "high",
"n": 1,
"output_format": "png",
"response_format": "url"
}'
蒙版为一张带 alpha 通道的 PNG,小于 4 MiB,尺寸须与第一张参考图一致。透明区域表示编辑范围。无需蒙版时省略 mask。
编辑本地文件
curl "https://api.uniall.ai/v1/images/edits" \
-H "Authorization: Bearer $UNIAI_API_KEY" \
-F "model=gpt-image-2.6-sunburst" \
-F "prompt=Replace only the masked background with a warm cream studio backdrop; keep the product unchanged" \
-F "image[]=@product.png" \
-F "mask=@mask.png" \
-F "size=1024x1024" \
-F "quality=high" \
-F "complexity=high" \
-F "n=1" \
-F "output_format=png" \
-F "response_format=url"
多图时重复 image[],最多 16 张。让 cURL 自动设置 multipart Content-Type。
标注编辑
将标注层与参考图分开传入:
curl "https://api.uniall.ai/v1/images/edits" \
-H "Authorization: Bearer $UNIAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.6-sunburst",
"prompt": "Change only the annotated bottle to blue and remove the annotation strokes",
"images": [{"image_url": "https://images.example.com/product.png"}],
"markup": {"image_url": "https://images.example.com/overlay.png"},
"complexity": "high",
"quality": "high",
"size": "1024x1024",
"output_format": "png",
"response_format": "url"
}'
标注层须为小于 50 MiB 的透明 PNG,与方向校正后的第一张参考图同尺寸。首图和标注层各不超过 16,777,216 像素。markup 不可与 mask 或 prompt_rewriter 组合。
本地文件使用:
curl "https://api.uniall.ai/v1/images/edits" \
-H "Authorization: Bearer $UNIAI_API_KEY" \
-F "model=gpt-image-2.6-sunburst" \
-F "prompt=Change only the annotated bottle to blue and remove the annotation strokes" \
-F "image[]=@product.png" \
-F "markup=@overlay.png" \
-F "complexity=high" \
-F "quality=high" \
-F "size=1024x1024" \
-F "output_format=png" \
-F "response_format=url"
生成 GIF
使用生成接口,设置 output_format: "gif",在 prompt 中描述动作和循环效果,并指定帧数和帧时长:
curl "https://api.uniall.ai/v1/images/generations" \
-H "Authorization: Bearer $UNIAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.6-flare",
"prompt": "A silver tabby kitten dancing, alternating its front paws in a smooth seamless loop, fixed camera, cream background",
"complexity": "medium",
"quality": "high",
"output_format": "gif",
"size": "256x256",
"n": 1,
"frame_count": 12,
"frame_duration_ms": 120,
"response_format": "b64_json"
}'
GIF 宽高须为 16 的倍数,每边不超过 3,840 像素,且 宽 × 高 × frame_count × n ≤ 8,294,400。GIF 单帧不受静态图最小像素数限制。GIF 不可搭配蒙版、标注层、压缩或提示词重写。这些参数用于请求控制,实际帧数、时长、尺寸和数量仍可能不同。
当前服务仅支持 GIF 生成,暂不支持 GIF 参考图编辑。响应可能额外包含 PNG 精灵图,请逐项检查 data[]。
响应
设置 response_format: "url" 时,从 data[].url 读取结果。示例:
{
"data": [
{
"url": "https://images.example.com/result.png"
}
]
}
设置 response_format: "b64_json" 时,将每个 data[].b64_json 解码为文件字节。该值不带 Data URL 前缀。以下内容已缩短:
{
"data": [
{
"b64_json": "R0lGODlh..."
}
]
}
实际文件格式、尺寸、动画帧数、帧时长和结果数量可能与请求不同。响应中的可选 output_format、size 字段描述可识别的实际结果。请检查收到的文件,不要仅根据请求的扩展名或数量判断。结果保留原始 GIF 文件和实际 MIME 类型;不因格式、尺寸、帧数或数量与请求不同而拒绝结果,也不自动转换或追加生成以补齐 n。
请求失败或超时后不要自动重复提交;保留错误信息和请求 ID 用于排查。
仅支持同步 Images API,不支持 Responses 会话、File ID 服务或流式输出;partial_images 须省略或设为 0。