概览
GPT Image 2 适合高质量图片生成、较强的指令跟随,以及营销视觉、概念图、产品图和带可读文字图片等常见创意工作流。
如果你只想最快跑通一次请求,就从这里开始:写一个 prompt,选择尺寸,然后读取返回结果中的第一张图片 URL。
计费按质量档区分:
low:每张 2 积分medium:每张 6 积分high:每张 12 积分
接口信息
- 方法:
POST - URL:
https://api.gptimageapi.dev/v1/images/generate
认证方式
在请求头中加入 API Key。还没有 API Key?点击这里创建。
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json请求体
{
"prompt": "A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.",
"model": "gpt-image-2",
"size": "4:3",
"quality": "high",
"n": 1,
"background": "opaque"
}核心字段
prompt:你希望模型生成的图片描述。model:标准生成路线使用gpt-image-2。size:使用宽高比字符串,例如1:1、4:3、16:9、9:21、1:2、2:1。quality:常见值为low、medium、high。n:输出图片数量。background:如果需要透明背景,可使用transparent。
为什么很多团队会先试 GPT Image 2
- 对商业视觉和精修场景有更强的 prompt 跟随能力。
- 对图内文字的处理通常比旧一代通用图像模型更可靠。
- 适用于灵感探索、产品营销图、UI mockup 和创意迭代。
- 支持透明背景输出,方便做合成和设计流程接入。
返回格式
成功返回统一 JSON:
{
"code": 0,
"message": "ok",
"data": {
"images": [
{
"url": "https://cdn.gptimageapi.dev/renders/1234567890.png"
}
]
}
}最佳实践
- 明确写出主体、环境、构图、光线和镜头视角。
- 如果图里必须出现精确文案,把文字放进引号。
- 探索阶段优先用
medium,最终导出再切到high。 quality同时决定积分消耗:low为 2、medium为 6、high为 12。- 一次请求尽量只描述一个清晰场景,不要把五种不同诉求揉进一个 prompt。
提示词建议
- 当图片里必须出现精确文案时,把文本放进引号里。
- 每个文字区域尽量短,多段短文本通常比一整段长文更稳。
- 把场景写清楚:海报、菜单板、应用界面、包装面板、价格卡片等。
high质量档留给最终版,不要把每一轮探索都跑成最高档。
需要提前知道的限制
- 很长的图中文字段仍然不如短标题和短标签稳定。
- 敏感或策略受限的 prompt 可能被拦截或改写。
- 对布局有非常细颗粒度要求时,仍然建议做多轮迭代并保留人工审核。
调用示例
curl -X POST "https://api.gptimageapi.dev/v1/images/generate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.",
"model": "gpt-image-2",
"size": "4:3",
"quality": "high",
"n": 1
}'Node.js
async function generate() {
const res = await fetch('https://api.gptimageapi.dev/v1/images/generate', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt:
'A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.',
model: 'gpt-image-2',
size: '4:3',
quality: 'high',
n: 1,
}),
});
const result = await res.json();
if (result.code !== 0) throw new Error(result.message);
return result.data.images[0].url;
}Python
import requests
def generate():
url = 'https://api.gptimageapi.dev/v1/images/generate'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
}
payload = {
'prompt': 'A photorealistic product photo of a citrus soda bottle on a wet studio table, soft reflections, premium lighting, minimal background.',
'model': 'gpt-image-2',
'size': '4:3',
'quality': 'high',
'n': 1,
}
res = requests.post(url, headers=headers, json=payload, timeout=60)
res.raise_for_status()
result = res.json()
if result.get('code') != 0:
raise Exception(result.get('message'))
return result.get('data', {}).get('images', [])[0].get('url')
print(generate())下一步
- 先去 playground 交互式测试 prompt。
- 如果你的工作流起点是已有素材,再继续看 图片编辑。
- 如果想看能力与 prompt 建议,继续读 模型说明。