跳轉到主要內容
POST
使用此路由可在 CometAPI 上以相容 OpenAI 的 multipart 上傳方式編輯現有圖片。

在以下情況使用此路由

  • 你已經有來源圖片,且想要進行由 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 路由後方遵循供應商特定的編輯行為

授權

Authorization
string
header
必填

Bearer token authentication. Use your CometAPI key.

主體

multipart/form-data
image
file
必填

Source image file. Start with one PNG or JPG input for the simplest flow.

prompt
string
必填

Edit instruction describing the change you want.

範例:

"Add a small red ribbon to the paper boat."

model
string
預設值:gpt-image-2

The image editing model to use. Choose a supported model from the Models page.

mask
file

Optional PNG mask. Transparent areas mark the regions to edit. The mask dimensions must match the source image exactly.

n
string
預設值:1

Number of edited images to return.

quality
enum<string>

Quality setting for models that support it.

可用選項:
high,
medium,
low
response_format
enum<string>

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
output_format
string

Encoded image type for GPT image edit results returned in data[].b64_json. For example, use jpeg for a JPEG payload.

範例:

"jpeg"

size
string

Requested output size when supported by the selected model.

回應

200 - application/json

Edited image result.

created
integer
必填
usage
object
必填
data
object[]
必填
background
string

Background mode returned by models that expose it.

output_format
string

Encoded image type returned by GPT image models.

quality
string

Quality level returned by models that expose it.

size
string

Output size returned by models that expose it.

最後修改於 2026年6月23日