MAI Image 2.6
Generate and edit images with MAI Image 2.6, ordered references, explicit sizing, optional grounding, and asynchronous task polling.
MAI Image 2.6 generates one PNG from a required prompt and optional reference
images. Use model: "mai-image-2.6" with the images endpoint. The website slug
uses hyphens: MAI Image 2.6.
Quickstart
curl https://reapi.ai/api/v1/images/generations \
-H "Authorization: Bearer $REAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mai-image-2.6",
"prompt": "A studio photograph of a small ivory ceramic teapot on an ivory ceramic pedestal, soft daylight, no text.",
"resolution": "1K",
"size": "1:1",
"web_grounding": false
}'import json
import os
import urllib.request
payload = {
"model": "mai-image-2.6",
"prompt": "A studio photograph of an ivory ceramic teapot, soft daylight.",
"resolution": "1K",
"size": "1:1",
"web_grounding": False,
}
request = urllib.request.Request(
"https://reapi.ai/api/v1/images/generations",
data=json.dumps(payload).encode(),
headers={"Authorization": "Bearer " + os.environ["REAPI_API_KEY"],
"Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=120) as response:
task = json.load(response)
print(task["id"])const response = await fetch('https://reapi.ai/api/v1/images/generations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.REAPI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'mai-image-2.6',
prompt: 'A studio photograph of an ivory ceramic teapot, soft daylight.',
resolution: '1K',
size: '1:1',
web_grounding: false,
}),
});
const task = await response.json();
if (!response.ok) throw new Error(JSON.stringify(task.error));
console.log(task.id);package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"time"
)
func main() {
body, err := json.Marshal(map[string]any{
"model": "mai-image-2.6",
"prompt": "A studio photograph of an ivory ceramic teapot, soft daylight.",
"resolution": "1K", "size": "1:1", "web_grounding": false,
})
if err != nil { panic(err) }
req, err := http.NewRequest("POST", "https://reapi.ai/api/v1/images/generations", bytes.NewReader(body))
if err != nil { panic(err) }
req.Header.Set("Authorization", "Bearer " + os.Getenv("REAPI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := (&http.Client{Timeout: 120 * time.Second}).Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
result, err := io.ReadAll(resp.Body)
if err != nil { panic(err) }
if resp.StatusCode >= 400 { panic(string(result)) }
fmt.Println(string(result))
}Endpoint
POST https://reapi.ai/api/v1/images/generations
Send Authorization: Bearer YOUR_API_KEY and Content-Type: application/json.
Parameters
| Field | Type | Required | Default | Accepted values |
|---|---|---|---|---|
model | string | Yes | — | mai-image-2.6 |
prompt | string | Yes | — | Non-empty generation or edit instruction; approximately 32,000 tokens of context |
size | string | No | 1:1 | auto, integer ratio between 1:4 and 4:1, or pixel dimensions such as 1536x1024 |
resolution | string | No | 1K | 1K or 2K, case-insensitive; no 4K |
width | integer | No | — | Supply with height; each side at least 768, total pixels at most 2,359,296 |
height | integer | No | — | Supply with width; same limits |
image_urls | string[] | No | None | Up to five public HTTP(S) image URLs, in order |
auto_aspect_ratio | boolean | No | false | Infer the frame from the prompt, equivalent to size: "auto" |
web_grounding | boolean | No | false | Allow web context during generation |
n | integer | No | 1 | Only 1 |
Prompt length is a token limit, not a character count. The gateway does not pretend to reproduce the model tokenizer with a character cap. Keep long instructions within the documented context limit.
Pixel size accepts x, *, or ×, for example 1536x1024. Fractional ratios
such as 1.5:1 are not supported; use integer equivalents such as 3:2.
No base64 or data URLs are accepted. Prefer JPEG or PNG reference images;
WEBP and GIF references are converted during processing.
Sizing and precedence
For text-to-image, explicit width and height take priority, followed
by pixel dimensions in size, then a ratio in size combined with resolution.
Automatic framing asks the model to choose a frame. Avoid mixing an automatic
choice with explicit dimensions when you need a predictable request.
Both dimensions must be at least 768 pixels, with width × height ≤ 2359296.
1536 × 1536, 2048 × 1152, and 3072 × 768 fit; 2048 × 2048 does not.
Dimensions that are not multiples of 32 are rounded down: a request for
1000 × 1000 yields a 992 × 992 size under the documented rule.
For reference editing, the model chooses output dimensions, generally
around one megapixel with a frame informed by the reference. size,
resolution, width, and height do not control the edit output. Inspect
actual output dimensions rather than assuming the requested canvas was used.
{
"model": "mai-image-2.6",
"prompt": "A matte ivory ceramic teapot on a pale blue table, soft daylight.",
"width": 1024,
"height": 1024,
"n": 1
}Reference editing
Provide one to five public image URLs and explain their roles in order. The prompt is still required. Repeated reference URLs are preserved.
{
"model": "mai-image-2.6",
"prompt": "Use the first image as the room and the second image as the chair. Replace the chair beside the window. Keep the window, floor, and camera view unchanged.",
"image_urls": ["https://example.com/room.jpg", "https://example.com/chair.jpg"],
"web_grounding": false
}Replace these illustrative URLs with accessible images you can use. Editing
instructions do not guarantee exact preservation of untouched pixels.
This endpoint does not expose mask_url, quality, style, background,
output_format, response_format, seed, or negative_prompt. Unknown
fields are rejected. The output format is PNG.
Polling and output
Submission returns the reAPI task id. Poll that same ID every three to five
seconds until status is completed or failed:
curl https://reapi.ai/api/v1/tasks/task_your_id \
-H "Authorization: Bearer $REAPI_API_KEY"Completed-task fields have this shape (values are descriptive placeholders, not a captured response):
{
id: string;
status: 'completed';
model: 'mai-image-2.6';
output: { image_urls: string[] };
usage: { credits: number };
}A completed task contains output.image_urls. usage.credits is the legacy
whole-credit value. For precise accounting, poll with ?include=billing and
read billing.credits_exact, billing.cost_usd, and the settlement's charged
and shortfall fields when present. Exact billing is opt-in; do not reconstruct
a fractional charge from the rounded usage.credits field.
curl 'https://reapi.ai/api/v1/tasks/task_your_id?include=billing' \
-H "Authorization: Bearer $REAPI_API_KEY"A failed task contains error.code and error.message. Allow several minutes
for generation. A client timeout alone does not mean the task failed; query
the original task before deciding whether to submit again. Polling does not
create an additional image charge.
Pricing and settlement
The initial quote is an estimate. It reserves credits for text input, reference inputs, and expected output pixels. On successful completion, the charge is reconciled using the actual generation cost. Any unused reservation is released; a higher final cost can require an additional debit. If actual cost is unavailable, the reservation is retained and the billing exception is recorded for reconciliation. Failed generations are refunded.
The calculation uses these billing dimensions:
estimated cost = estimated text input + estimated reference input + estimated output
final charge = actual metered generation charge, rounded once to micro-USD precision
unused reservation = max(reserved charge - final charge, 0)Output image tokens follow actual width × actual height / 1024; input image
and text usage also contribute. Reference edits and automatic framing make
final output dimensions uncertain. Wide ratios can produce more pixels than
a square at the same nominal tier, so a 1K label is not a fixed per-image rate.
See the current pricing estimates, and read the MAI Image 2.6 API guide for request design and polling examples. This page intentionally does not freeze SKU prices.
Errors and troubleshooting
Errors use { error: { code, message, request_id } }.
See the shared error catalog.
| Code | Meaning |
|---|---|
10001–10004 | Missing, invalid, or revoked API key |
20002 | Required field missing |
20003 | Invalid value, range, type, or unsupported field |
20004 | Unsupported model for this endpoint |
30001 | Insufficient credits |
80001 | Submission failure |
80002 | Task polling deadline reached |
80003 | Terminal generation failure |
80004 | Completed response has no image URL |
- A size error: check both sides, the total area, and integer-ratio syntax.
- An unexpected edit size: references activate model-selected output sizing.
- An unreadable reference: check that its URL returns image bytes without login.
- A slow task: poll the existing ID before starting another billable task.
- A different final charge: compare the estimate with actual dimensions and reference inputs; the quote is neither a fixed rate nor a maximum charge.