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
microsoft/mai-image-2.5-proComplex compositions; consistent people and objectsmicrosoft/mai-image-2.5Precise local editsmicrosoft/mai-image-2.5-flashLow latency; batch generationAll 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
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.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)
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.
- For higher resolutions, use Nano Banana Pro (up to 4K) or GPT Image.
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.pngReference 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
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.