跳转到主要内容
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=阳光明媚的室内休息区,带有游泳池" \
  -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=阳光明媚的室内休息区,带有游泳池" \
  -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