Skip to content

批量生图 API (Batches 模式)

当您需要同时生成数十张甚至成百上千张图片(如电商图包生成、画册合成)时,建议使用 Batches 批量生图模式


1. 提交批量生图任务

  • HTTP 请求方法POST
  • 接口地址https://api.ximi-api.cc.cd/v1/images/batches
  • 请求头 Header
    • Authorization: Bearer YOUR_API_KEY
    • Idempotency-Key: UNIQUE_IDEMPOTENCY_KEY

请求 Body 示例

json
{
  "model": "gpt-image-2",
  "items": [
    {
      "custom_id": "item-001",
      "prompt": "极简蓝白科技感 LOGO 设计",
      "output_count": 1
    },
    {
      "custom_id": "item-002",
      "prompt": "复古水彩风格英式下午茶插画",
      "output_count": 1
    }
  ]
}

2. 批量任务状态查询与 ZIP 下载

查询批量任务列表

  • 接口GET /v1/images/batches?limit=20

导出与打包下载 ZIP 压缩包

当 Batch 状态变为 completed 后,可通过打包下载接口一次性将全量生成的原图压缩包下载至本地:

bash
curl -O https://api.ximi-api.cc.cd/v1/images/batches/BATCH_ID/download \
  -H "Authorization: Bearer YOUR_API_KEY"

请求将直接返回标准的 application/zip 文件二进制流!

XIMI-API 企业级 AI 聚合平台 · 官方 API 开发文档