围绕 Microsoft MAI Image 2.7 图片编辑模型规划修改方向。在 MAI Image API Playground 中结合原图与明确指令,描述场景、光线、文字,以及需要保留的细节。
MAI Image 2.7 API 配置概览
说明需要修改的内容,以及应当保留的细节。
选择图片并描述修改内容。
通过示例代码组织包含原图和编辑指令的图片编辑请求,再查询任务以获取结果。
将 APIMart API Key 保存到环境变量 APIMART_API_KEY。提交编辑和查询任务时,均通过 Authorization: Bearer <key> 发送该 Key。
向 POST /v1/images/generations 发送请求,model 设为 mai-image-2.7,prompt 填写编辑指令,image_urls 放入 1 个 HTTP 或 HTTPS 原图 URL。从响应的 data[0].task_id 读取任务 ID。
通过 GET /v1/tasks/{task_id} 查询任务。状态为 completed 时,从 data.result.images[0].url[0] 读取图片 URL;状态为 failed 时,从 data.error.message 查看失败原因。
鉴权方式和 API 通用用法请参阅APIMart 文档。
curl -X POST https://api.apimart.ai/v1/images/generations \
-H "Authorization: Bearer $APIMART_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mai-image-2.7",
"prompt": "将图中的产品放在柔和晨光下的大理石厨房台面上,保持产品形状和标签不变。",
"image_urls": [
"https://example.com/source-image.jpg"
]
}'import os
import time
import requests
API_BASE = "https://api.apimart.ai"
headers = {"Authorization": f"Bearer {os.environ['APIMART_API_KEY']}"}
# 1. Submit the generation task
payload = {
"model": "mai-image-2.7",
"prompt": "将图中的产品放在柔和晨光下的大理石厨房台面上,保持产品形状和标签不变。",
"image_urls": [
"https://example.com/source-image.jpg"
]
}
resp = requests.post(f"{API_BASE}/v1/images/generations", headers=headers, json=payload, timeout=60)
resp.raise_for_status()
task_id = resp.json()["data"][0]["task_id"]
# 2. Poll the task until it finishes
for _ in range(200):
task_resp = requests.get(f"{API_BASE}/v1/tasks/{task_id}", headers=headers, timeout=30)
task_resp.raise_for_status()
task = task_resp.json()["data"]
if task["status"] == "completed":
print(task["result"]["images"][0]["url"][0])
break
if task["status"] == "failed":
raise RuntimeError(task.get("error", {}).get("message", "generation failed"))
time.sleep(3)
else:
raise TimeoutError(f"task {task_id} did not finish in time; continue GET polling with this task ID")TASK_ID="task_xxx" # replace with the task_id returned by the POST request
curl "https://api.apimart.ai/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer $APIMART_API_KEY"| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
model | string | 是 | 默认值: mai-image-2.7 | 本页示例使用的模型值:mai-image-2.7。 |
prompt | string | 是 | 默认值: — | 描述希望进行的编辑,以及原图中需要保留的元素。 |
image_urls | array | 是 | 默认值: — | 包含且仅包含 1 个原图 HTTP 或 HTTPS URL 的数组,用于图片编辑。 |
围绕图片中的关键细节组织修改要求。
为已有视觉素材准备具体的修改方案。
通过三个步骤一起检查原图与编辑指令。
从本地文件或 HTTP/HTTPS 图片链接中选择需要编辑的原始图片。
先描述主要改动,再列出应当保留的物体、文字、纹理或区域。
在 Form 或 JSON 中核对原图与提示词,去除矛盾要求后继续完善方案。
了解原图、编辑提示词与工作台配置。
MAI Image 2.7 是微软的图片编辑模型。MAI Image API 工作台用于整理原图与指令,覆盖场景、风格、光照、文字和修复等编辑方向。
先选择原图,再在 mai-image-api 提示词中说明预期改动,并明确列出需要保持不变的重要细节。
MAI Image API 工作台一次选择一张原图,可用本地文件或图片链接。准备另一张图片的编辑时,替换当前原图即可。
先在 API 提示词中写明主要改动,再补充环境、光照和保留要求。优先使用明确指令,避免同时提出相互冲突的目标。
在 API 提示词中明确产品形状、人物特征、材质、文字或保留区域。这些属于编辑方向,不代表每个细节都能精确保留的保证。
在 MAI Image API 方案中描述新环境,同时写明主体位置与比例。补充接触阴影和透视关系,有助于明确物体与场景之间的预期关系。
为 MAI Image API 描述光线方向、柔和程度、颜色与氛围,说明哪些阴影和反射需要变化,以及哪些部分应保持视觉一致。
在 MAI Image API 提示词中描述媒介、色彩和纹理,再指出应保留的主体、姿态与构图,避免只使用含糊的风格标签。
在 API 提示词中用引号写出准确的替换文字,并说明位置与所在表面。仍需认真核对拼写、对齐和可读性。
明确告诉 Microsoft MAI Image API 要处理哪些划痕、褪色或瑕疵,并指定需要保留的脸部特征、纹理、材质以及原场景中的重要元素。
在 MAI Image API 提示词中使用左侧、后方、接触或遮挡等明确相对位置,并补充比例、透视及用于定位的周边物体。
MAI Image API 工作台可选择本地图片或输入 HTTP/HTTPS 图片链接。链接应直接指向图片素材,而不是包含图片的网页。
Form 与 JSON 描述同一份 MAI Image API 草稿。有效 JSON 会回填表单;内容有误时显示提示,并保留编辑文字和此前的表单草稿。 mai-image-2.7 是本页使用的配置 ID。
重置会清除 MAI Image API 工作台中的当前原图与编辑提示词,并恢复初始配置。需要保留的指令请先复制。
本页标题中的这些名称只是不同拼写,不应当作 API 请求标识。MAI Image 27、MAIImage 2.7 和 MAI-Image2.7 属于搜索写法,不代表另一个型号或 API ID。mai-image-2.7 是本页配置 ID;实际请求使用的标识应以对应 API 文档为准。
登录 APIMart 后,通过本页顶部的 API Keys 入口进入密钥管理,即可创建和管理 APIMart API Key。身份验证要求与请求标识请查阅对应 API 文档。
探索同类型的其他模型。

Hy Image V3.5 Preview
HY Image 3.5 Preview is an image generation and editing model developed by Tencent Hunyuan. It supports text-to-image creation, reference-based generation, and multi-turn editing, allowing users to refine images through conversational instructions. With support for up to 4K output and flexible image dimensions, it offers a versatile tool for creating and refining visual content.

Flux 3 Image Klein
FLUX 3 Image Klein is a compact, open-weight image generation and editing model developed by Black Forest Labs. It combines text-to-image creation, image editing, and composition using up to 10 reference images in a single model. With support for up to 4K resolution and bounding-box layout control, it gives creators flexible tools to bring their ideas to life.

Mai Image 2.6
MAI-Image-2.6 is Microsoft's image model for text-to-image, single-image editing and composition with up to 5 reference images. It is available in high-quality and Flash versions, with 1K and 2K output and sharp text rendering.

Mai Image 2.6 Flash
MAI-Image-2.6 Flash is the Flash version of Microsoft MAI-Image-2.6 for text-to-image and image editing with up to 5 references, 1K/2K PNG output and optional Bing grounding, billed by actual token usage.