跳轉到主要內容
POST
/
v1
/
images
/
edits
curl -X POST "https://api.lemondata.cc/v1/images/edits" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F "image=@sunlit_lounge.png" \
  -F "[email protected]" \
  -F "prompt=A sunlit indoor lounge area with a pool" \
  -F "n=1" \
  -F "size=1024x1024"
{
  "created": 1706000000,
  "data": [
    {
      "url": "https://..."
    }
  ]
}

概述

根據原始圖像和提示詞建立編輯或擴展的圖像。需要 multipart/form-data 內容類型。

請求主體

image
file
必填
要編輯的圖像。必須是有效的 PNG 檔案,小於 4MB,且為正方形。圖像應在需要編輯的位置具有透明度。
prompt
string
必填
描述所需編輯的文字。
mask
file
一個附加圖像,其完全透明的區域指示應編輯圖像的位置。必須是有效的 PNG 檔案,小於 4MB,且與 image 具有相同的尺寸。
model
string
預設值:"dall-e-2"
用於圖像編輯的模型。目前僅支援 dall-e-2
n
integer
預設值:"1"
要生成的圖像數量。必須在 1 到 10 之間。
size
string
生成圖像的尺寸。必須是 256x256512x5121024x1024 之一。
response_format
string
預設值:"url"
回傳生成圖像的格式。必須是 urlb64_json
user
string
代表終端使用者的唯一識別碼,用於濫用監控。

回應

created
integer
圖像建立時間的 Unix 時間戳。
data
array
生成的圖像陣列。每個物件包含:
  • url (string): 編輯後圖像的 URL(如果 response_format 是 url
  • b64_json (string): Base64 編碼的圖像(如果 response_format 是 b64_json
curl -X POST "https://api.lemondata.cc/v1/images/edits" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F "image=@sunlit_lounge.png" \
  -F "[email protected]" \
  -F "prompt=A sunlit indoor lounge area with a pool" \
  -F "n=1" \
  -F "size=1024x1024"
{
  "created": 1706000000,
  "data": [
    {
      "url": "https://..."
    }
  ]
}

注意事項

圖像編輯僅適用於 DALL-E 2。圖像必須具有透明區域以指示應套用編輯的位置,或者您可以提供單獨的遮罩圖像。

主體

application/json
image
file
必填

要編輯的圖像。必須是有效的 PNG 檔案,小於 4MB,且為正方形。圖像應在需要編輯的位置具有透明度。

prompt
string
必填

描述所需編輯的文字。

mask
file

一個附加圖像,其完全透明的區域指示應編輯圖像的位置。必須是有效的 PNG 檔案,小於 4MB,且與 image 具有相同的尺寸。

model
string

用於圖像編輯的模型。目前僅支援 dall-e-2

n
integer

要生成的圖像數量。必須在 1 到 10 之間。

size
string

生成圖像的尺寸。必須是 256x256512x5121024x1024 之一。

response_format
string

回傳生成圖像的格式。必須是 urlb64_json

user
string

代表終端使用者的唯一識別碼,用於濫用監控。

回應

200 - application/json

Response 200

created
integer

圖像建立時間的 Unix 時間戳。

data
object[]

生成的圖像陣列。 每個物件包含: url (string): 編輯後圖像的 URL(如果 response_format 是 urlb64_json (string): Base64 編碼的圖像(如果 response_format 是 b64_json