GPT Image 2
GPT Image 2:照片级真实感、精准文字渲染、像素级图像编辑
功能特性
- 文生图生成
- 图生图编辑(最多 4 张参考图)
- 照片级画质与精准字体渲染
- 单张输出(n=1)
定价
| Resolution | Credits |
|---|---|
| 1k | 3 (~$0.03) |
| 2k | 4 (~$0.04) |
| 4k | 5 (~$0.06) |
端点
POST
/api/v1/images/generate参数
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
| model | string | 必需 | Must be "gpt-image-2" |
| type | string | 可选 | "text-to-image" or "image-to-image" (default: text-to-image) |
| prompt | string | 必需 | Text description (3–20000 chars) |
| image_urls | string[] | 可选 | Required for image-to-image. Up to 4 reference image URLs |
| input_image | string | 可选 | Deprecated. Alias for image_urls[0] |
| image_size | string | 可选 | Optional aspect ratio: "1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "5:4", "4:5", "2:1", "1:2", "21:9", or "9:21". Required for 4k; auto/default is not allowed with 4k. |
| resolution | string | 可选 | Optional output resolution: "1k", "2k", or "4k" (default: "1k") |
| num_images | number | 可选 | Must be 1 (gpt-image-2 always returns a single image) |
请求示例(文生图)
{
"model": "gpt-image-2",
"resolution": "2k",
"prompt": "A hand-drawn illustrated greeting card with the text \"Hello, world!\" in serif letters"
}请求示例(图生图)
{
"model": "gpt-image-2",
"type": "image-to-image",
"resolution": "2k",
"prompt": "Place the subject on a beach at golden hour, keep facial features identical",
"image_urls": ["https://tempfile.aiquickdraw.com/workers/nano/image_1772780968156_ygk0zm.png"]
}响应示例
{
"success": true,
"data": {
"task_id": "task_gpt2_123",
"credits_used": 4,
"remaining_credits": 496,
"model": "gpt-image-2"
}
}代码示例(文生图)
curl -X POST https://gateway.bananapro.site/api/v1/images/generate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"resolution": "2k",
"prompt": "A hand-drawn illustrated greeting card with the text \"Hello, world!\" in serif letters"
}'代码示例(图生图)
curl -X POST https://gateway.bananapro.site/api/v1/images/generate \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"type": "image-to-image",
"resolution": "2k",
"prompt": "Place the subject on a beach at golden hour, keep facial features identical",
"image_urls": ["https://tempfile.aiquickdraw.com/workers/nano/image_1772780968156_ygk0zm.png"]
}'