Skip to content
Platform / Docs / GPT Image 2.5 API

API Reference

GPT Image 2.5 API

REQUEST gpt-image-api ID 44

Image generation with GPT Image 2.5. Prompt and reference-image fields follow this page.

REQUEST https://xiaoapis.com/api/image/image25

Overview

  • 提示词生成
  • 参考图可选
  • JSON 任务结果

Use cases

  • 高质量配图
  • 设计草稿
  • 营销视觉
Conventions
  • Gateway · https://xiaoapis.com
  • Auth · send key (query or JSON body, as this API specifies)
  • Response · JSON. Check the business code and the HTTP status, not only HTTP 200

Authentication

Send the platform API key (query parameter key or JSON field key, as this page specifies). Create one in API key management.

REQUEST https://xiaoapis.com/api/image/image25
Content-Type: application/json

{
  "key": "YOUR_API_KEY"
}

Request example

/api/image/image25?key=你的key&prompt=一只橘猫坐在窗边晒太阳&imageSize=1K&aspectRatio=1:1&notify=https://your.domain/callback

Details

接口说明:

基于 OpenAI GPT Image 2.5,支持文生图与图生图(带参考图即图生图)。提交后立即返回 task_id,出图完成后向 notify 推送结果。回调与落库复用 /api/image/callback,失败自动退回点数。

默认模型 Flare(更快,适合日常与批量);model=sunburst 为更精细的精品档,计费相同。

计费说明:

分辨率 imageSize扣除点数约合(按 0.01 元/点)
1K25 点0.25 元
2K40 点0.40 元
4K60 点0.60 元

提交成功即按分辨率扣费;任务失败退回。27:16、16:27、9:8、8:9 仅支持 1K。

请求HEADER:

名称值
Content-Typeapplication/x-www-form-urlencoded;charset:utf-8; 或 application/json

请求参数说明:

名称必填类型示例值说明
key是string35kj5jnlj53453kl5j43nj5接口密钥,在控制台->密钥管理查看
prompt是string一只橘猫坐在窗边晒太阳,电影感光线图片描述,最多 20000 字符
notify是stringhttps://your.domain/callback任务完成回调地址,需公网可访问。兼容 callBackUrl
imageSize否string1K分辨率:1K / 2K / 4K,默认 1K。兼容 resolution、size(值为 1K/2K/4K 时)
aspectRatio否string1:1画幅,默认 auto。支持 auto、1:1、3:2、2:3、4:3、3:4、16:9、9:16、21:9、27:16、16:27、9:8、8:9。兼容 aspect_ratio
urls否string/arrayhttps://example.com/a.jpg参考图公网 URL,最多 16 张。逗号分隔、JSON 数组或数组提交均可。传入后走图生图。兼容 input_urls。单张不超过 30MB,格式 JPEG/PNG/WEBP
background否stringopaque背景:transparent 透明、opaque 不透明、auto 自动。默认 opaque
model否stringflareflare(默认,更快)或 sunburst(更精细)。也兼容 gpt-image-2-5-flare / gpt-image-2-5-sunburst

GET / POST / JSON 均可。本接口只提交任务,出图结果通过 notify 回调,不会在本次响应里返回图片地址。

返回参数说明:

名称类型说明
codeint状态码,200 表示提交成功
msgstring状态信息
dataobject任务信息
data.idint本地任务主键
data.task_idstring任务 ID,用于对照回调
data.modelstring实际使用的模型标识,如 gpt-image-2-5-flare
data.image_sizestring本次分辨率
data.power_costnumber本次扣除点数
data.exec_timefloat上游提交耗时
data.user_ipstring客户端 IP
exec_timefloat接口执行耗时
ipstring客户端IP

回调 notify 说明:

任务成功或失败后,以 POST JSON 推送到你传入的 notify。成功时 data.image_url 为可访问的图片地址。

名称类型说明
codeint200 成功,400 失败
msgstringsuccess 或 任务失败
data.task_idstring任务 ID
data.image_urlstring生成图片地址;失败时为空
data.fail_reasonstring失败原因
data.exec_timenumber生成耗时(秒)

Response example

{"code":200,"msg":"任务创建成功","data":{"id":128,"task_id":"task_2f8c1a0b","model":"gpt-image-2-5-flare","image_size":"1K","power_cost":25,"exec_time":0.42,"user_ip":"1.2.3.4"},"exec_time":0.86,"ip":"1.2.3.4"}

Error codes

错误码类型说明
403int没有权限 / 密钥无效
400int参数错误、点数不足、画幅与分辨率不匹配,或上游创建失败
500int服务器内部错误

FAQ

和「AI 图像」接口如何选择?

模型与参数集不同,按效果与价格对照文档选择。

如何传参考图?

使用 urls / input_urls 等字段提交公网图片地址,数量上限见文档。

是否异步?

以该接口文档的任务模型为准(同步或 task 查询)。

商业使用注意?

遵守平台服务条款与内容安全要求,勿生成违规内容。

失败常见原因?

提示词违规、参考图过大/不可达、额度不足。

Full console doc (with the debugger):/doc/44