认证
authorization string 必填
所有 API 需要通过 Bearer Token 进行身份验证
获取 API Key:
访问 API Key 管理页面 获取您的 API Key
使用方法:
添加到请求头:
Authorization: Bearer YOUR_API_KEY
参数
model string 必填
请求使用的模型 ID
可选值: gpt_image_1_5
prompt string 必填
所需图像(或多个图像)的文字描述, 最大长度为 32000 个字符
size string
生成图像的大小
可选值: 1024x1024、1024x1536、1536x1024、auto
默认值: auto
n integer
生成图像数量
范围: 1 - 4
默认值: 1
quality string
图像质量等级
可选值: low、medium、high、auto
默认值: auto
轮询
由于结果生成需要时间,您需要在创建任务后轮询任务状态
初始响应只返回任务 ID 和初始状态等信息,最终生成结果需通过使用该任务 ID 轮询任务状态接口获取
轮询请求与响应示例见右侧
响应格式
error object
错误信息, 仅在状态为 failed 时存在
code
string错误代码
message
string详细错误消息
output array
生成结果, 仅在状态为 completed 时存在
content
array生成内容列表
type
string资源类型, 例如
imageurl
string生成内容 URL
usage object
使用统计, 仅在状态为 completed 时存在
cost
string总成本(美元)
discount
number折扣金额
metadata object
元数据信息
错误码
| 错误码 | 描述 |
|---|---|
| 014002095 | 内部生成错误 |
| 014002096 | 结果解析异常 |
| 014002097 | HTTP 错误响应 |
| 014002099 | 同步生成异常 |