图生图
上传一张原图,按提示词编辑、改色或调整风格。
POST
/v1/images/edits请求格式
使用 multipart/form-data。除 image 外,其余字段与文生图一致。
| 字段 | 必填 | 说明 |
|---|---|---|
image | 是 | 原图文件,支持 PNG/JPEG/WebP |
model | 是 | 例如 生图专用-2.6 |
prompt | 是 | 编辑要求,例如“把杯子改成蓝色” |
size | 否 | 期望输出尺寸 |
response_format | 否 | b64_json 或 url |
output_format | 否 | png / jpeg / webp |
请求示例
curl
curl https://sub.chatacc.com/v1/images/edits \
-H "Authorization: Bearer sk-你的Key" \
-F "model=生图专用-2.6" \
-F "prompt=把杯子改成蓝色,保持白色背景" \
-F "size=1024x1024" \
-F "response_format=b64_json" \
-F "image=@input.png"Python
import base64
import requests
url = "https://sub.chatacc.com/v1/images/edits"
headers = {"Authorization": "Bearer sk-你的Key"}
data = {
"model": "生图专用-2.6",
"prompt": "把杯子改成蓝色,保持白色背景",
"size": "1024x1024",
"response_format": "b64_json",
}
with open("input.png", "rb") as f:
files = {"image": ("input.png", f, "image/png")}
r = requests.post(url, headers=headers, data=data, files=files, timeout=180)
r.raise_for_status()
open("output.png", "wb").write(base64.b64decode(r.json()["data"][0]["b64_json"]))原图建议先压缩到合理尺寸;大图上传会明显增加请求耗时。多图场景可重复传
image 字段。