Microsoft
MAI Image 2.7
mai-image-2.7/flash/edit
The precision-focused tier in Microsoft's MAI image series, supporting text-to-image and image-to-image editing, capable of object removal and replacement, inpainting, and enhancement, accepting up to 5 reference images per request for multi-image fusion, and maintaining stable composition across multiple editing rounds
Try mai-image-2.7/flash/edit
Input
Showcases
View all showcasesOutput
imagePricing
mai-image-2.7/flash/edit per image
| Specifications | Unit Price |
|---|---|
| 1K | $0.0185 |
| 2K | $0.074 |
Overview
Designed for image editing and image modification scenarios, this model accepts 1 to 5 reference images plus a text prompt and outputs a static image. It suits designers, e-commerce operators, and content producers who want to create new versions from existing assets: adjusting image attributes, replacing elements, or repainting local regions while preserving the original composition and visual style. Output can be 1K or 2K, with a fixed aspect ratio selectable as square, portrait, or landscape, and results are saved as PNG, JPEG, or WebP.
Key Features
- Multi-image input for fused editing — A single request can include up to 5 reference images, used to fuse subjects, products, scenes, and other assets.
- Controllable resolution and aspect ratio — Output can be 1K or 2K, with a fixed portrait or landscape ratio chosen from seven options.
- Optional transparent background output — When the background parameter is set to transparent, the result contains transparent regions for later compositing and layout.
Capabilities
- Reference-image editing and repainting: Using 1 to 5 images as input along with a prompt, it modifies image content, handling object replacement, attribute adjustment, and local repainting while keeping the original compositional relationships in the output.
- Resolution and aspect ratio control: Output resolution is chosen between 1K and 2K, and the aspect ratio is chosen from square, 4:3, 3:2, and 16:9 in both portrait and landscape, to match different placements.
- Output format and background settings: Results can be saved as PNG, JPEG, or WebP; the background can be opaque or transparent, and the transparent option suits downstream workflows that require cutout compositing.
- Prompt-driven detail modification: Text descriptions specify what to change, with prompts up to 20,000 characters, so multiple modification requests can be described in a single request.
Use Cases
- E-commerce operators changing product image backgrounds — Upload a product image and a scene reference image to replace the background or adjust the mood of the main image, then output product visuals in each placement's aspect ratio for storefronts and ad delivery.
- Design teams iterating on poster elements — Use an existing poster as the input image, replace visual elements via prompt while keeping the layout, and generate PNG or WebP files for downstream layout work.
- Content production requiring transparent assets — Input an existing image and set a transparent background to output an image with transparent regions for overlaying onto other backgrounds or templates.
- Fusing multiple reference assets into one image — Upload character, product, and style reference images together and fuse them into a single coherent composition for concept drafts and visual proposals.
Limitations and Selection Advice
A single editing request can include up to 5 reference images; if more assets need to be combined, you should composite the input yourself first. Maximum output resolution is 2K; no 4K option is provided, so large-format print or ultra-high-definition publishing scenarios require separate upscaling. Prompts are limited to 20,000 characters, and input images must be HTTPS links.
What's new
View changelog →- New model New model now available: mai-image-2.7/flash/edit
- New model New model launched: mai-image-2.7/flash/text-to-image
- New model New model released: mai-image-2.7/edit
Frequently asked questions
View all FAQs →-
What editing operations can this model perform?
It supports object removal, object replacement, attribute modification, local inpainting, and image enhancement, while keeping the composition and layout stable across multiple consecutive edits. When making these edits, write what to change and what to keep into the prompt, and leave the rest for the model to infer from the visual context.
-
What is the maximum number of reference images I can pass in a single request?
Up to 5 images, at least 1, passed in via the image_urls array. For multi-reference fusion, pass the person, product, style, and scene each as separate reference images, and state in the prompt what role each image plays; the model will fuse them according to the visual context.
-
What is the maximum output resolution?
Maximum 2K; no 4K option is offered. resolution accepts 1K or 2K, defaulting to 1K; if 4K output is required, you need to switch to another model that supports 4K.
-
How can I write prompts for better editing results?
Organize the prompt in this order: first anchor what to keep, then write the changes, and finally write the blending requirements: ① Clearly state the composition, subject, lighting, and layout to preserve; ② Specify the exact objects to remove, replace, or modify and their target state; ③ Explain how the new elements should blend with the scene in terms of lighting, scale, and position. This model reasons from visual context when a prompt is ambiguous, so spelling out the constraints in full is more effective than piling on adjectives.
Create a generation task
https://api.hiapi.ai/v1/tasks Headers
AuthorizationstringRequiredAccount API key. Required on every request. Example: Bearer YOUR_HIAPI_API_KEY. Get your API key
Content-TypestringOptionalThe request body is always parsed as JSON; when sent, only application/json (optionally with charset) is accepted — any other value returns 415. Example: application/json.
Idempotency-KeystringOptionalIdempotency key, up to 255 bytes. Retries with the same key from the same account create the task only once; replays return the original taskId.
On network timeouts or client retries, the same key creates the task only once — no double charges (scope: the API key's account). Use a business-unique identifier as the key (e.g. "order-42"); replays return the original taskId, and keys expire 24 hours after the first request. See the Unified Async API overview for the full scenario matrix.
Body
modelstringRequiredCurrent fixed value: mai-image-2.7/flash/edit
routestringOptionalCurrent fixed value: default
inputobjectRequired
Business parameters for mai-image-2.7/flash/edit and route default — see the parameter table below.
promptstringRequiredminLength 1maxLength 20000Editing instruction text, used to describe the desired edit or generated content to apply to the input image.
backgroundstringOptionalDefault: "opaque"Background mode string, controls how the background of the generated result is handled; default is opaque.
opaquetransparentimage_sizestringOptionalDefault: "square_hd"Output image size identifier string; default is square_hd.
square_hdportrait_4_3landscape_4_3portrait_3_2landscape_3_2portrait_16_9landscape_16_9image_urlsarrayRequiredminItems 1maxItems 5Array of input image URLs, where each element is the address of an image to be edited; the array itself carries multiple reference/editing source images.
Array [ string ]
resolutionstringOptionalDefault: "1K"Output resolution tier string; default is 1K.
1K2Koutput_formatstringOptionalDefault: "png"Output image file format string; default is png.
pngjpegwebpcallbackobjectOptional
Terminal-state notification config. When omitted, no callback is delivered — poll the task yourself. See the callback note below.
Provide callback.url when creating a task and HiAPI POSTs to your service once the task reaches a terminal state — no polling needed. The callback payload mirrors the task detail structure; signature verification, delivery retries and idempotency are documented on the Unified Async API overview page.
urlstringRequiredRequired when callback is present. A POST is sent to this URL once the task reaches a terminal state; must be a valid http(s) URL.
whenstringOptionalDefault: "final"Only final is supported today — notified on both success and fail.
finalstoragestringOptionalDefault: "temp"Artifact storage tier: temp (default, retained about 7 days) or persistent (long-term, billed by size). Insufficient balance or exceeding the storage cap silently downgrades to temp; the effective tier is shown in the task detail response.
temppersistentRequest examples
# Submit an async task; returns a taskId immediately (no waiting for generation)
curl -X POST "https://api.hiapi.ai/v1/tasks" \
-H "Authorization: Bearer $HIAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mai-image-2.7/flash/edit",
"input": {
"prompt": "…",
"background": "opaque",
"image_size": "square_hd",
"image_urls": "…",
"resolution": "1K",
"output_format": "png"
}
}' const res = await fetch("https://api.hiapi.ai/v1/tasks", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HIAPI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "mai-image-2.7/flash/edit",
input: {
"prompt": "…",
"background": "opaque",
"image_size": "square_hd",
"image_urls": "…",
"resolution": "1K",
"output_format": "png"
}
}),
});
const task = await res.json();
// { code: 200, message: "success", data: { taskId } } import os, requests
res = requests.post(
"https://api.hiapi.ai/v1/tasks",
headers={"Authorization": f"Bearer {os.environ['HIAPI_API_KEY']}"},
json={
"model": "mai-image-2.7/flash/edit",
"input": {
"prompt": "…",
"background": "opaque",
"image_size": "square_hd",
"image_urls": "…",
"resolution": "1K",
"output_format": "png"
}
},
)
print(res.json()) # { code, message, data: { taskId } } 200 OK
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR"
}
} 400 Bad Request
{
"code": 400,
"message": "invalid request",
"data": null,
"error_code": "INVALID_REQUEST"
} Get task detail
https://api.hiapi.ai/v1/tasks/:id Response fields
taskIdstringRequiredTask ID, always prefixed with tk-hiapi-.
modelstringRequiredResolved full model name. Tasks submitted with the route parameter return base@route (e.g. gpt-image-2/text-to-image@ext); otherwise identical to the name passed at creation.
routestringOptionalPresent only when the task was submitted with an explicit route parameter; echoes the submitted value.
statusstringRequiredTask status.
queued Queued, not started yet.
handling Being processed.
archiving Processing finished, artifacts being prepared.
success Terminal: completed, artifacts available (output returned).
fail Terminal: failed (error returned).
After submission, check status: success and fail are terminal, everything else is non-terminal. Poll every 1–3 seconds until terminal. On success, download artifacts from output[].url and transfer them before expireAt; pass storage: "persistent" at creation time when long-term retention is needed.
creatednumberRequiredTask creation time (Unix seconds).
completednumberRequiredUnix seconds when the task reached a terminal state; fixed to 0 while not terminal.
outputarrayOptional
Present only when status == success. Artifact list — always an array; a single task may return multiple types at once (e.g. video + first_frame).
Array [ object ]
Array items
urlstringRequiredArtifact URL, directly downloadable.
typestringRequiredCurrent possible values: video, image, audio, first_frame, last_frame, thumbnail; more may be added later.
expireAtnumberRequiredUnix seconds until which the artifact remains accessible; download or transfer before it expires.
errorobjectOptional
Present only when status == fail.
codestringRequiredBusiness error code.
messagestringRequiredError description.
Response examples
Success
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-01HZTQ8BX2N3GM3YFK4Z9D7VQR",
"model": "happyhorse-1-0",
"status": "success",
"created": 1777282033,
"completed": 1777282099,
"output": [
{
"url": "https://cdn.hiapi.ai/tasks/.../video.mp4",
"type": "video",
"expireAt": 1777886899
}
]
}
} Processing (non-terminal)
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "archiving",
"created": 1777282033,
"completed": 0
}
} Failed
{
"code": 200,
"message": "success",
"data": {
"taskId": "tk-hiapi-...",
"model": "happyhorse-1-0",
"status": "fail",
"created": 1777282033,
"completed": 1777282099,
"error": {
"code": "TASK_FAILED",
"message": "task failed"
}
}
} Articles
View all articles →-
Guide
MAI Image 2.7 Flash Image Editing Getting Started Guide: Image-to-Image Capabilities, Pricing, and Integration Best Practices
A hands-on guide for developers on integrating the Microsoft image-to-image model and controlling costs
-
Comparison
MAI Image 2.7 Flash Image Editing Side-by-Side Comparison: How to Choose an Image-to-Image Model and Key Migration Points
-
Tutorial
MAI Image 2.7 Flash Image Editing in Practice: 5 High-Value Image Editing Scenarios and Integration Essentials
Related Models
View all models →Same Type
-
Qwen Image 2.1 Alibaba $0.020 /image -
BRIA Product Shot Bria $0.058 /image -
Muse Image 1.0 Meta $0.015 per task -
Grok Imagine xAI $0.011 /second -
Nano Banana 2 Google $0.018 /image -
Ideogram 4.6 Ideogram $0.011 /image -
Qwen Image 2.0 Alibaba $0.042 /image -
Recraft Creative Upscale Recraft $0.357 /image -
Krea 2 Medium Turbo Krea $0.021 /image -
Google Virtual Try-On Google $0.107 /image -
851 Labs Background Remover 851 Labs $0.002 /image -
Ideogram V3 Character Ideogram $0.090 /image



