imagesv2.ai API 让你的应用、脚本或工作流(Dify、n8n、Zapier、自有后端)用和网页生成器相同的模型、相同的积分价格生成和编辑图片。一个 key,一个余额。
https://imagesv2.ai/api/v1Authorization: Bearer <你的 API 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 并查询积分余额 |
JSON 请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
prompt | string | 是 | 要生成的内容,或对输入图的修改要求 |
model | string | 否 | 默认 gpt-image-2,见模型 |
image_urls | string[] | 否 | 传了就是编辑(图生图)。用 /api/v1/uploads 返回的 URL 或你在本站生成的图 |
n | integer | 否 | 1–4 张(GPT Image 系列与 Seedream 5.0 Lite;其他模型固定 1 张) |
quality | string | 否 | GPT Image 系列:low、medium、high、auto(2.5/2.6 另有 xhigh、max),默认 auto |
size | string | 否 | GPT Image 系列:auto、1024x1024、1536x1024、1024x1536、2048x2048、3072x2048、2048x3072,默认 auto |
output_format | string | 否 | png(默认)、jpeg、webp |
background | string | 否 | auto、transparent、opaque;透明背景需 png 或 webp |
aspect_ratio | string | 否 | Nano Banana、Seedream、MiniMax H3、MAI Image:如 1:1、16:9、9:16、4:5 |
resolution | string | 否 | 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-..."
}创建任务时扣积分;生成失败会自动退回。
{
"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),与网站规则一致;任意一次购买后即无水印。
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-2 | GPT Image 2 | 10(low)/ 40(medium)/ 110(high) | 30 / 60 / 130 |
gpt-image-2.5-flare | GPT Image 2.5 Flare(速度向) | 10 / 40 / 60 | +20 |
gpt-image-2.5-sunburst | GPT Image 2.5 Sunburst(编辑更精准) | 10 / 40 / 60 | +20 |
gpt-image-2.6-flare | GPT Image 2.6 Flare | 30 / 50 / 60 | +20 |
gpt-image-2.6-sunburst | GPT Image 2.6 Sunburst | 30 / 50 / 60 | +20 |
gemini-nano-banana-2.1 | Nano Banana 2.1 | 40(1K) | 60 |
gemini-3.1-flash-image | Nano Banana 2 | 70(1K) | 90 |
gemini-3-pro-image | Nano Banana Pro | 140(1K) | 160 |
seedream/5.5 | Seedream 5.5 | 20 | 30 |
seedream/5.0-lite | Seedream 5.0 Lite | 30 | 30 |
minimax/h3-image/text-to-image | MiniMax H3 Image | 30(2K) | 50 |
fal-ai/mai-image-2.7 | MAI Image 2.7 | 40(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" } }| HTTP | code | 含义 |
|---|---|---|
| 400 | invalid_request | 缺 prompt、未知模型、参数值不合法、图片不在 imagesv2.ai |
| 401 | invalid_api_key | key 缺失、格式错误、已删除或不存在 |
| 402 | insufficient_credits | 余额不足,recharge_url 是充值链接;本次未扣费 |
| 403 | account_suspended | 该 key 所属账号已被限制生成 |
| 404 | not_found | 任务不存在或属于其他账号 |
| 429 | rate_limited | 请求过于频繁,等 retry_after 秒再试 |
每个 key 每分钟:生成 20 次、上传 30 次、读取(轮询任务、/me)120 次。需要更高额度请在反馈页联系我们。
X-Imagesv2-Client: <你的应用名>,方便我们排查你的集成问题。