GPT Image 2.6
- 新增 GIF 动图与 SVG 矢量输出,同一条 Images 接口
- 出图前规划档位 complexity:low / medium / high,单独调不额外计费
- 同步返回,图片在 data[].b64_json,无需轮询
认证
所有接口均使用 Bearer Token 进行认证。 获取 API Key:访问控制台 创建。 请求时在请求头中添加: ``http Authorization: Bearer YOUR_OAIRoute_KEY ``
Every endpoint authenticates with a Bearer token. Get an API key from the console. Add it to the request headers: ``http Authorization: Bearer YOUR_OAIRoute_KEY ``
请求结构
请求体是平铺的 JSON,创作字段与输出字段都在顶层,没有 content 数组包装。
GPT Image 2.6 在 2.5 的基础上多了三样能力,都靠请求字段控制,不需要换路径:
complexity—— 出图前的规划算力,与quality各自独立。output_format: gif+frame_count/frame_duration_ms—— 动图输出。output_format: svg+svg—— 矢量输出,由单独的写作模型产出 SVG 源码。
响应是同步的:请求会阻塞到图片生成完成,结果直接在 data[].b64_json 里返回,没有 task_id,也不需要轮询。图片是 Base64,客户端自行解码落盘。
The body is flat JSON: creative fields and output fields sit at the top level, with no content array wrapper.
GPT Image 2.6 adds three capabilities over 2.5, all driven by request fields on the same path:
complexity— compute spent planning the image, independent ofquality.output_format: gifplusframe_count/frame_duration_ms— animated output.output_format: svgplussvg— vector output authored by a separate model.
The response is synchronous: the request blocks until the image is ready and returns it inline in data[].b64_json. There is no task_id and nothing to poll; decode the Base64 and write the file.
支持的场景
| 场景 | 字段组合 |
|---|---|
| 文生图 | prompt |
| 单图编辑 | prompt + image(1 张) |
| 多图参考 | prompt + image(2 到 16 张) |
| 蒙版重绘 | prompt + image + mask_url |
| 固定画布 | size 写精确像素 |
| 动图(GIF) | output_format: "gif" + frame_count + frame_duration_ms |
| 矢量图(SVG) | output_format: "svg" + svg |
| 高复杂度版面 | complexity: "high" + 含大量文字或图层的 prompt |
传入 image 后自动进入编辑模式,不需要额外参数切换。mask_url 单独传无效。GIF 与 SVG 都需要显式写 output_format,只传帧参数不会触发动图。
| Scenario | Field combination |
|---|---|
| Text to image | prompt |
| Single-image edit | prompt + image (1 image) |
| Multi-image reference | prompt + image (2 to 16 images) |
| Masked repaint | prompt + image + mask_url |
| Fixed canvas | size written as exact pixels |
| Animated GIF | output_format: "gif" + frame_count + frame_duration_ms |
| Vector SVG | output_format: "svg" + svg |
| Dense layouts | complexity: "high" + a prompt with heavy text or many layers |
Passing image enters edit mode automatically; no extra parameter is needed. mask_url alone has no effect. GIF and SVG both require an explicit output_format; frame fields on their own do not produce animation.
请求参数
提交后同步返回图片本身,不返回任务 ID。图片在 data[].b64_json,是 Base64 字符串,客户端解码后落盘。
取值 gpt-image-2.6-flare 或 gpt-image-2.6-sunburst。两者单价相同:flare 偏速度与批量迭代,sunburst 偏细节与多轮打磨。
画面描述,上限 32000 字符,中英文均可。建议写清主体、场景、构图、风格、光线,以及哪些必须保留、哪些需要改动。做 GIF 时把动作与循环方式写进提示词(例如「镜头固定,提灯摆动一个来回,结尾回到起始姿态」),模型按描述编帧;做 SVG 时描述形状与配色,而不是摄影质感。
默认 auto。可写宽高比 1:1、3:2、2:3、4:3、3:4、5:4、4:5、16:9、9:16、2:1、1:2、21:9、9:21、3:1、1:3,也可写精确像素如 1536x864。GIF 模式下只接受 auto 或精确像素,不接受比例。
输出档位,取值 1k(默认)、2k、4k,与比例形式的 size 配合决定像素;size 写精确像素时该字段失效。
渲染画质,取值 low、medium、high、xhigh、max、auto,默认 auto。只影响像素渲染,不影响出图前的规划;SVG 模式下决定参考图的精细度,而不是 SVG 本身的推理深度。草稿用 low,成品逐个上调比较细节、延迟与成本。
出图前的规划算力,取值 low、medium、high,默认 high。与 quality 两个维度独立,单独调这项不额外计费。 局部改色、换背景、改招牌这类窄任务用 low 更快;文字多、版式分层、多个物体互相遮挡时用 high,但耗时更长,也可能改动到不该动的地方。
生成张数,取值 1 到 4,默认 1。必须传数字,不能传字符串。output_format 为 svg 时只能是 1,GIF 也建议一次一张,多张会成倍占用总像素预算。
参考图,最多 16 张公网地址。传入即进入编辑模式:第一张是主体,其余作为场景、光线或风格参考。SVG 与 GIF 都可以带参考图,但参考图只影响写之前的那张底图,不会把源图直接矢量化。
蒙版,仅配合 image 使用,只作用于第一张参考图。透明像素表示可重绘区域。像素尺寸必须与第一张参考图完全一致,而不是与输出尺寸一致。GIF 模式不支持蒙版。
取值 png(默认)、jpeg、webp、gif、svg。PNG 与 WebP 支持透明背景。gif 与 svg 是 2.6 新增,2.5 及更早的模型传入会返回 400。
GIF 帧数,取值 2 到 16,默认 9。只能与 output_format: "gif" 一起使用。帧数 × 尺寸 × n 的总像素要落在模型预算内,超了会报错,需要下调其中之一。
GIF 每帧停留毫秒数,默认 200,最小 20,按 10 毫秒取整。总时长 = 帧数 × 每帧时长,例如 9 帧 × 200ms = 1.8 秒一个循环。
仅 output_format: "svg" 时使用,决定由哪个模型、花多少推理来写 SVG 源码。svg.model 默认 gpt-6.1-sol。顶层 model 仍然负责参考图,SVG 写作模型单独指定,两者不要混用。
压缩比,取值 0 到 100,仅对 jpeg 与 webp 生效。GIF 与 SVG 不支持该字段。
取值 transparent、opaque、auto。transparent 需要搭配 png 或 webp,不能与 jpeg 同时使用。
内容审核档位,取值 auto、low,默认 low。
The image comes back inline: no task ID. It sits in data[].b64_json as a Base64 string for the client to decode.
gpt-image-2.6-flare or gpt-image-2.6-sunburst. Both cost the same: flare favors speed and batch iteration, sunburst favors detail and repeated refinement.
The scene description, up to 32,000 characters, in Chinese or English. Spell out the subject, setting, composition, style, lighting, and what must stay versus what must change. For GIF, describe the motion and the loop (for example, "fixed camera, the lantern swings once and settles back to its starting pose"); for SVG, describe shapes and colors rather than photographic texture.
Defaults to auto. Accepts aspect ratios 1:1, 3:2, 2:3, 4:3, 3:4, 5:4, 4:5, 16:9, 9:16, 2:1, 1:2, 21:9, 9:21, 3:1, 1:3, or exact pixels such as 1536x864. In GIF mode only auto or exact pixels are accepted; ratios are not.
Output tier: 1k (default), 2k, 4k. Combined with a ratio-form size to determine pixels; ignored when size gives exact pixels.
Render quality: low, medium, high, xhigh, max, auto, default auto. It affects pixel rendering only, not pre-render planning; in SVG mode it sets the fidelity of the reference image, not the depth of the SVG authoring. Use low for drafts and step up for finals.
Planning compute before rendering: low, medium, high, default high. Independent of quality, and changing it alone carries no extra charge. Narrow edits such as recoloring or swapping a sign are faster at low; heavy text, layered layouts and occluded objects benefit from high, at the cost of latency and a higher chance of unintended changes.
Images per call, 1 to 4, default 1. Must be a number, not a string. With output_format: "svg" it can only be 1; for GIF, prefer one at a time since multiple results multiply the pixel budget.
Reference images, up to 16 public URLs. Supplying one enters edit mode: the first is the subject, the rest inform scene, light or style. SVG and GIF can take references too, but they only shape the underlying image, not vectorize the source directly.
The mask, used only with image, applied only to the first reference image. Transparent pixels mark the repaintable area. Its pixel size must match the first reference image exactly, not the output size. GIF mode does not support masks.
png (default), jpeg, webp, gif, svg. PNG and WebP support transparency. gif and svg are new in 2.6; passing them to 2.5 or earlier returns 400.
GIF frames, 2 to 16, default 9. Only valid with output_format: "gif". Frames × dimensions × n must fit the model's pixel budget; exceeding it returns an error, so lower one of them.
Delay per GIF frame in milliseconds, default 200, minimum 20, rounded to 10 ms. Total length = frames × delay, e.g. 9 frames × 200 ms = a 1.8-second loop.
Used only with output_format: "svg"; decides which model authors the SVG and how much reasoning it spends. The top-level model still covers the reference image; the SVG author is selected separately.
Compression, 0 to 100, only for jpeg and webp. Not supported for GIF or SVG.
transparent, opaque, auto. transparent requires png or webp and cannot be combined with jpeg.
Content-moderation level: auto, low, default low.
动图输出(GIF)
GIF 是 2.6 新增的输出格式,走同一条 POST /v1/images/generations,只多两个字段:
| 字段 | 取值 | 默认 | 说明 |
|---|---|---|---|
frame_count | 2 到 16 | 9 | 帧数,决定动作的平滑度 |
frame_duration_ms | ≥ 20,10ms 取整 | 200 | 每帧停留时长,决定播放速度 |
总时长就是 frame_count × frame_duration_ms。9 帧 × 200ms = 1.8 秒一个循环。
写提示词的要点
- 写清主体 + 动作 + 循环:谁在动、怎么动、结尾回到哪里。只写静态画面会得到近似重复的帧。
- 镜头最好写明固定还是不固定;镜头运动叠在物体运动上时帧数不够容易抖。
- GIF 只有 256 色,渐变与照片级光照会明显分层,适合图形、插画、图标类动效,不适合写实人像。
尺寸与预算
size在 GIF 模式下只接受auto或精确像素(宽高都能被 16 整除),不接受16:9这类比例写法。- 帧数、尺寸与
n三者相乘要落在模型的总像素预算内,超了会直接报错,处理办法是调小其中一项。 mask_url、output_compression、流式与局部预览在 GIF 模式下都不可用。
GIF is a new output format in 2.6, on the same POST /v1/images/generations path, adding exactly two fields:
| Field | Range | Default | Meaning |
|---|---|---|---|
frame_count | 2 to 16 | 9 | Frame count, which sets motion smoothness |
frame_duration_ms | ≥ 20, rounded to 10 ms | 200 | Delay per frame, which sets playback speed |
Total length is frame_count × frame_duration_ms: 9 frames × 200 ms gives a 1.8-second loop.
Prompting
- Describe subject + motion + loop: who moves, how, and where it ends up. A static description yields near-duplicate frames.
- Say whether the camera is locked; camera motion stacked on object motion jitters at low frame counts.
- GIF is 256 colors, so gradients and photographic lighting band badly. It suits graphics, illustration and icon motion, not realistic portraits.
Size and budget
- In GIF mode
sizeaccepts onlyautoor exact pixels (both edges divisible by 16); ratio strings such as16:9are rejected. - Frames × dimensions ×
nmust fit the model's total pixel budget; exceeding it errors out, so lower one of the three. mask_url,output_compression, streaming and partial previews are unavailable in GIF mode.
矢量输出(SVG)
output_format: svg 返回的不是栅格图,而是 UTF-8 的 SVG XML 源码,放在 data[0].b64_json 里,Base64 解码后直接存成 .svg 即可,可以直接进设计工具或前端代码库。
流程分两步:先用顶层 model 与 quality 生成一张参考图,再由 svg 指定的模型把这张图写成矢量。所以顶层 model 决定底图长什么样(构图、配色、细节),svg.model 决定矢量化写得好不好。
svg 对象
| 字段 | 类型 | 说明 |
|---|---|---|
svg.model | string | 默认 gpt-6.1-sol。负责写 SVG 的模型,与顶层图像模型是两个东西;未开启 SVG 模型选择时不要传整个 svg 对象 |
svg.reasoning.effort | string | 写作模型的推理量,取值 none、minimal、low、medium、high、xhigh、max;省略即用该模型的默认值 |
约束
n只能是1,一次只出一份 SVG。- 不支持流式与局部预览(
stream/partial_images),也不支持output_compression。 - 输出是静态矢量:没有脚本、没有外链资源、不会内嵌位图。需要交互或动画请自行在 SVG 上加。
- 生成的 SVG 不能作为编辑接口的栅格输入再用,要改就在同一路径重新生成。
- 计费用量与栅格图分开统计,响应里另有
svg_usage字段记录写作模型的 token 消耗。
写提示词的要点
- 描述形状、层级与配色,而不是光影质感;「扁平插画、双色、几何构成」比「电影级打光」有效。
- 图标与 logo 类需求写明「单色、可缩放、留白均匀」,避免生成大量细碎路径导致文件体积失控。
- 文字尽量少:SVG 里的文字通常被转成路径,事后无法直接改字,需要改字请重新生成并写明字体风格。
output_format: svg returns no raster image but UTF-8 SVG XML source in data[0].b64_json. Decode the Base64, save it as .svg, and it goes straight into a design tool or a front-end codebase.
It runs in two stages: the top-level model and quality first produce a reference image, then the model named in svg authors that image as vectors. So the top-level model decides how the underlying image looks (composition, palette, detail) and svg.model decides how well it is vectorized.
The svg object
| Field | Type | Meaning |
|---|---|---|
svg.model | string | Defaults to gpt-6.1-sol. The model that authors the SVG, distinct from the top-level image model; omit the whole svg object when SVG model selection is off |
svg.reasoning.effort | string | Reasoning spent by the author: none, minimal, low, medium, high, xhigh, max; omitted means that model's default |
Constraints
nmust be1; one SVG per call.- No streaming or partial previews (
stream/partial_images), and nooutput_compression. - Output is static vector: no scripts, no external resources, no embedded rasters. Add interaction or animation yourself.
- The produced SVG cannot be fed back to the edit endpoint as a raster input; regenerate on the same path to revise it.
- Billing usage is tracked separately from raster output; the response carries an
svg_usageblock for the author model's tokens.
Prompting
- Describe shapes, hierarchy and palette rather than lighting texture; "flat illustration, two colors, geometric" works better than "cinematic lighting".
- For icons and logos, ask for "single color, scalable, even margins" so the output doesn't balloon into thousands of tiny paths.
- Keep text minimal: text in SVG is usually converted to paths, so it can't be edited afterwards — regenerate with the type style spelled out instead.
尺寸约束
精确像素:宽高都必须能被 16 整除,单边不超过 3840,长短边比例不超过 3:1,总像素在 655360 到 8294400 之间。
比例 + resolution:比例形式与档位组合出像素,例如 1:1 在 1k / 2k / 4k 下分别是 1024×1024、2048×2048、2880×2880。
超过 2560×1440 的输出稳定性会下降,属于实验范围。GIF 的尺寸还要受帧数挤占的总像素预算约束,通常比静态图更小。
Exact pixels: both edges divisible by 16, neither over 3840, long-to-short ratio at most 3:1, total pixels between 655,360 and 8,294,400.
Ratio + resolution: the ratio and tier combine into pixels; 1:1 gives 1024×1024, 2048×2048 and 2880×2880 at 1k, 2k and 4k.
Output above 2560×1440 is less stable and considered experimental. GIF dimensions also compete with frames in the total pixel budget, so they usually run smaller than stills.
响应
同步返回,与 OpenAI Images API 一致。返回体里只有 b64_json 与 generation_id,没有图片 URL,客户端解码 Base64 后自行落盘。
字段说明
created(integer) — 生成完成时间,Unix 秒。data(array) — 每项对应一张输出图。data[].b64_json(string) — Base64 图片数据。PNG / JPEG / WebP / GIF 解码后即原文件;SVG 解码后是 XML 文本。data[].generation_id(string) — 本次生成的唯一标识,可用于日志关联与排障。data[].revised_prompt(string / 可选) — 模型改写后的提示词,GPT Image 系列通常不返回。size(string) — 实际输出尺寸,如1536x1024。output_format(string) — 实际输出格式,与请求一致。quality(string) — 实际使用的画质档位。background(string / 可选) —transparent或opaque。usage(object) — 计费用量,含input_tokens、output_tokens、total_tokens,以及图片 / 文本分项。svg_usage(object / 可选) — 仅 SVG 输出时返回,记录写作模型的 token 消耗。
生成是同步的,请求会阻塞到图片出完。普通尺寸通常几十秒,复杂提示词官方给出上限约 2 分钟,客户端超时建议设到 3 分钟以上。WebP 与 JPEG 比 PNG 快,对延迟敏感时优先选这两种。
Returned synchronously, in the OpenAI Images API shape. The body carries only b64_json and generation_id; there is no image URL, so decode the Base64 and write the file yourself.
Fields
created(integer) — completion time, Unix seconds.data(array) — one entry per output image.data[].b64_json(string) — Base64 image data. Decodes to a PNG / JPEG / WebP / GIF file, or to XML text for SVG.data[].generation_id(string) — a unique id for this generation, useful for log correlation and debugging.data[].revised_prompt(string / optional) — the model's rewritten prompt; GPT Image models usually omit it.size(string) — the actual output dimensions, e.g.1536x1024.output_format(string) — the format actually produced, matching the request.quality(string) — the quality tier actually used.background(string / optional) —transparentoropaque.usage(object) — billing usage withinput_tokens,output_tokens,total_tokensand image/text breakdowns.svg_usage(object / optional) — returned only for SVG output, tracking the author model's tokens.
Generation is synchronous: the request blocks until the image is ready. Ordinary sizes take tens of seconds, and OpenAI caps complex prompts at about 2 minutes, so set client timeouts above 3 minutes. WebP and JPEG are faster than PNG; prefer them when latency matters.
错误码
| HTTP | 含义 |
|---|---|
| 400 | 参数错误,type 为 invalid_request_error。常见于 output_format: "gif" 却传了比例形式的 size,或把 gif / svg 传给 2.5 及更早的模型 |
| 401 | Token 缺失或无效,type 为 authentication_error |
| 402 | 余额不足,type 为 payment_required |
| 429 | 触发限流 |
内容审核拦截时返回 400,error.type 为 image_generation_user_error、error.code 为 moderation_blocked,error.moderation_details 里带 moderation_stage(input / output / unknown)与被命中的粗粒度类别。这类错误重试无效,需要改提示词或改输入图。
| HTTP | Meaning |
|---|---|
| 400 | Invalid parameters, type is invalid_request_error. Common causes: output_format: "gif" with a ratio-form size, or gif / svg sent to 2.5 or earlier |
| 401 | Token missing or invalid, type is authentication_error |
| 402 | Insufficient balance, type is payment_required |
| 429 | Rate limit hit |
A moderation block returns 400 with error.type image_generation_user_error, error.code moderation_blocked, and error.moderation_details carrying moderation_stage (input / output / unknown) plus the coarse categories hit. Retrying won't help; change the prompt or the input image.
For more status codes and retry guidance see Error codes and rate limits; for troubleshooting see the FAQ.
支持的模型
| 模型 ID | 定位 | GIF | SVG |
|---|---|---|---|
gpt-image-2.6-flare | 2.6 代,速度优先,适合批量与原型 | ✅ | ✅ |
gpt-image-2.6-sunburst | 2.6 代,细节优先,适合成品图与多轮打磨 | ✅ | ✅ |
gpt-image-2.5-flare | 速度优先,适合批量与原型 | — | — |
gpt-image-2.5-sunburst | 编辑精度优先,适合成品图与多轮打磨 | — | — |
gpt-image-2 | 上一代主力,不支持 xhigh 与 max 档 | — | — |
gpt-image-1.5 | 轻量,出图快 | — | — |
gpt-image-1-mini | 成本最低 | — | — |
xhigh 与 max 只有 2.5 及以后支持,传给 gpt-image-2 会返回 400,不会降档。gif 与 svg 只有 2.6 支持,complexity 同样只在 2.6 上生效。
完整模型目录(含价格、分辨率上限)可读取 GET https://api.oairoute.com/api/pricing;也可用 GET /v1/models 筛 supported_endpoint_types 含 image-generation 的条目。
| Model ID | Positioning | GIF | SVG |
|---|---|---|---|
gpt-image-2.6-flare | 2.6 generation, speed first; batch work and prototyping | ✅ | ✅ |
gpt-image-2.6-sunburst | 2.6 generation, detail first; finished images and iteration | ✅ | ✅ |
gpt-image-2.5-flare | Speed first; batch work and prototyping | — | — |
gpt-image-2.5-sunburst | Edit precision first; finished images and iteration | — | — |
gpt-image-2 | Previous main model; no xhigh or max | — | — |
gpt-image-1.5 | Lightweight, fast output | — | — |
gpt-image-1-mini | Lowest cost | — | — |
xhigh and max exist from 2.5 onward; passing them to gpt-image-2 returns 400 rather than downgrading. gif and svg exist only on 2.6, and complexity only takes effect there.
The full catalog (prices, resolution limits) is available from GET https://api.oairoute.com/api/pricing, or filter GET /v1/models for entries whose supported_endpoint_types contain image-generation.