图片生成与编辑
先用文生图验证 Provider;参考图和蒙版任务应逐步增加输入,便于定位失败字段。
调用入口
POST /v1/images/generations
Authorization: Bearer <GATEWAY_API_KEY>
文生图
curl -X POST http://localhost:9890/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_GATEWAY_KEY" \
-d '{
"model": "agnes-2.1",
"prompt": "minimal product photo, soft natural light, clean background",
"size": "1024x1024",
"response_format": "url"
}'
单图参考
{
"model": "agnes-2.1",
"prompt": "keep the subject and composition, change to a cinematic poster style",
"image": "https://example.com/input.jpg",
"strength": 0.55,
"size": "1024x1024",
"response_format": "url"
}
strength 越高,允许偏离原图的程度通常越大。先从中等值测试。
多图参考
{
"model": "agnes-2.0",
"prompt": "combine the clothing style from the first image with the scene from the second",
"images": [
"https://example.com/look.jpg",
"https://example.com/scene.jpg"
],
"size": "1024x1024"
}
局部编辑
{
"model": "agnes-2.1",
"prompt": "replace the selected area with white tulips and keep the original lighting",
"image": "https://example.com/original.jpg",
"mask": "https://example.com/mask.png",
"size": "1024x1024"
}
输入建议
- 参考图片 URL 必须可由 Gateway 安全下载;不要使用只在浏览器本地可见的路径。
- 多图任务先用两张图片验证,再增加数量。
- 蒙版的尺寸和原图保持一致,明确黑白区域含义。
- 需要直接嵌入响应时使用
b64_json;日常更推荐 URL。