Felo API PlatformFelo API Platform
返回模型列表

Microsoft AI: MAI-Image-2.7 API

Microsoft AI 的图像生成与编辑模型,支持高保真创作、精准修改和图中文字渲染。

MAI-Image-2.7 支持文本输入和图像输入,并生成图像输出。它可根据文本提示生成图像,也能通过图生图编辑现有图像,移除、替换对象或调整对象属性,同时尽量保持构图、布局和迭代编辑中的视觉一致性。

该模型适合创意生成、场景重塑与重新布光、产品图和品牌资产制作、插画、徽标与图标生成,以及现有素材的修复和增强。它还支持修复图像中的文字、标签、海报、包装和标牌文字,并可处理局部重绘与运动模糊伪影移除。

MAI-Image-2.7 提供更准确、可控的编辑能力,以及更好的文字渲染和写实效果。相较 MAI-Image-2.6,它在全部10 个评估用例和全部7 项编辑操作上均有改进;目前可作为 Microsoft Foundry 中的公开预览版本使用。

更新时间:

模型 ID

mai-image-2.7
上下文
4.096K
最大输出
1.024K
输入
text / image
输出
image

核心要点

  • 文本生成图像
  • 图像精准编辑
  • 保持构图一致
  • 改进文字渲染
  • 高保真写实效果
  • 支持局部重绘

供应商

1 个供应商

比较不同供应商的调用价格,点击供应商可查看完整费用和适用条件。

供应商 · 计费明细
可用率

基准测试

  • AA-Image-Editing v2.1

    Elo;5,478 次投票;截至2026-11-16 排名第1

    1215
  • Artificial Analysis 场景与风格

    Elo,高于下一名模型

    24
  • Artificial Analysis 实景电影

    排名第1

    第1
  • Artificial Analysis 消费者

    排名第1

    第1
  • Artificial Analysis 前沿编辑

    排名第1

    第1

分数来自模型厂商公布的数据,未独立验证。

快速开始

提交图片任务、轮询状态,再保存图片。以下示例使用 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"
}'

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")
PY

4下载输出

成功后从 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)
PY
input_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",
  "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?

MAI-Image-2.7 支持文本输入和图像输入,并生成图像输出。它可根据文本提示生成图像,也能通过图生图编辑现有图像,移除、替换对象或调整对象属性,同时尽量保持构图、布局和迭代编辑中的视觉一致性。 该模型适合创意生成、场景重塑与重新布光、产品图和品牌资产制作、插画、徽标与图标生成,以及现有素材的修复和增强。它还支持修复图像中的文字、标签、海报、包装和标牌文字,并可处理局部重绘与运动模糊伪影移除。 MAI-Image-2.7 提供更准确、可控的编辑能力,以及更好的文字渲染和写实效果。相较 MAI-Image-2.6,它在全部10 个评估用例和全部7 项编辑操作上均有改进;目前可作为 Microsoft Foundry 中的公开预览版本使用。

如何计算调用费用?

费用取决于你使用的供应商、对应价格和实际用量。长文本输入等情况可能适用不同价格,详见计费明细。 按实际生成费用计费,具体金额以账单为准。

MAI-Image-2.7 支持哪些输入和输出?

支持文本输入和图像输入,输出图像。

它可以编辑现有图像吗?

可以。它支持图生图转换、局部重绘、对象移除与替换、属性修改、文字更新,以及运动模糊伪影移除。

MAI-Image-2.7适合哪些任务?

适合创意生成、场景重塑与重新布光、产品图和品牌资产制作、插画、徽标与图标生成,以及素材修复增强。

它在文字渲染方面有什么特点?

它可以在标签、海报、包装和标牌中渲染文字,并提供改进的文字渲染效果。

它与同系列模型有什么差别?

相较 MAI-Image-2.6,MAI-Image-2.7 在全部10 个评估用例和全部7 项编辑操作上均有改进。

相关模型