跳转到内容
中文

GPT Image 2

提供商OpenAI
模型名称gpt-image-2
主要端点/v1/chat/completions
返回形式choices[0].message.content 中返回 Markdown 图片内容
典型能力长提示词理解、版式海报、多模态对话式生图

GPT Image 2 适合放在统一的 Chat Completions 工作流里调用,特别适合需要复杂自然语言描述的设计任务。

  • 需要长提示词和细节约束的海报或封面图
  • 统一走 Chat Completions 的多模态产品
  • 强调版式、文案和场景关系的营销素材
  • 与 Nano Banana 系列做对照测试
  • POST /v1/chat/completions
  • 建议 stream: false
参数类型说明
modelstring固定为 gpt-image-2
messagesarray标准 Chat Completions 消息数组
extra_body.google.image_config.aspect_ratiostring可用 auto1:116:99:164:33:4
extra_body.google.image_config.image_sizestring分辨率:1K(默认)、2K4K。分辨率越高价格越高,详见实时定价
streamboolean建议设为 false

限制说明:当清晰度(image_size)选 "4K" 时,比例(aspect_ratio)不能是 "1:1"(正方形)。如需 4K 输出,请把清晰度降到 "2K",或者把比例换成 16:99:164:33:4 中的任意一种。

Terminal window
curl -X POST https://api.hiapi.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"stream": false,
"messages": [
{
"role": "user",
"content": "Create a launch poster for an AI note-taking app with clean typography, dark UI mockup, and a subtle neon accent"
}
],
"extra_body": {
"google": {
"image_config": {
"aspect_ratio": "16:9",
"image_size": "1K"
}
}
}
}'
{
"id": "chatcmpl-img-004",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "![image](data:image/png;base64,iVBORw0KGgoAAA...)"
},
"finish_reason": "stop"
}
]
}

GPT Image 2 同步返回结果,不需要轮询。

  • 400 Bad Requestmessages 结构错误,或比例参数不受支持。
  • 401 Unauthorized:API Key 无效。
  • 429 Too Many Requests:请求过于密集。
  • 400 content_policy_violation:提示词触发安全限制。

GPT Image 2 的实时价格请查看实时定价页