MAI Image API

Generate and edit images with MAI Image 2.6 or Flash and retrieve asynchronous results.

MAI Image API

Use an Official Group API key with mai-image-2.6 or mai-image-2.6-flash. Each task returns one PNG from text or up to five reference images.

See current availability and pricing on the MAI Image 2.6 model page or Flash model page.

Pricing

Prices are in US dollars per million tokens. Charges use actual usage.

ModelText inputReference image inputImage output
MAI Image 2.6$4.25$6.80$32.30
MAI Image 2.6 Flash$1.4875$2.125$16.15

Output tokens are width × height ÷ 1,024. A 1,024 × 1,024 output uses 1,024 tokens and costs approximately US$0.033075 for 2.6 or US$0.016538 for Flash, plus text and reference inputs. Aspect ratio and edits can change actual dimensions. Cached input uses the standard rate.

The service reserves funds at acceptance and charges actual usage at the price active on submission. Confirmed failures are free. Keep checking submission_unknown and meter_pending until the result is confirmed.

Parameters

ParameterAccepted values
modelEither exact model ID shown above
promptRequired, 1–8,000 characters, in Chinese or English
nFixed at 1
sizeDefaults to 1:1. Accepts auto, integer ratios from 1:4 to 4:1, or dimensions like 1536x1024.
resolution1K (default) or 2K. Lowercase is accepted.
image_urlsUp to five public HTTP(S) image URLs or PNG/JPEG/WebP Base64 data URLs

Exact dimensions must be at least 768 pixels on each side, with a maximum area of 2,359,296 pixels. 2048x1152 and 3072x768 are valid. 2048x2048 exceeds the area limit. Dimensions round down to multiples of 32, so 1000x1000 becomes 992x992. Exact dimensions take precedence over resolution.

For reference-image edits, the model determines output dimensions. The playground accepts PNG, JPEG, or WebP up to 10 MB per file and 48 MB combined. Data URLs follow the same limits and the request-body limit. Public URLs must be accessible without a login.

Set web_grounding: true to enable Bing grounding, which defaults to off. Provide both width and height to override size. Set auto_aspect_ratio: true for automatic aspect ratio. The model still determines dimensions for edits.

Masks, quality, output_format, response_format, stream, and webhook are unavailable. Unsupported fields are rejected.

Submit a task

Each submitted example creates a separate billable task. To check an existing result, use the task query instead.

curl https://app.apipool.dev/v1/images/generations \
  -H "Authorization: Bearer $APIPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"mai-image-2.6","prompt":"A blue ceramic cup on a white background in soft side light","size":"1:1","resolution":"1K","n":1}'

To edit from a URL, replace the example with a public image URL.

curl https://app.apipool.dev/v1/images/generations \
  -H "Authorization: Bearer $APIPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"mai-image-2.6-flash","prompt":"Make the cup red and keep the other details","image_urls":["https://example.com/cup.png"]}'

For local files, use /v1/images/edits and repeat the multipart image field.

curl https://app.apipool.dev/v1/images/edits \
  -H "Authorization: Bearer $APIPOOL_API_KEY" \
  -F "model=mai-image-2.6-flash" \
  -F "prompt=Combine the references into a clean product image" \
  -F "[email protected]" -F "[email protected]"

Query and download

The submission returns HTTP 202 and a task id. Query every 3–5 seconds with the original key. Allow at least three minutes for processing.

TASK_ID="imgtask_..."
curl "https://app.apipool.dev/v1/tasks/$TASK_ID" \
  -H "Authorization: Bearer $APIPOOL_API_KEY"

When the task completes, download data[].url and check usage for text input, image input, and image output tokens. Results are retained for 24 hours. Each signed URL has an expires_at. Query the original task for a new URL during retention. See asynchronous image tasks for Python polling.

Troubleshooting

  • HTTP 400. Check parameters, image dimensions, output count, and reference count. Rejected requests are free.
  • HTTP 401 or 404. Check the key, group, and model ID. Query with the original key.
  • HTTP 429 or 503. Follow Retry-After. If you have a task ID, keep querying it.
  • failed. Read the error and adjust the prompt or reference before submitting again.
  • Submission timeout or submission_unknown. Check the request log before retrying.
  • meter_pending. Keep polling. If it persists, send the task ID to support.