GPT Image 2 API 文档 – AI 生图接口

用一个 API key 调用 GPT Image 2、GPT Image 2.5/2.6、Nano Banana、Seedream 等模型,支持文生图与图片编辑,按网站同价扣积分。
2026/11/28

imagesv2.ai API 让你的应用、脚本或工作流(Dify、n8n、Zapier、自有后端)用和网页生成器相同的模型、相同的积分价格生成和编辑图片。一个 key,一个余额。

  • Base URL: https://imagesv2.ai/api/v1
  • 鉴权: Authorization: Bearer <你的 API key>
  • 获取 key: 设置 → API Keys(登录后点新建,复制 key)
  • 充值积分: 价格页
  • 用 Dify? 在 Dify Marketplace 安装 imagesv2 插件,填入 key 即可,无需写代码。

生成是异步的:先创建任务,再轮询直到状态为 success 或 failed。多数图片 10–60 秒完成,GPT Image 2 高质量最长约 2 分钟。

快速开始

# 1. 创建任务
curl https://imagesv2.ai/api/v1/images/generations \
  -H "Authorization: Bearer $IMAGESV2_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "Studio product photo of a matte black water bottle on a beige stone plinth, soft shadow, 4k",
    "quality": "medium",
    "size": "1024x1024"
  }'
# → 202 {"id":"7f3c...","status":"pending","model":"gpt-image-2","credits_cost":40,"poll_url":"https://imagesv2.ai/api/v1/tasks/7f3c..."}

# 2. 轮询到 success
curl https://imagesv2.ai/api/v1/tasks/7f3c... \
  -H "Authorization: Bearer $IMAGESV2_API_KEY"
# → {"id":"7f3c...","status":"success","images":[{"url":"https://r2.imagesv2.ai/..."}],"credits_cost":40,...}

建议每 3–5 秒轮询一次。图片 URL 是我们 CDN 上的永久链接。

接口一览

方法路径作用
POST/api/v1/images/generations创建文生图或图片编辑任务
GET/api/v1/tasks/{id}查询任务状态与结果
POST/api/v1/uploads上传编辑用的参考图
GET/api/v1/models模型、参数与积分价格(无需 key)
GET/api/v1/me校验 key 并查询积分余额

POST /api/v1/images/generations

JSON 请求体:

字段类型必填说明
promptstring是要生成的内容,或对输入图的修改要求
modelstring否默认 gpt-image-2,见模型
image_urlsstring[]否传了就是编辑(图生图)。用 /api/v1/uploads 返回的 URL 或你在本站生成的图
ninteger否1–4 张(GPT Image 系列与 Seedream 5.0 Lite;其他模型固定 1 张)
qualitystring否GPT Image 系列:low、medium、high、auto(2.5/2.6 另有 xhigh、max),默认 auto
sizestring否GPT Image 系列:auto、1024x1024、1536x1024、1024x1536、2048x2048、3072x2048、2048x3072,默认 auto
output_formatstring否png(默认)、jpeg、webp
backgroundstring否auto、transparent、opaque;透明背景需 png 或 webp
aspect_ratiostring否Nano Banana、Seedream、MiniMax H3、MAI Image:如 1:1、16:9、9:16、4:5
resolutionstring否Nano Banana 2 / 2.1 / Pro:1K、2K、4K;Seedream:basic、high;MiniMax H3:2K、4K;MAI:1K、2K

返回 202 Accepted:

{
  "id": "7f3c2a8e-...",
  "status": "pending",
  "model": "gpt-image-2",
  "credits_cost": 40,
  "poll_url": "https://imagesv2.ai/api/v1/tasks/7f3c2a8e-..."
}

创建任务时扣积分;生成失败会自动退回。

GET /api/v1/tasks/{id}

