通用开放接口图像 API
POST /v1/images/edits
POST
/v1/images/edits图生图 / 图像编辑。
鉴权:Bearer Token
Content-Type:multipart/form-data 或 application/json(视模型/渠道支持)
请求体(multipart/form-data)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 图像模型 |
prompt | string | 是 | 编辑描述 |
image | file | 是 | 待编辑图片 |
mask | file | 否 | 蒙版(局部编辑) |
n | integer | 否 | 生成数量 |
size | string | 否 | 输出尺寸 |
response_format | string | 否 | url 或 b64_json |
请求体(JSON,部分渠道支持 URL 数组)
{ "model": "agnes-image-2.0-flash", "prompt": "Add a red scarf to the cat", "size": "1024x768", "image": ["https://example.com/cat.jpg"], "response_format": "url"}请求示例(curl)
JSON(URL 数组):
curl https://www.yunsell.com/v1/images/edits \ -H "Authorization: Bearer sk-xxx" \ -H "Content-Type: application/json" \ -d '{ "model": "agnes-image-2.0-flash", "prompt": "Add a red scarf to the cat", "size": "1024x768", "image": ["https://example.com/cat.jpg"], "response_format": "url" }'multipart/form-data(上传本地文件):
curl https://www.yunsell.com/v1/images/edits \ -H "Authorization: Bearer sk-xxx" \ -F "model=dall-e-2" \ -F "prompt=Add a red scarf to the cat" \ -F "image=@/path/to/cat.png" \ -F "response_format=url"响应体
HTTP 200,结构与 /v1/images/generations 相同:
{ "created": 1712697600, "data": [ { "url": "https://cdn.example.com/generated/edit_abc123.png" } ]}