跳至主要内容

GPT Image 2

gpt-image-2gpt-image-2 4K 透過 OpenAI Images 相容端點提供文生圖與圖片編輯。客戶端只需使用 PopGo 公開模型 ID。

呼叫地址

POST https://api.popgo.site/v1/images/generations
POST https://api.popgo.site/v1/images/edits
Authorization: Bearer YOUR_API_KEY

/generations 使用 JSON;/edits 使用 multipart/form-data,編輯時至少提供一個 image 檔案。

模型與欄位

模型用途規格
gpt-image-2文生圖、圖片編輯尺寸與品質依即時模型頁
gpt-image-2 4K文生圖、圖片編輯用於 4K 輸出級別,尺寸依即時配置
欄位類型說明
modelstring必填,使用上列公開模型 ID
promptstring必填,描述主體、構圖、動作與風格
sizestring選填,使用 WIDTHxHEIGHT 或支援的 auto;使用半形 x
qualitystring選填,只有模型頁列出時才傳
ninteger選填,結果數量,預設 1
response_formatstring選填,urlb64_json
image / image[]file編輯用參考檔案,可重複欄位傳多張

範例

curl https://api.popgo.site/v1/images/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "YOUR_MODEL",
"prompt": "A rainy city cafe at night, cinematic photography",
"size": "1024x1024",
"n": 1,
"response_format": "url"
}'

編輯與多張參考圖:

curl https://api.popgo.site/v1/images/edits \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "model=YOUR_MODEL" \
-F "image[]=@input.png" \
-F "image[]=@style.png" \
-F "prompt=Keep the subject from the first image and apply the palette of the second"

回應與 Base64

data[].url 是圖片地址。使用 response_format=b64_json 時,data[].b64_json 是不含 data:image/png;base64, 前綴的圖片 Base64 內容;顯示前請補上 MIME 類型,或先解碼為檔案。

限制

sizequalityn 和參考圖數量都必須符合即時模型能力。圖片編輯不能把本機路徑直接放進 JSON;請使用 multipart 檔案上傳。URL 可能過期,成功後請儘快下載。計費依模型與價格頁執行。