{
  "id": "7f3c2a8e-...",
  "status": "success",
  "model": "gpt-image-2",
  "prompt": "Studio product photo of ...",
  "credits_cost": 40,
  "watermarked": false,
  "images": [{ "url": "https://r2.imagesv2.ai/raw/....png" }],
  "error": null,
  "created_at": "2026-11-28T08:00:00.000Z",
  "completed_at": "2026-11-28T08:00:31.000Z"
}

status 取值:pending、processing、success、failed、canceled。failed 时 error 给出原因,积分已退回。

从未购买过积分的账号拿到的是带水印的图("watermarked": true),与网站规则一致;任意一次购买后即无水印。

POST /api/v1/uploads

multipart 表单,一个或多个 files 字段(JPEG、PNG、WebP、GIF、AVIF、HEIC,单张不超过 40 MB,每次最多 10 张)。返回的 URL 填进 image_urls。

curl https://imagesv2.ai/api/v1/uploads \
  -H "Authorization: Bearer $IMAGESV2_API_KEY" \
  -F "[email protected]"
# → {"urls":["https://r2.imagesv2.ai/9b1e....jpg"]}

curl https://imagesv2.ai/api/v1/images/generations \
  -H "Authorization: Bearer $IMAGESV2_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "Put this bottle on a sunlit marble kitchen counter, lifestyle ad photo",
    "image_urls": ["https://r2.imagesv2.ai/9b1e....jpg"],
    "quality": "medium"
  }'

出于安全考虑,接口只读取 imagesv2.ai 上的图片,外部图片请先上传。

模型

GET /api/v1/models 返回实时清单,含全部参数与价格。下表为默认参数下每张图的积分。

模型 ID名称文生图编辑
gpt-image-2GPT Image 210(low)/ 40(medium)/ 110(high)30 / 60 / 130
gpt-image-2.5-flareGPT Image 2.5 Flare(速度向)10 / 40 / 60+20
gpt-image-2.5-sunburstGPT Image 2.5 Sunburst(编辑更精准)10 / 40 / 60+20
gpt-image-2.6-flareGPT Image 2.6 Flare30 / 50 / 60+20
gpt-image-2.6-sunburstGPT Image 2.6 Sunburst30 / 50 / 60+20
gemini-nano-banana-2.1Nano Banana 2.140(1K)60
gemini-3.1-flash-imageNano Banana 270(1K)90
gemini-3-pro-imageNano Banana Pro140(1K)160
seedream/5.5Seedream 5.52030
seedream/5.0-liteSeedream 5.0 Lite3030
minimax/h3-image/text-to-imageMiniMax H3 Image30(2K)50
fal-ai/mai-image-2.7MAI Image 2.740(1K)80

更高分辨率、更大尺寸和更多参考图会更贵;实际扣费总会在开工前以 credits_cost 返回。积分套餐见价格页。

错误码

错误使用 HTTP 状态码和 JSON:

{ "error": { "code": "insufficient_credits", "message": "Not enough credits for this request.", "credits_remaining": 5, "recharge_url": "https://imagesv2.ai/pricing?utm_source=api" } }
HTTPcode含义
400invalid_request缺 prompt、未知模型、参数值不合法、图片不在 imagesv2.ai
401invalid_api_keykey 缺失、格式错误、已删除或不存在
402insufficient_credits余额不足,recharge_url 是充值链接;本次未扣费
403account_suspended该 key 所属账号已被限制生成
404not_found任务不存在或属于其他账号
429rate_limited请求过于频繁,等 retry_after 秒再试

限流

每个 key 每分钟:生成 20 次、上传 30 次、读取(轮询任务、/me)120 次。需要更高额度请在反馈页联系我们。

Key 与安全

  • key 只放在服务端,拿到 key 的人可以花你的积分。
  • key 泄露后到设置 → API Keys 删除,立即失效。
  • 可选请求头 X-Imagesv2-Client: <你的应用名>,方便我们排查你的集成问题。

生成的图片遵循我们的服务条款和隐私政策。