GPT Image 2 API:价格、尺寸和可运行的代码
GPT Image 2 是 OpenAI 的图像生成与编辑模型,于 2026 年 4 月发布。本指南介绍它接受的尺寸和输入、一张图片的费用,以及用一个 API 密钥就能运行的请求。
GPT Image 2 是什么
OpenAI 于 2026 年 4 月发布了 GPT Image 2;它的 API 快照是 gpt-image-2-2026-04-21。OpenAI 将其描述为“用于快速、高质量图像生成与编辑的最先进图像生成模型”,并表示它“支持灵活的图像尺寸和高保真的图像输入”。在 Revana 上,这具体体现为:
- 三种输出尺寸:1K、2K 和 4K。
- 9 种宽高比,从方形、竖版到适合页头和横幅的 21:9 与 5:2。
- 最多 16 张输入图片,用于编辑和合成:产品、徽标、人物和风格参考。
- 生成与编辑合二为一,请求格式与 Revana 上所有其他模型相同。
典型任务:产品图、广告创意、社交媒体图片、网站横幅、样机,以及对现有照片的编辑。
输入与限制
| 选项 | GPT Image 2 |
|---|---|
| 模型 id | gpt-image-2 |
| 任务 | 文生图和图像编辑 |
| 分辨率 | 1K、2K 和 4K |
| 宽高比 | 1:1、3:4、4:3、2:3、3:2、9:16、16:9、21:9 和 5:2 |
| 输入图片 | 一张待编辑的图片通过 image_url 传入,或最多 16 张通过 image_urls |
| 线路 | 两条线路 |
图像请求使用与视频相同的字段,只是没有 duration 和 audio。模型未列出的尺寸或宽高比,会在任何扣费之前以 422 被拒绝。
GPT Image 2 价格(2026 年 10 月)
GPT Image 2 按生成的图片计费,价格取决于输出尺寸。价格取自 2026 年 10 月的 Revana 目录:
| 分辨率 | 每张图片 | 100 张图片 | 1,000 张图片 |
|---|---|---|---|
| 1K | $0.03 | $3.00 | $30.00 |
| 2K | $0.03 | $3.00 | $30.00 |
| 4K | $0.03 | $3.00 | $30.00 |
每个任务的价格在你提交时从预付余额中预留,只有图片交付后才会扣费;任务失败则释放预留。扣费金额会作为 cost_usd 随生成任务一起返回。价格页面列出了额度包和所有模型的价格。
上一代模型 GPT Image 1.5 仍在目录中。它的价格随宽高比和质量而变,从低质量方形图片的 $0.01 到高质量 3:2 图片的 $0.14。
用 GPT Image 2 生成图片
发送 POST /v1/generations,带上 "model": "gpt-image-2"、提示词、尺寸和宽高比。你会得到一个带有生成任务 id 的 202;轮询它,直到状态变为 succeeded。图片通常只需几秒。这张 2K 方形图片的费用为 $0.03。
export REVANA_API_KEY="sr_live_..."
# 1. Submit the job (returns 202 with the generation id)
curl https://api.revana.si/v1/generations \
-H "Authorization: Bearer $REVANA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"input": {
"prompt": "Flat-lay product photo of a matte black water bottle on a terracotta background, hard midday shadow. A small white card next to the bottle reads \"STAY COLD\" in black sans-serif letters.",
"resolution": "2K",
"aspect_ratio": "1:1"
},
"max_cost_usd": 0.1
}'
# 2. Poll with the id from step 1 until status is "succeeded" or "failed"
curl https://api.revana.si/v1/generations/gen_01JBX7Q2M4 \
-H "Authorization: Bearer $REVANA_API_KEY"import os
import time
import requests
API = "https://api.revana.si/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['REVANA_API_KEY']}"}
resp = requests.post(f"{API}/generations", headers=HEADERS, json={
"model": "gpt-image-2",
"input": {
"prompt": "Flat-lay product photo of a matte black water bottle on a terracotta background, hard midday shadow. A small white card next to the bottle reads \"STAY COLD\" in black sans-serif letters.",
"resolution": "2K",
"aspect_ratio": "1:1",
},
"max_cost_usd": 0.1,
})
resp.raise_for_status()
job = resp.json()
while job["status"] in ("queued", "running"):
time.sleep(5)
job = requests.get(f"{API}/generations/{job['id']}", headers=HEADERS).json()
if job["status"] == "succeeded":
print(job["output"]["urls"], job["cost_usd"])
else:
print("Failed:", job["error"])// Node 18 or later. Save as generate.mjs and run: node generate.mjs
const API = "https://api.revana.si/v1";
const headers = {
Authorization: `Bearer ${process.env.REVANA_API_KEY}`,
"Content-Type": "application/json",
};
const res = await fetch(`${API}/generations`, {
method: "POST",
headers,
body: JSON.stringify({
model: "gpt-image-2",
input: {
prompt: "Flat-lay product photo of a matte black water bottle on a terracotta background, hard midday shadow. A small white card next to the bottle reads \"STAY COLD\" in black sans-serif letters.",
resolution: "2K",
aspect_ratio: "1:1",
},
max_cost_usd: 0.1,
}),
});
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
let job = await res.json();
while (job.status === "queued" || job.status === "running") {
await new Promise((r) => setTimeout(r, 5000));
job = await (await fetch(`${API}/generations/${job.id}`, { headers })).json();
}
if (job.status === "succeeded") console.log(job.output.urls, job.cost_usd);
else console.error("Failed:", job.error);一个已完成的生成任务,图片链接在 output.urls 中。链接会过期,所以请把文件复制到你自己的存储中:
{
"id": "gen_01JC4K2W9T",
"model": "gpt-image-2",
"status": "succeeded",
"output": {
"urls": [
"https://cdn.revana.si/g/gen_01JC4K2W9T/0.png"
]
},
"cost_usd": 0.03,
"attempts": 1,
"error": null,
"created_at": "2026-10-19T14:02:11Z",
"completed_at": "2026-10-19T14:02:29Z"
}用你自己的图片制作横幅
把你的产品图和徽标通过 image_urls 发送,在提示词中按位置引用它们,并选择宽幅的宽高比。如果只想编辑一张照片,请改用 image_url 传入,并描述要做的修改。
{
"model": "gpt-image-2",
"input": {
"prompt": "A website banner. The sneaker from the first image on the right, floating above a soft shadow. The logo from the second image at the top left. The words \"NEW SEASON\" in large white letters on a warm orange gradient. Keep the logo exactly as it is.",
"image_urls": [
"https://example.com/sneaker.png",
"https://example.com/logo.png"
],
"resolution": "2K",
"aspect_ratio": "5:2"
},
"max_cost_usd": 0.1
}GPT Image 2 的提示词技巧
- 像给设计师写需求一样写提示词。按顺序写:主体、场景、构图、光线、风格,最后是文字。
- 引用确切的文字,并说明放在哪里、要呈现成什么样子。
- 按渠道选择宽高比。信息流用 1:1,Stories 和 Reels 用 9:16,页头用 16:9 或 21:9,横幅用 5:2。
- 给输入图片编号。发送多张图片时,“第二张图里的徽标”不会产生任何歧义。
- 说明哪些内容不能变。编辑时,要像说明要改什么一样清楚地说明要保留什么(人脸、标签、徽标)。
- 校对。每张图片发布之前,检查拼写和小字。
GPT Image 2 还是 Nano Banana Pro?
两者都能根据文本和输入图片生成并编辑最高 4K 的图片,请求格式相同。目录中的差异如下:
| GPT Image 2 | Nano Banana Pro | |
|---|---|---|
| 开发商 | OpenAI | |
| 分辨率 | 1K、2K 和 4K | 1K、2K 和 4K |
| 宽高比 | 9 | 10 |
| 输入图片 | 最多 16 张 | 最多 14 张 |
| 起价 | $0.03 / 张 | $0.04 / 张 |
| 线路 | 两条线路 | 一条线路 |
我们不发布画质排名。请用对你重要的提示词在两者上都跑一遍;由于请求格式相同,切换只需修改 model 中的一个词。我们的 Nano Banana Pro 指南对该模型有同样详细的介绍。
路由与回退
目前 GPT Image 2 在 Revana 上有两条线路。对于有多条线路的模型,路由器会先尝试最便宜的,失败后转到下一条,始终按标价计费。如果所有线路都失败,任务会以 failed 结束,且不收费。
请为 failed 的任务做好准备:稍后重试,或者在你自己的代码中,改用另一个图像模型,换一个不同的 model 字符串作为回退。
在模型页面浏览所有图像模型,阅读文档,或者获取 API 密钥。
常见问题
GPT Image 2 API 的价格是多少?
2026 年 10 月,GPT Image 2 在 1K 下每张 $0.03,2K 下 $0.03,4K 下 $0.03。100 张 1K 图片为 $3.00。
GPT Image 2 是什么时候发布的?
OpenAI 于 2026 年 4 月发布了 GPT Image 2。它的 API 快照是 gpt-image-2-2026-04-21。
GPT Image 2 支持哪些尺寸和宽高比?
尺寸为 1K、2K 和 4K,宽高比为 1:1、3:4、4:3、2:3、3:2、9:16、16:9、21:9 和 5:2。
我可以向 GPT Image 2 发送多少张输入图片?
最多 16 张,通过 image_urls 传入。如果只编辑一张图片,请通过 image_url 传入。
我应该用 GPT Image 2 还是 Nano Banana Pro?
请用你自己的提示词测试两者。在目录中,GPT Image 2 最多支持 16 张输入图片,列出 9 种宽高比;Nano Banana Pro 最多支持 14 张,列出 10 种。两者都最高支持 4K。
GPT Image 1.5 还能用吗?
能。它的价格随宽高比和质量而变,2026 年 10 月为每张 $0.01 到 $0.14。