编辑图像
用文字提示编辑或向外扩展已有图像。可以用 JSON 请求体引用已上传的文件,也可以用 multipart 直接上传图片文件。
/v1/images/editsJSON 或 multipart。未在 schema 中定义的字段会作为扩展参数转发给提供商,见 厂商扩展字段。
curl http://localhost:8080/v1/images/edits \
-H "Authorization: Bearer $LLM_PROXY_KEY" \
-F image=@lighthouse.png \
-F mask=@mask.png \
-F model=gpt-image-1 \
-F prompt="Replace the sky with a starry night" \
-F size=1024x1024from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-your-proxy-key")
img = client.images.edit(
model="gpt-image-1",
image=open("lighthouse.png", "rb"),
mask=open("mask.png", "rb"),
prompt="Replace the sky with a starry night",
)
print(img.data[0].url){
"created": 1718047200,
"data": [
{"url": "https://…/lighthouse-edited.png"}
]
}JSON 请求体
images(1–16 条,每条带 file_id 或 image_url),可选的 mask (file_id/image_url),以及 prompt、model、n、size、quality、 response_format、user、background、input_fidelity、moderation、 output_compression、output_format、partial_images、stream。未知字段作为扩展 参数进入提供商(见厂商扩展字段);对 qwen/qwen-intl 来说,这些扩展字段包括 watermark、seed、bbox_list、 color_palette 和 enable_sequential。
本端点的 output_format 只有 png、jpeg、webp;gif 和 svg 仅用于生成端点 (见 GIF 与 SVG 输出)。
Multipart
文件字段 image 和 image[](最多 16 个),外加一个 mask 文件;其他字段以表单字符串 提交。每张图片必须是上传的文件,否则请求会以 Multipart image edits require every image to be an uploaded file 失败。
响应
结构与生成图像相同:{"created", "data":[{"url"|"b64_json"}], …},可能带 usage。流式编辑会发出 image_edit.partial_image / image_edit.completed SSE 事件。
提供商支持
openai、openai-compatible 家族、gemini 和 qwen 类型的提供商,见 能力矩阵。
相关
curl http://localhost:8080/v1/images/edits \
-H "Authorization: Bearer $LLM_PROXY_KEY" \
-F image=@lighthouse.png \
-F mask=@mask.png \
-F model=gpt-image-1 \
-F prompt="Replace the sky with a starry night" \
-F size=1024x1024from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-your-proxy-key")
img = client.images.edit(
model="gpt-image-1",
image=open("lighthouse.png", "rb"),
mask=open("mask.png", "rb"),
prompt="Replace the sky with a starry night",
)
print(img.data[0].url){
"created": 1718047200,
"data": [
{"url": "https://…/lighthouse-edited.png"}
]
}