Image
MAI-Image-2.7 Flash
使用 Microsoft MAI-Image-2.7 Flash 進行快速、低成本的影像生成與編輯,支援最多 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-flash","prompt":"A glass perfume bottle on a white marble countertop, clean product photography","size":"1:1","resolution":"1K"}'端點與標頭
POST https://api.seedrouter.ai/v1/images/generations
| 標頭 | 值 |
|---|---|
| Authorization | Bearer YOUR_API_KEY |
| Content-Type | application/json |
請將金鑰妥善保存在你的伺服器端。HTTP 200 僅代表任務已受理,並不表示影像已生成完成。影像編輯同樣使用 /v1/images/generations 端點,只需搭配 image_urls 參數即可。
參數
mai-image-2.7-flash 與 mai-image-2.7 共用完全相同的 9 個可接受的欄位與限制條件。僅 model 與 prompt 為必填。省略選填欄位即套用預設值;所有欄位皆不接受 null。Playground 介面提供固定的模型與全部 8 個可編輯輸入欄位。
| 欄位 | 型別 | 預設值 | 限制條件 |
|---|---|---|---|
model | 字串 | 必填 | mai-image-2.7-flash |
prompt | 字串 | 必填 | 去除前後空白後 1–20000 個 Unicode 字元 |
n | 整數 | 1 | 必須為 1;若需多張圖片請分別提交任務 |
size | 字串 | 1:1 | 僅限文字轉圖片;整數長寬比 1:4–4:1 或 WIDTHxHEIGHT(亦接受 * / ×);不接受 auto |
resolution | 字串 | 1K | 1K 或 2K(不分大小寫);僅在 size 為長寬比時生效;不接受 4K |
width | 整數 | 省略 | 精確像素寬度,>= 768;必須與 height 成對提供;覆寫 size 與 resolution;僅限文字轉圖片 |
height | 整數 | 省略 | 精確像素高度,>= 768;必須與 width 成對提供;width × height <= 4,194,304(2048×2048) |
image_urls | 字串陣列 | 省略 | 1–5 個不含憑證的公開 HTTP(S) 圖片 URL,用於單圖編輯或多圖合成 |
background | 字串 | auto | auto 或 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。- 傳入未定義的欄位將回傳 HTTP 400。輸出格式一律為 PNG。
參考圖片
在 image_urls 中傳入 1–5 個不含內嵌憑證的公開 HTTP(S) URL,即可進行單圖編輯或多圖合成。支援的輸入格式為 JPEG、PNG、WebP 與 GIF。SeedRouter 不接受 Base64 data URI。
當提供 image_urls 時,模型會依參考圖片決定輸出尺寸;size、resolution、width 與 height 不會影響圖生圖的輸出尺寸。
{
"model": "mai-image-2.7-flash",
"prompt": "Combine both reference images into a clean studio product photograph",
"image_urls": [
"https://example.com/first.png",
"https://example.com/second.png"
]
}計費方式
計費涵蓋三種 Token 類別:文字輸入、影像輸入與影像輸出。將各類別實測用量乘以其即時費率即為總費用。失敗的請求不收費。請參閱即時價格。
任務回應與輪詢
請求受理後會回傳非同步任務物件:
{"id":"task_example","model":"mai-image-2.7-flash","status":"processing"}curl https://api.seedrouter.ai/v1/tasks/task_example \
-H "Authorization: Bearer $SEEDROUTER_API_KEY"任務完成的回應會在 output.data[0].url 中包含交付的 PNG URL,並附帶實測 size、output.output_format 與 output.usage。建議每 5–10 秒輪詢一次。用戶端發生逾時後,切勿重複提交相同請求。
錯誤處理
HTTP 錯誤回應格式為 {"error":{"code":integer,"message":string}}。請參閱共用錯誤目錄與任務生命週期。
