跳转到主要内容
POST
/
v1
/
images
/
generations
curl --request POST \
  --url https://toapis.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-1.5-official",
    "prompt": "将两张参考图融合成赛博朋克风格插画海报",
    "image_urls": [
      "https://example.com/input-a.png",
      "https://example.com/input-b.png"
    ],
    "size": "1:1",
    "quality": "high",
    "n": 1
  }'
{
  "id": "tsk_img_01KPTXXXXXXXXXXXXXXX",
  "object": "generation.task",
  "model": "gpt-image-1.5-official",
  "status": "queued",
  "progress": 0,
  "created_at": 1703884800,
  "metadata": {}
}

Documentation Index

Fetch the complete documentation index at: https://docs.toapis.com/llms.txt

Use this file to discover all available pages before exploring further.

  • 与图像生成使用同一端点 /v1/images/generations
  • 请求中包含 image_urls 即自动切换为编辑模式
  • 支持多参考图融合(最多 16 张)、局部重绘(mask)
  • 参考图须为公网可访问的 PNG / JPG,单张 ≤ 50MB
编辑模式的调用方式与生成完全兼容:只需在生成请求基础上加入 image_urls(和可选的 mask_url)即可,无需切换端点。

Authorizations

Authorization
string
必填
所有接口均需要使用 Bearer Token 进行认证获取 API Key:访问 API Key 管理页面 获取您的 API Key
Authorization: Bearer YOUR_API_KEY

Body

model
string
默认值:"gpt-image-1.5-official"
必填
固定填写 gpt-image-1.5-official
prompt
string
必填
描述期望的编辑效果示例:"把背景换成星空,保持主体人物不变"
image_urls
string[]
必填
参考图 URL 数组(触发编辑模式的关键字段)
  • 最多 16 张
  • 必须是公网可访问的稳定 URL(PNG / JPG,单张 ≤ 50MB)
  • 可使用 上传图片接口 获取 URL
mask_url
string
遮罩图 URL,用于局部重绘(inpainting)
  • 须为 PNG 格式,且包含 Alpha 通道
  • 透明区域(alpha = 0)为待重绘区域,不透明区域保持原样
  • 尺寸须与第一张参考图一致
size
string
默认值:"1:1"
输出图像宽高比支持 13 种比例,也可传 auto1: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
resolution
string
默认值:"1k"
分辨率档位:1k / 2k / 4k4K 仅支持 6 个比例(16:9 / 9:16 / 2:1 / 1:2 / 21:9 / 9:21
quality
string
默认值:"high"
图片质量:low / medium / high
n
integer
默认值:1
生成数量,范围 1 ~ 10
output_format
string
默认值:"png"
输出格式:png / jpeg
Azure OpenAI 不支持 webp 格式。
output_compression
integer
默认值:100
JPEG 压缩强度,范围 0–100(仅对 output_format: "jpeg" 有效)

Response

id
string
任务唯一标识符,用于查询任务状态
object
string
固定为 generation.task
status
string
任务状态:queued / in_progress / completed / failed
progress
integer
任务进度百分比(0-100)
created_at
integer
任务创建时间戳(Unix 时间戳)
curl --request POST \
  --url https://toapis.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "gpt-image-1.5-official",
    "prompt": "将两张参考图融合成赛博朋克风格插画海报",
    "image_urls": [
      "https://example.com/input-a.png",
      "https://example.com/input-b.png"
    ],
    "size": "1:1",
    "quality": "high",
    "n": 1
  }'
{
  "id": "tsk_img_01KPTXXXXXXXXXXXXXXX",
  "object": "generation.task",
  "model": "gpt-image-1.5-official",
  "status": "queued",
  "progress": 0,
  "created_at": 1703884800,
  "metadata": {}
}