图像编辑(gpt-image-1)
测试中
POST
https://api.deerapi.com/v1/images/edits
https://platform.openai.com/docs/api-reference/images/createEdit
图像编辑请求参数
参数名 | 类型 | 是否必需 | 描述 |
---|---|---|---|
image | 文件或文件数组 | ✅ | 要编辑的图像。必须是支持的图像文件或数组。 - gpt-image-1: PNG、WEBP 或 JPG,每张小于25MB。 - dall-e-3: 一张正方形 PNG,小于4MB。 |
prompt | 字符串 | ✅ | 所需图像的文本描述。 - 最大长度:dall-e-3 为1000字符,gpt-image-1 为32000字符。 |
mask | 文件 | 可选的 PNG 掩码图像。透明区域(alpha=0)表示需要编辑的区域。 必须与图像尺寸匹配,且小于4MB。适用于第一张图像。 | |
model | 字符串 | 使用的模型:dall-e-3 或 gpt-image-1。 | |
n | 整数或 null | 生成的图像数量。必须在1到10之间。 默认值:1。 | |
quality | 字符串或 null | 仅适用于 gpt-image-1。可选值:high、medium、low。 默认值:auto。 | |
response_format | 字符串或 null | 响应格式。可选值:url 或 b64_json。 仅 dall-e-3 支持 url(有效期60分钟)。 | |
size | 字符串或 null | 图像尺寸: - gpt-image-1: 1024x1024、1536x1024、1024x1536、auto(默认) - dall-e-2: 256x256、512x512、1024x1024 |
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.deerapi.com/v1/images/edits' \
--header 'Authorization: Bearer {{api-key}}' \
--form 'image=@"MQ==/test.png"' \
--form 'prompt="Put on glasses"' \
--form 'model="gpt-image-1"' \
--form 'mask=@""' \
--form 'n=""' \
--form 'quality=""' \
--form 'response_format=""' \
--form 'size=""'
响应示例响应示例
{
"data": [
{
"b64_json": ".........................."
}
],
"created": 1747124651,
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 6605,
"prompt_tokens_details": {
"cached_tokens_details": {}
},
"completion_tokens_details": {},
"input_tokens": 365,
"output_tokens": 6240,
"input_tokens_details": {
"text_tokens": 42,
"image_tokens": 323,
"cached_tokens_details": {}
}
}
}
请求参数
Header 参数
Authorization
string
可选
示例值:
Bearer {{api-key}}
Body 参数multipart/form-data
image
file
必需
示例值:
MQ==/test.png
prompt
string
必需
示例值:
Put on glasses
model
string
可选
默认为 gpt-image-1
示例值:
gpt-image-1
mask
file
可选
必须与图像尺寸匹配,且小于4MB。适用于第一张图像。
n
string
可选
默认值:
1
quality
enum<string>
可选
枚举值:
highmediumlow
默认值:
auto
response_format
enum<string>
可选
仅 dall-e-3 支持 url(有效期60分钟)。
枚举值:
urlb64_json
size
string
可选
返回响应
修改于 2025-05-29 09:26:33