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 的效果最佳。
- 依交付用途設定長寬比:針對社群貼文、橫幅、商品頁面或編輯版面,預先設定合適的比例。
- 使用清晰的來源圖像進行編輯:清晰、光線良好的輸入有助於保留主體身分特徵,並提升局部編輯品質。
- 多圖請求僅使用有效的參考圖:編輯請求只應提供與目標相關的圖像,避免相互衝突的視覺引導。