Claude Opus 5.5 已在 SeedRouter 上线

Image

MAI-Image-2.7

View Markdown

使用 Microsoft MAI-Image-2.7 生成和编辑图像,支持最多 5 个参考图 URL、1K/2K 档位或精确像素尺寸,按 token 计费。

快速示例

提交一次图像生成请求,保存返回的 id,然后轮询任务状态直至变为 completed 或 failed。该 API 采用异步任务模式并返回 PNG URL。

curl https://api.seedrouter.ai/v1/images/generations \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model":"mai-image-2.7","prompt":"A university campus poster at dusk, photorealistic style, cinematic lighting","size":"16:9","resolution":"2K"}'

接口地址与请求头

POST https://api.seedrouter.ai/v1/images/generations

请求头取值
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

请将密钥妥善保存在服务端。HTTP 200 仅表示任务已受理,不代表图像已生成完毕。图像编辑同样使用 /v1/images/generations 接口,并传入 image_urls。

请求参数

共支持 9 个字段。仅 model 和 prompt 为必填项。省略可选字段即可使用默认值;所有字段均不接受 null。Playground 提供固定的模型选择以及全部 8 个可编辑输入项。

字段类型默认值约束
modelstring必填mai-image-2.7
promptstring必填去除首尾空白后为 1–20000 个 Unicode 字符
ninteger1必须为 1;如需生成多张图,请分别提交多个任务
sizestring1:1仅限文生图;整数宽高比 1:4–4:1 或 WIDTHxHEIGHT(也接受 * / ×);不支持 auto
resolutionstring1K1K 或 2K(不区分大小写);仅在 size 为宽高比时生效;不支持 4K
widthinteger省略精确像素宽度,>= 768;必须与 height 成对传入;覆盖 size 和 resolution;仅限文生图
heightinteger省略精确像素高度,>= 768;必须与 width 成对传入;width × height <= 4,194,304(2048×2048)
image_urlsstring array省略1–5 个不含内嵌凭证的公开 HTTP(S) 图片 URL,用于单图编辑或多图合成
backgroundstringautoauto 或 opaque;不支持 transparent

尺寸与宽高比

文生图时,可以传入 size(1:4 至 4:1 的整数比例)搭配 resolution(1K 或 2K),也可以直接在 size 中传入像素尺寸(例如 2048x1152),或成对传入 width 和 height。

  • 像素限制:每边至少为 768,且 width × height 不超过 4,194,304(2048×2048)。每条边会向下取整为 32 的倍数。
  • width 和 height 的优先级高于 size 和 resolution。
  • 传入未知字段(包括 quality、style、output_format、response_format、mask_url、auto_aspect_ratio、web_grounding)将返回 HTTP 400。输出格式固定为 PNG。
size1K2K
1:11024×10242048×2048
4:31152×8642336×1760
3:4864×11521760×2336
3:21248×8322496×1664
2:3832×12481664×2496
16:91344×7682720×1536
9:16768×13441536×2720
2:11536×7682880×1440
1:2768×15361440×2880
21:91792×7683104×1312
9:21768×17921312×3104
4:13072×7684096×1024
1:4768×30721024×4096

参考图

在 image_urls 中传入 1–5 个可公开访问且不含内嵌凭证的 HTTP(S) URL,即可进行单图编辑或多图合成。支持的输入格式为 JPEG、PNG、WebP 和 GIF。SeedRouter 不接受 Base64 data URI,请先将图片托管到公开 URL。

传入 image_urls 时,模型会根据参考图自动决定输出尺寸;size、resolution、width 和 height 不会影响图生图的输出尺寸。

{
  "model": "mai-image-2.7",
  "prompt": "Make the bicycle blue and add a small dog sitting beside the front wheel",
  "image_urls": [
    "https://example.com/bicycle.png"
  ]
}

计费

计费按三类 token 计算:文本输入、图像输入和图像输出。将各类别的实测用量乘以对应实时费率即可得出费用。失败的请求不收费。查看实时价格。

任务响应与轮询

请求受理后会返回一个异步任务对象:

{"id":"task_example","model":"mai-image-2.7","status":"processing"}
curl https://api.seedrouter.ai/v1/tasks/task_example \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY"

任务完成后的响应包含交付的 PNG URL(output.data[0].url)、实测 size、output.output_format 以及 output.usage。建议每隔 5–10 秒轮询一次。客户端超时后切勿重复提交相同请求。

错误处理

HTTP 错误响应格式为 {"error":{"code":integer,"message":string}}。详见通用错误目录与任务生命周期。

相关页面