Skip to Content
ModelsMAI Image

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

Model IDs (copy them exactly)
MAI Image 2.6microsoft/mai-image-2.6
MAI Image 2.6 Flashmicrosoft/mai-image-2.6-flash
MAI Image 2.5 Promicrosoft/mai-image-2.5-proComplex compositions; consistent people and objects
MAI Image 2.5microsoft/mai-image-2.5Precise local edits
MAI Image 2.5 Flashmicrosoft/mai-image-2.5-flashLow latency; batch generation

Current prices — MAI Image 2.6 , MAI Image 2.6 Flash , MAI Image 2.5 .

Text to image

mai_image.py
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))
A red apple on a white table
1024×1024 PNG generated by MAI Image 2.6 Flash in the test.

Response excerpt with the Base64 image data omitted.

{ "data": [ { "b64_json": "BASE64_PNG_OMITTED" } ] }

Size (size)

MAI Image 2.5

Key pointsize only sets the aspect ratio. Output is about 1 megapixel, and passing a larger size does not increase the resolution.
Requested sizeActual output
Omitted1024×1024
1024x1024, 2048x2048, 4096x40961024×1024
1536x10241248×832
1024x1536832×1248
100x100768×768
  • 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

Terminal
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.png

In 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

ErrorCauseFix
Request timeoutThe client timeout is too shortSet the timeout to 300 seconds or more
404 model_not_foundModel ID misspelledCopy the model ID from this page

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.

Last updated on