建立圖片編輯
在 CometAPI 中使用 POST /v1/images/edits,透過 multipart 上傳、遮罩、GPT 圖像模型與編碼圖片輸出控制來編輯圖片。
在以下情況使用此路由
- 你已經有來源圖片,且想要進行由 Prompt 驅動的編輯
- 你可能需要使用遮罩來進行針對性的修改
- 你可以處理 multipart 檔案上傳,而不是單純的 JSON 請求
安全的第一個請求
- 先從一個 PNG 或 JPG 檔案開始
- 在基本編輯流程可正常運作前,先不要使用遮罩
- 在此路由上進行 GPT 圖片編輯請求時,使用
model: "gpt-image-2" - 使用一個簡短指令,只要求一項可見的變更
- 從
data[0].b64_json讀取編輯後的結果 - 當你想要 JPEG 負載時,設定
output_format: "jpeg" - 預期延遲會比一般圖片生成更長
模型行為
- 此路由上的 GPT 圖片編輯模型會回傳內嵌的 base64 圖片資料
output_format會控制b64_json內部的編碼圖片類型response_format只有在模型支援 URL 輸出時才有作用qwen-image-edit會在相同的 CometAPI 路由後方遵循供應商特定的編輯行為
授權
Bearer token authentication. Use your CometAPI key.
主體
Source image file. Start with one PNG or JPG input for the simplest flow.
Edit instruction describing the change you want.
"Add a small red ribbon to the paper boat."
The image editing model to use. Choose a supported model from the Models page.
Optional PNG mask. Transparent areas mark the regions to edit. The mask dimensions must match the source image exactly.
Number of edited images to return.
Quality setting for models that support it.
high, medium, low Requested response container when supported by the selected model. GPT image edit models return data[].b64_json; use output_format to choose the encoded image type.
url, b64_json Encoded image type for GPT image edit results returned in data[].b64_json. For example, use jpeg for a JPEG payload.
"jpeg"
Requested output size when supported by the selected model.
回應
Edited image result.
Background mode returned by models that expose it.
Encoded image type returned by GPT image models.
Quality level returned by models that expose it.
Output size returned by models that expose it.