Skip to main content
POST
编辑图像

授权

X-Api-Key
string
header
必填

需要从 AiToEarn 获取 API Key。点击前往「API Key 获取教程」

请求体

application/json
model
string
必填

图像编辑模型名称。先调用「图像编辑模型」接口(GET /api/ai/models/image/edit),传入其返回的 data[n].name;各模型支持的尺寸、最大输入图片数与价格以该接口返回为准。

示例:

"gpt-image-2"

image
必填

原始图片。支持单个图片 URL、data URL 或图片 URL 数组;当前 gpt-image-2 最多支持 14 张输入图片。

示例:

"https://images.unsplash.com/photo-1592194996308-7b43878e84a6?auto=format&fit=crop&w=1024&q=80"

prompt
string
必填

编辑描述

Required string length: 1 - 4000
示例:

"Edit the provided image into a cozy realistic scene by placing the cute orange cat beside a sunlit window. Preserve its orange fur, seated pose, and facial expression, enhance the soft natural light, add warm tones and subtle detail, and maintain a realistic photography style."

mask
string

遮罩图片 URL,用于局部重绘(可选)。需为与 image 尺寸一致的 PNG 图片:完全透明(alpha 为 0)的区域表示需要按提示词重绘的部分,不透明区域保持原图不变。不传时对整张图片进行编辑。

n
integer

生成图片数量

必填范围: 1 <= x <= 1
示例:

1

size
string

图像尺寸。可选值随模型而不同,以「图像编辑模型」接口返回的 data[n].sizes 为准;不同尺寸的价格不同,见 data[n].pricing。当前示例使用 1024x1024,对应最低价格 1 积分。

示例:

"1024x1024"

response_format
enum<string>

返回格式

可用选项:
url,
b64_json
示例:

"url"

响应

200 - application/json

请求已被服务处理。业务是否成功以响应体 code === 0 为准。

code
integer
必填

业务状态码。0 表示成功,非 0 表示业务错误。

message
string
必填

响应消息。

data
object
requestId
string

请求 ID。

timestamp
integer

错误响应时间戳,Unix 毫秒。

最后修改于 2026年7月31日