Skip to Content
ModelsMAI Image

MAI Image family

Microsoft’s image generation and editing models, three in total, called through the OpenAI-compatible API in much the same way as GPT Image: text to image uses /v1/images/generations, and editing uses /v1/images/edits.

Choosing a model

Model IDs (copy them exactly)
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

All three take the same parameters; in our tests a 1024×1024 image takes about 12 to 25 seconds. For live prices, see the model page .

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.5-flash", prompt="A red apple on a white table", size="1024x1024", ) with open("output.png", "wb") as f: f.write(base64.b64decode(resp.data[0].b64_json))

Size (size)

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.
  • For higher resolutions, use Nano Banana Pro (up to 4K) or GPT Image.

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

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.

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

Can MAI Image generate 2K or 4K images?

No. size only sets the aspect ratio, and the output is about 1 megapixel in total. In our tests both 2048x2048 and 4096x4096 produced 1024x1024. For higher resolutions, use Nano Banana Pro or GPT Image.

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