Microsoft AI: MAI-Image-2.7 Flash API
Microsoft AI 的快速影像模型,支援文字生圖、影像編輯與參考圖導向資產生成。
Microsoft AI: MAI-Image-2.7 Flash 是以 diffusion 為基礎的影像模型,支援文字輸入、影像輸入與影像輸出。它可進行文字轉影像生成、精準且可控制的影像對影像編輯,並能使用最多5張風格或主體參考影像生成資產。輸出一律為 PNG,並以 base64 編碼的 JSON物件返回。
此模型定位為 MAI-Image-2.7 的更快速、較低成本版本,適合高量草稿製作、互動式創意工具、快速迭代、個人化生成與產品影像清理。它也適合變更物件色彩或材質、製作商店招牌與行銷視覺,以及需要準確呈現文字的影像任務;相較於完整品質取向,模型會以部分保真度換取速度。
更新時間:
模型 ID
mai-image-2.7-flash- 上下文
- 4.096K
- 最大輸出
- 1.024K
- 輸入
- text / image
- 輸出
- image
核心要點
- 快速且較低成本
- 支援影像精準編輯
- 最多5張參考影像
- 輸出固定為 PNG
- 適合高量生成
供應商
比較不同供應商的呼叫價格,點擊供應商可查看完整費用和適用條件。
| 可用率 | |
|---|---|
歷史統計不等於即時健康檢查,缺少資料不代表服務中斷。
基準測試
- 7
Artificial Analysis 排行榜 —影像編輯
排名為第7
- 11
Artificial Analysis 排行榜 —文字轉影像生成
排名為第11
- 3
Artificial Analysis — 場景與風格編輯
排名為第3
- 4
Artificial Analysis — 增強與修復
排名為第4
分數來自模型廠商公布的資料,未經獨立驗證。
快速开始
提交圖片任務、輪詢狀態,再儲存圖片。以下範例使用 curl 和 Python 3(僅標準函式庫,無須安裝依賴)。
POST https://openapi.felo.ai/api/v1/images/generations
1填入 API key
從 Felo API Platform 帳戶建立 key,並設定為環境變數。
export FELO_API_KEY="YOUR_API_KEY"2發出第一次請求
選用參數的值依模型而異,範例不預設這些值;加入前請在 Playground 確認。請求欄位與 model、prompt 同層,不包在 input 中。
curl --fail-with-body --max-time 60 "https://openapi.felo.ai/api/v1/images/generations" \
-H "Authorization: Bearer $FELO_API_KEY" \
-H "Content-Type: application/json" \
-o created.json \
-d '{
"prompt": "A studio product photo of a ceramic coffee cup on warm linen, soft morning light",
"model": "mai-image-2.7-flash"
}'3輪詢任務
提交後取得 task_id;queued、running 時每 3 秒查詢一次,succeeded、failed 或 interrupted 時停止。範例最多等待 30 分鐘。保留 created.json 可繼續查詢同一任務,避免重複提交。
python3 - <<'PY'
import json, os, time
from pathlib import Path
from urllib.parse import quote
from urllib.request import Request, urlopen
task = json.loads(Path("created.json").read_text())
task_id = task["task_id"]
url = "https://openapi.felo.ai/api/v1/images/generations/" + quote(task_id, safe="")
headers = {"Authorization": "Bearer " + os.environ["FELO_API_KEY"]}
deadline = time.monotonic() + 1800
while task["status"] in ("queued", "running"):
if time.monotonic() >= deadline:
raise TimeoutError(f"Keep task_id={task_id} to resume polling")
time.sleep(3)
with urlopen(Request(url, headers=headers), timeout=60) as response:
task = json.load(response)
if task.get("task_id") != task_id or task.get("kind") != "image":
raise ValueError("Unexpected task response")
print(task["status"])
if task["status"] != "succeeded":
raise RuntimeError(task.get("error") or task["status"])
if not task.get("outputs"):
raise ValueError("Task succeeded without image outputs")
Path("task.json").write_text(json.dumps(task))
print("Saved task.json")
PY4下載輸出
成功後從 task.json 讀取 outputs 並儲存。結果相容 HTTPS 位址、URL 物件和 b64_json。簽名位址請及時下載;下載圖片時無須攜帶 API Key。
python3 - <<'PY'
import base64, json
from pathlib import Path
from urllib.request import urlopen
task = json.loads(Path("task.json").read_text())
if task.get("status") != "succeeded" or not task.get("outputs"):
raise ValueError("No completed image outputs")
extensions = {"image/png": ".png", "image/jpeg": ".jpg", "image/webp": ".webp", "image/gif": ".gif", "image/avif": ".avif"}
for index, output in enumerate(task["outputs"], 1):
item = output if isinstance(output, dict) else {}
url = output if isinstance(output, str) else item.get("url") or item.get("unsigned_url")
mime = item.get("media_type") or "image/png"
if url and url.startswith("https://"):
with urlopen(url, timeout=60) as response:
data = response.read()
mime = response.headers.get_content_type()
elif url and url.startswith("data:image/") and ";base64," in url:
header, encoded = url.split(",", 1)
mime = header[5:].split(";", 1)[0]
data = base64.b64decode(encoded, validate=True)
elif item.get("b64_json"):
data = base64.b64decode(item["b64_json"], validate=True)
else:
raise ValueError("Unrecognized image output")
path = Path(f"image-{index}" + extensions.get(mime, ".bin"))
path.write_bytes(data)
print(path)
PYinput_references
編輯圖片時,將範例位址替換為你的 HTTPS 圖片位址或 base64 圖片 data URL。提交一次後,沿用相同的輪詢與儲存步驟。
curl --fail-with-body --max-time 60 "https://openapi.felo.ai/api/v1/images/generations" \
-H "Authorization: Bearer $FELO_API_KEY" \
-H "Content-Type: application/json" \
-o created.json \
-d '{
"prompt": "Keep the product and framing. Replace the background with a sunlit marble countertop.",
"model": "mai-image-2.7-flash",
"input_references": [
{
"type": "image_url",
"image_url": {
"url": "https://example.com/product.png"
}
}
]
}'支援的參數
- n
- background
- max_tokens
- temperature
- aspect_ratio
- input_references
- max_completion_tokens
想查看完整文件?
API 文件 →常見問題
什麼是 Microsoft AI: MAI-Image-2.7 Flash?
Microsoft AI: MAI-Image-2.7 Flash 是以 diffusion 為基礎的影像模型,支援文字輸入、影像輸入與影像輸出。它可進行文字轉影像生成、精準且可控制的影像對影像編輯,並能使用最多5張風格或主體參考影像生成資產。輸出一律為 PNG,並以 base64 編碼的 JSON物件返回。 此模型定位為 MAI-Image-2.7 的更快速、較低成本版本,適合高量草稿製作、互動式創意工具、快速迭代、個人化生成與產品影像清理。它也適合變更物件色彩或材質、製作商店招牌與行銷視覺,以及需要準確呈現文字的影像任務;相較於完整品質取向,模型會以部分保真度換取速度。
如何計算呼叫費用?
費用取決於你使用的供應商、對應價格和實際用量。長文字輸入等情況可能適用不同價格,詳見計費明細。 按實際生成費用計費,具體金額以帳單為準。
支援哪些輸入與輸出?
支援文字輸入與影像輸入,輸出為影像。輸出格式一律為 PNG,並以 base64 編碼的 JSON物件返回。
模型的上下文與輸出長度是多少?
上下文為32,000 tokens。資料未提供輸出長度上限。
適合哪些任務?
適合文字轉影像、影像編輯、產品影像清理、快速設計迭代,以及使用最多5張參考影像進行資產生成。
參考影像有哪些限制?
影像編輯的參考影像必須是 JPEG 或 PNG,且最多5張。
它與同系列模型有何差別?
它是 MAI-Image-2.7 的更快速、較低成本版本,保留相同的生成與編輯能力,但會以部分保真度換取速度。