ChatGPT Images 2.5 API
ChatGPT Images 2.5 Client 模型的完整 API 参考文档。
模型变体
此 API 支持两种模型变体:
快速对比
支持的宽高比
16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9
ChatGPT Images 2.5 Client(文生图)
端点
POST /api/v1/image/task
身份验证
Authorization: Bearer YOUR_API_KEY
请求参数
必填
注意: 宽度与高度的比例必须为以下值之一:16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9
请求示例
const response = await fetch('https://api.flaq.ai/api/v1/image/task', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model_name: 'chatgpt-images-2.5-client',
prompt: 'A minimalist product shot of a ceramic mug on marble, soft studio light',
width: 1,
height: 1,
resolution: '1k'
})
});
const { data } = await response.json();
const taskId = data.task_id;
const pollResponse = await fetch(
`https://api.flaq.ai/api/v1/image/${taskId}`,
{
headers: { Authorization: 'Bearer YOUR_API_KEY' }
}
);
const result = await pollResponse.json();
console.log(result.data.task_result.images[0].url);
ChatGPT Images 2.5 Edit Client(图像编辑)
端点
POST /api/v1/image/task
请求参数
必填
注意: 宽度与高度的比例必须为以下值之一:16:9, 9:16, 1:1, 3:2, 2:3, 3:4, 4:3, 5:4, 4:5, 21:9
单图编辑示例
{
model_name: 'chatgpt-images-2.5-edit-client',
prompt: 'Replace the background with a clean studio scene and brighten the product lighting',
image_url_list: ['https://example.com/product-photo.jpg'],
width: 16,
height: 9,
resolution: '1k'
}
多图合成示例
{
model_name: 'chatgpt-images-2.5-edit-client',
prompt: 'Blend these reference images into a polished campaign composition while keeping the main subject identity consistent',
image_url_list: [
'https://example.com/image1.jpg',
'https://example.com/image2.jpg',
'https://example.com/image3.jpg'
],
width: 16,
height: 9,
resolution: '1k'
}
响应格式
初始响应
两种 ChatGPT Images 2.5 变体都会返回用于轮询的 task_id:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "submitted",
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}"
},
"message": "success"
}
轮询响应
轮询 GET /api/v1/image/{task_id} 以检查状态:
{
"code": 0,
"data": {
"task_id": "{task_id}",
"task_status": "succeed",
"task_status_msg": null,
"response_url": "https://api.flaq.ai/api/v1/image/{task_id}",
"task_result": {
"credit": 0.0997,
"images": [
{
"url": "https://example.com/generated-image.jpeg"
}
]
}
},
"message": "success"
}
状态值
submitted:任务已受理
processing:正在生成或编辑图像
succeed:任务已成功完成
failed:任务失败
处理时间
通常处理时间为15–60秒,具体取决于提示词的复杂程度,以及编辑请求中的图像数量。
最佳实践
- 明确描述构图:提示词清晰描述主体、取景、光照和预期风格时,ChatGPT Images 2.5 的效果最佳。
- 根据交付用途设置宽高比:针对社交帖子、横幅、商品页面或编辑排版,预先设置合适的比例。
- 使用清晰的源图像进行编辑:清晰、光照良好的输入有助于保留主体身份特征,并提升局部编辑质量。
- 多图请求仅使用有效参考图:编辑请求只应提供与目标相关的图像,避免相互冲突的视觉引导。