快速结论

  • 调用入口是 POST /v1/images/generations,请在请求体中设置 model=gpt-image-2。
  • 支持 prompt 文生图,也支持通过 reference_images 传参考图 URL 做参考图生成或编辑。
  • 参考图只支持 URL,本地图片需要先调用上传接口,不能直接传 base64。
  • 接口采用异步任务模式,先返回任务 ID,再通过图片任务状态接口查询结果。
  • 官方公开价格按 1K / 2K / 4K 分辨率约为 $0.22 / $0.50 / $1.30 每张;ToAPIs 当前投放页固定价为 $0.015 / $0.020 / $0.025 每张,最终以账户当前价格为准。
  • 按 ToAPIs 1K 档 $0.015/张估算,充值 $10 大约可继续生成 600+ 张 1K 图片;如果按 4K 档 $0.025/张估算,约可生成 400 张 4K 图片。

关键参数

  • model | string | 必填 | gpt-image-2 | - | 固定使用 gpt-image-2 作为模型标识。
  • prompt | string | 必填 | - | - | 图片生成或编辑的主提示词。
  • size | string | 可选 | 1:1 | 1K: 1:1 | 3:2 | 2:3;2K: 1: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;4K: 4:3 | 3:4 | 16:9 | 9:16 | 2:1 | 1:2 | 21:9 | 9:21 | 输出宽高比;可选值随 resolution 档位变化。
  • resolution | string | 可选 | 1K | 1K | 2K | 4K | 输出分辨率档位;需要与 size 的支持范围匹配。
  • reference_images | string[] | 可选 | - | URL 数组 | 参考图 URL 数组,用于参考图生成或编辑。本地图片需先上传,不能直接传 base64。
  • image_urls | string[] | 可选 | - | URL 数组(兼容字段) | 兼容字段,旧调用可继续使用;新接入建议优先使用 reference_images。
  • response_format | string | 可选 | url | url | b64_json | 返回结果格式;ToAPIs docs 当前推荐使用 url。

常见错误

  • 400 invalid_request_error: 触发=缺少必填字段,或 size 与 resolution 组合不合法。; 修复=按官方文档校验 model、prompt、size、resolution、response_format 的字段和值。; 重试=修正参数后重试,不建议盲重试。
  • 400 invalid_reference_images: 触发=直接传 base64、传入本地路径、或 reference_images 不是 URL。; 修复=先调用上传图片接口,拿到 URL 后再传给 reference_images。; 重试=修正参考图输入后重试。
  • 401 authentication_error: 触发=Authorization 头缺失或 API Key 无效。; 修复=检查 Bearer Token 格式和密钥权限范围。; 重试=修复鉴权后再重试。
  • 429 rate_limit_exceeded: 触发=请求频率、并发或当前额度命中上游限流策略。; 修复=先做指数退避重试,并检查当前请求节奏、并发设置和额度使用情况。; 重试=建议 1s/2s/4s 退避并加入抖动;连续触发时再收紧提交节奏。
OpenAI logo

GPT-Image-2

可商用

透過 ToAPIs 調用 OpenAI 最新圖像模型,生成高品質、可商用的驚豔圖片。

模型类型:
價格: 1K 3 積分($0.015)/ 張; 2K 4 積分($0.02)/ 張; 4K 5 積分($0.025)/ 張

输入

表单JSON
描述你想生成的图片。35 / 1200

快速提示词

高级选项

实际价格以提交时确认为准

参考图

请求预览

{
  "model": "gpt-image-2",
  "prompt": "一張高級產品海報,柔和棚拍燈光,乾淨背景,主體細節清晰,商業廣告質感。",
  "size": "1:1",
  "n": 1,
  "response_format": "b64_json",
  "metadata": {
    "resolution": "1K",
    "orientation": "square"
  }
}

输出

预览JSON
示例结果
示例结果

2M+

Images generated

8s

Avg. response time

99.9%

Uptime

API

Ready for production

生成案例

探索 GPT-Image-2 的生成效果

使用同款模型生成
GPT-Image-2 generated fashion campaign visual

Generated in 8.2s with GPT-Image-2

GPT-Image-2 generated product scene

GPT-Image-2 #2

GPT-Image-2 generated social creative

GPT-Image-2 #3

透明計價

GPT-Image-2 價格

Same image model capability, lower generation cost, free credits on signup.

儲值積分

1K

ToAPIs

$0.015

3 積分 /

節省 93%VS

官方價格

$0.22

2K

ToAPIs

$0.02

4 積分 /

節省 96%VS

官方價格

$0.5

4K

ToAPIs

$0.025

5 積分 /

節省 98%VS

官方價格

$1.3

Prices are shown for model-page comparison and may change. Final billing follows the current account pricing.

为什么选择 ToAPIs

Why use ToAPIs for GPT-Image-2?

Keep GPT-Image-2 quality while lowering image generation costs and using one API key across more models.

Lower per-image pricing

Generate 1K, 2K, and 4K images at a lower listed cost than official pricing.

Free credits first

New users get 10 credits to test prompts before topping up.

Unified API access

Use one ToAPIs account and API key across image, video, and language models.

Start generating in three steps

Test in the page, then move the same model into your production workflow.

  1. 1

    Try a prompt

    Use the playground to validate quality, text rendering, and style fit.

  2. 2

    Create an API key

    Sign up, open Dashboard, and create a token for GPT-Image-2 requests.

  3. 3

    Ship your workflow

    Call the image endpoint, poll async task status, and top up credits as usage grows.

Built for image generation teams

Ads and social creatives

Produce campaign concepts, thumbnails, posters, and localized image variants.

Product visuals

Generate product-style shots, merchandising scenes, and reference-guided variations.

Developer pipelines

Add async image generation to agents, CMS tools, and batch creative systems.

FAQ

GPT-Image-2 pricing FAQ

Can I try GPT-Image-2 for free?

Yes. New ToAPIs users receive 10 credits and can test GPT-Image-2 before topping up.

Is the official comparison fixed?

This model page uses a fixed comparison table for clarity. Final ToAPIs billing follows current account pricing.

Can I use the API after testing?

Yes. Create an API key in the dashboard and integrate GPT-Image-2 into your image generation workflow.

GPT-Image-2 API

Generate your first GPT-Image-2 image on ToAPIs

Start with free credits, compare the output, then get an API key when you are ready to scale.

New here? Sign up and get 10 free credits to try GPT-Image-2 now!

Explore the power of AI image generation with zero risk.

Sign up to get free credits