Microsoft
MAI Image 2.7
mai-image-2.7/text-to-image
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/text-to-image
Input
Showcases
View all showcasesOutput
imagePricing
mai-image-2.7/text-to-image per image
| Specifications | Unit Price |
|---|---|
| 1K | $0.0504 |
| 2K | $0.2013 |
Positioning Overview
This is a text-only image generation model aimed primarily at developers and design teams that need high-quality visual output. Simply enter a natural language prompt to generate a static image matching the description, with support for specifying aspect ratio, transparent background, and output format. It is suitable for scenarios such as creative concept art, advertising assets, and e-commerce display images, helping quickly turn text ideas into ready-to-use image assets.
Key Highlights
- High-resolution image output — supports two resolution tiers, 1K and 2K, meeting different clarity needs from preview to final image.
- Flexible aspect ratio and background control — offers seven aspect ratios and a choice of opaque or transparent background, adapting to a variety of design layouts.
- Rich output format options — can output PNG, JPEG, or WebP, making it convenient for direct use on the web, in print, or for further processing.
- Long prompt support — prompts support up to 20,000 characters, allowing detailed descriptions to precisely control image content.
Capability Description
- Text-to-image: generates static images from natural language prompts, suitable for creative ideation and visual asset production.
- Resolution and aspect ratio adjustment: each request can select one resolution tier from 1K or 2K and one of seven aspect ratios to control output size and composition orientation.
- Transparent background output: can generate images with a transparent background, making it easy to overlay onto different background colors or design drafts.
- Output format specification: a single request can specify one output format among PNG, JPEG, or WebP, adapting to different usage environments.
Applicable Scenarios
- Creative teams quickly producing concept art — input detailed text descriptions to generate multiple concept images for internal review or direction exploration, saving time on sketching.
- E-commerce and advertising asset production — generate background or atmosphere images based on product selling-point prompts; 2K images can be used directly as advertising assets.
- Generating transparent elements for design drafts — choose transparent background output as PNG and place the generated graphic elements directly into posters or interface designs.
- Image generation for content platforms — generate images for articles or social media, specifying aspect ratio and output format (e.g., WebP) for quick publishing.
Limitations and Model Selection Advice
Supports a maximum output resolution of only 2K, with no 4K option; prompts are limited to 20,000 characters; each request can select only one aspect ratio, one resolution tier, and one output format, and multiple combinations cannot be obtained simultaneously.
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/text-to-image
routestringOptionalCurrent fixed value: default
inputobjectRequired
Business parameters for mai-image-2.7/text-to-image and route default — see the parameter table below.
promptstringRequiredminLength 1maxLength 20000The prompt for text-to-image generation, describing the desired image content; takes a string value.
backgroundstringOptionalDefault: "opaque"Controls how the background of the generated image is handled; takes a string value, default opaque.
opaquetransparentimage_sizestringOptionalDefault: "square_hd"Specifies the size specification of the generated image; takes a string value, default square_hd.
square_hdportrait_4_3landscape_4_3portrait_3_2landscape_3_2portrait_16_9landscape_16_9resolutionstringOptionalDefault: "1K"Specifies the resolution tier of the generated image; takes a string value, default 1K.
1K2Koutput_formatstringOptionalDefault: "png"Specifies the output file format of the generated image; takes a string value, default 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/text-to-image",
"input": {
"prompt": "…",
"background": "opaque",
"image_size": "square_hd",
"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/text-to-image",
input: {
"prompt": "…",
"background": "opaque",
"image_size": "square_hd",
"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/text-to-image",
"input": {
"prompt": "…",
"background": "opaque",
"image_size": "square_hd",
"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 Text-to-Image Getting Started Guide: Capability Boundaries, Pricing, and Integration Practices
From capability boundaries to per-image billing integration practices, all in one place
-
Comparison
MAI Image 2.7 Text-to-Image vs. Comparable Models: A Developer's Guide to Model Selection and Migration
Choose the right text-to-image model by capability, per-image cost, and integration method
-
Tutorial
Hands-on text-to-image with mai-image-2.7: 5 high-value business scenarios and implementation essentials
From e-commerce assets to batch content production: implementing 5 types of real needs with a unified image generation API
Related Models
View all models →Same Type
-
FIBO 2.0 Bria $0.057 /image -
Nano Banana 2 Google $0.018 /image -
FLUX.2 Klein 4B Black Forest Labs $0.0004 /image -
Recraft Creative Upscale Recraft $0.357 /image -
Grok Imagine Image 2.0 xAI $0.052 /image -
Qwen Image 2.0 Alibaba $0.042 /image -
Imagen 4 Google $0.030 /image -
Ideogram 4.6 Ideogram $0.011 /image -
Google Virtual Try-On Google $0.107 /image -
BRIA Product Shot Bria $0.058 /image -
FLUX.2 Black Forest Labs $0.035 /image -
GPT Image 2.5 OpenAI $0.0021 /image



