MAI Image family
Call Microsoft’s MAI Image models through the OpenAI-compatible API. Use /v1/images/generations for text to image and /v1/images/edits for editing.
Choosing a model
microsoft/mai-image-2.6microsoft/mai-image-2.6-flashmicrosoft/mai-image-2.5-proComplex compositions; consistent people and objectsmicrosoft/mai-image-2.5Precise local editsmicrosoft/mai-image-2.5-flashLow latency; batch generationCurrent prices — MAI Image 2.6 , MAI Image 2.6 Flash , MAI Image 2.5 .
Text to image
Python
import base64
from openai import OpenAI
client = OpenAI(api_key="YOUR_OFOX_API_KEY", base_url="https://api.ofox.ai/v1", timeout=600)
resp = client.images.generate(
model="microsoft/mai-image-2.6-flash",
prompt="A red apple on a white table",
size="1024x1024",
n=1,
)
with open("output.png", "wb") as f:
f.write(base64.b64decode(resp.data[0].b64_json))
Response excerpt with the Base64 image data omitted.
{
"data": [
{
"b64_json": "BASE64_PNG_OMITTED"
}
]
}Size (size)
MAI Image 2.5
size only sets the aspect ratio. Output is about 1 megapixel, and passing a larger size does not increase the resolution.- The output keeps the requested aspect ratio, with total pixels adjusted to about 1 million; a size that is too small produces 768×768.
MAI Image 2.6 / 2.6 Flash
On OfoxAI, MAI Image 2.6 Flash returned a 1024×1024 PNG for the size="1024x1024" example above. Microsoft Foundry lists up to 2,359,296 total pixels for 2.6 and 2.6 Flash (equivalent to 1536×1536). Microsoft Foundry
Image editing
curl https://api.ofox.ai/v1/images/edits \
--max-time 600 \
-H "Authorization: Bearer $OFOX_API_KEY" \
-F model=microsoft/mai-image-2.5 \
-F prompt="Make the apple purple, keep everything else the same" \
-F image=@apple.jpg \
| jq -r '.data[0].b64_json' | base64 --decode > apple_purple.pngIn the MAI Image 2.5 example, reference images count as input tokens; see usage.input_tokens_details.image_tokens in the response. We measured 576 tokens for one 768×768 reference image.
The OfoxAI catalog lists /v1/images/edits for MAI Image 2.6 and 2.6 Flash. Microsoft Foundry documents up to five JPEG or PNG reference images per edit for these models. Microsoft Foundry
Common errors
For multiple images, send several requests concurrently, one image per request.
FAQ
What output size can I expect from MAI Image?
For 2.5, see the sizes measured on OfoxAI in the table above. The 2.6 Flash example returns 1024×1024. Microsoft Foundry lists a higher pixel limit for the 2.6 series.
How do I edit images with MAI Image?
Use /v1/images/edits and upload the image file as a multipart form, the same way as with GPT Image.