Microsoft AI: MAI-Image-2.7 Flash API
Microsoft AI: MAI-Image-2.7 Flash delivers fast, controllable image generation and editing for high-volume creative workflows.
Microsoft AI: MAI-Image-2.7 Flash is a diffusion-based image model designed for text-to-image generation and precise, controllable image-to-image editing. It accepts text and image inputs, supports up to5 style or subject reference images for reference-guided asset generation, and operates with a32,000 tokens context. Outputs are always PNG images returned in a base64-encoded JSON object.
This public-preview model is intended for interactive creative tools, rapid iteration, personalization, and high-volume generation where speed and per-image cost matter more than4K-quality finishing. It can clean up product photos, generate transparent backgrounds, replace objects without manual masking, refine colors or materials, and create storefront, signage, and marketing visuals with accurately rendered text. Explicitly specifying the editing area is recommended for local edits.
MAI-Image-2.7 Flash is a faster, lower-cost variant with the same generation and editing capabilities as MAI-Image-2.7, trading some fidelity for speed. It is limited to image generation and editing, without text reasoning, tool use, or web search. Reference images must be JPEG or PNG, image-editing references are limited to5 images, and output width and height must each be at least768 pixels.
Updated:
MODEL ID
mai-image-2.7-flash- Context
- 4.096K
- Max output
- 1.024K
- Input
- text / image
- Output
- image
Highlights
- Fast image generation
- Controllable image editing
- Up to5 reference images
- Accurate rendered text
- PNG base64 JSON output
Providers
Compare API prices across providers. Select a provider to view all charges and conditions.
| Uptime | |
|---|---|
Historical observations are not a live health check. Missing data does not mean an outage.
Benchmarks
- 7
Artificial Analysis leaderboard — image editing
Ranked7th for image editing.
- 11
Artificial Analysis leaderboard — text-to-image generation
Ranked11th for text-to-image generation.
- 3
Artificial Analysis — scene and style editing
Ranked3rd for scene and style editing.
- 4
Artificial Analysis — enhancement and restoration
Ranked4th for enhancement and restoration.
Scores as published by the model provider.
Quick Start
Submit an image task, poll its status, then save the images. These examples use curl and Python 3 (standard library only).
POST https://openapi.felo.ai/api/v1/images/generations
1Get your API key
Create a key from your Felo API Platform account and set it as an environment variable.
export FELO_API_KEY="YOUR_API_KEY"2Make your first request
Optional values vary by model. This example leaves them unset; confirm supported values in Playground before adding them. Request fields sit alongside model and prompt, without an input wrapper.
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"
}'3Poll the task
Submission returns task_id. Poll every 3 seconds while queued or running; stop on succeeded, failed or interrupted. This example stops waiting after 30 minutes. Keep created.json to resume querying the same task instead of submitting again.
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")
PY4Download the output
After success, save outputs from task.json. Results may be HTTPS URLs, URL objects or b64_json. Download signed URLs promptly; media downloads do not use your 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
For image editing, replace the example URL with your HTTPS image URL or a base64 image data URL. Submit once, then use the same polling and saving steps.
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"
}
}
]
}'Supported parameters
- n
- background
- max_tokens
- temperature
- aspect_ratio
- input_references
- max_completion_tokens
Prefer the full reference?
API reference →Frequently asked questions
What is Microsoft AI: MAI-Image-2.7 Flash?
Microsoft AI: MAI-Image-2.7 Flash is a diffusion-based image model designed for text-to-image generation and precise, controllable image-to-image editing. It accepts text and image inputs, supports up to5 style or subject reference images for reference-guided asset generation, and operates with a32,000 tokens context. Outputs are always PNG images returned in a base64-encoded JSON object. This public-preview model is intended for interactive creative tools, rapid iteration, personalization, and high-volume generation where speed and per-image cost matter more than4K-quality finishing. It can clean up product photos, generate transparent backgrounds, replace objects without manual masking, refine colors or materials, and create storefront, signage, and marketing visuals with accurately rendered text. Explicitly specifying the editing area is recommended for local edits. MAI-Image-2.7 Flash is a faster, lower-cost variant with the same generation and editing capabilities as MAI-Image-2.7, trading some fidelity for speed. It is limited to image generation and editing, without text reasoning, tool use, or web search. Reference images must be JPEG or PNG, image-editing references are limited to5 images, and output width and height must each be at least768 pixels.
How is usage billed?
Your bill depends on the provider you use, its prices and your usage. Longer inputs or other conditions may have different prices. Billed based on the actual generation cost. See your bill for the final amount.
What inputs does MAI-Image-2.7 Flash support?
It supports text input and image input. Reference images must be JPEG or PNG, and up to5 style or subject reference images can be used.
What output does it return?
The model always returns a PNG image in a base64-encoded JSON object. Output image width and height must each be at least768 pixels.
What tasks is it suitable for?
It is suitable for text-to-image generation, image-to-image editing, product photo cleanup, design refinement, personalization, and high-volume creative workflows.
Does it support reasoning, tools, or web search?
No. It is limited to image generation and editing and does not include text reasoning, tool use, or web search.
How does it differ from MAI-Image-2.7?
It is designed as a faster, lower-cost variant with the same generation and editing capabilities, trading some fidelity for speed.