curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "mai-image-2.6",
"prompt": "A photorealistic poster of a university campus at sunset, cinematic lighting",
"size": "16:9",
"resolution": "2K"
}'
import requests
response = requests.post(
"https://api.apimart.ai/v1/images/generations",
headers={"Authorization": "Bearer <token>"},
json={
"model": "mai-image-2.6",
"prompt": "A photorealistic poster of a university campus at sunset, cinematic lighting",
"size": "16:9",
"resolution": "2K"
}
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.apimart.ai/v1/images/generations", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "mai-image-2.6",
prompt: "A photorealistic poster of a university campus at sunset, cinematic lighting",
size: "16:9",
resolution: "2K"
})
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K..."
}
]
}
MAI-Image-2.6
MAI-Image-2.6 Image Generation
Text-to-image, single-image editing, composition with up to 5 reference images, and web grounding. Available in high-quality and Flash versions.
POST
/
v1
/
images
/
generations
curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "mai-image-2.6",
"prompt": "A photorealistic poster of a university campus at sunset, cinematic lighting",
"size": "16:9",
"resolution": "2K"
}'
import requests
response = requests.post(
"https://api.apimart.ai/v1/images/generations",
headers={"Authorization": "Bearer <token>"},
json={
"model": "mai-image-2.6",
"prompt": "A photorealistic poster of a university campus at sunset, cinematic lighting",
"size": "16:9",
"resolution": "2K"
}
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.apimart.ai/v1/images/generations", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "mai-image-2.6",
prompt: "A photorealistic poster of a university campus at sunset, cinematic lighting",
size: "16:9",
resolution: "2K"
})
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K..."
}
]
}
Model selection
| Model ID | Features |
|---|---|
mai-image-2.6 | High-quality version for quality-focused use cases |
mai-image-2.6-flash | Faster, lower-cost version with slightly lower image quality |
This endpoint is asynchronous. Retrieve the task ID from
data[0].task_id after submission, then use task queries for results. Poll every 3–5 seconds with an overall wait timeout of 3 minutes. Stop when the status is completed or failed.curl --request POST \
--url https://api.apimart.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "mai-image-2.6",
"prompt": "A photorealistic poster of a university campus at sunset, cinematic lighting",
"size": "16:9",
"resolution": "2K"
}'
import requests
response = requests.post(
"https://api.apimart.ai/v1/images/generations",
headers={"Authorization": "Bearer <token>"},
json={
"model": "mai-image-2.6",
"prompt": "A photorealistic poster of a university campus at sunset, cinematic lighting",
"size": "16:9",
"resolution": "2K"
}
)
response.raise_for_status()
print(response.json())
const response = await fetch("https://api.apimart.ai/v1/images/generations", {
method: "POST",
headers: {
Authorization: "Bearer <token>",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "mai-image-2.6",
prompt: "A photorealistic poster of a university campus at sunset, cinematic lighting",
size: "16:9",
resolution: "2K"
})
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K..."
}
]
}
Request headers
Bearer authentication in the format
Bearer <token>, where <token> is your APIMart API Key.Request parameters
Whether to run content moderation before submitting the image task.
true: useomni-moderation-latestto review prompts and input imagesfalseor omitted: do not send a moderation request, adding no moderation cost or latency (default)
Image description or editing instructions. Supports Chinese and English, up to approximately 32,000 tokens (not characters).
Accepts an aspect ratio (such as
16:9), pixel dimensions (such as 1536x1024), or auto.- Aspect ratio: any integer ratio from
1:4to4:1, used together withresolution. - Pixel dimensions: accepts
widthxheight,width*height, orwidth×height. In this mode,resolutiondoes not determine dimensions. auto: the model selects an aspect ratio based on the prompt.
Supports
1K and 2K, including lowercase. Other tiers such as 4K are unsupported and return HTTP 400.For text-to-image with an aspect ratio, this parameter selects the size tier. It does not determine dimensions when exact pixels are used. It cannot set image-to-image output dimensions.Exact pixel width. Must be provided together with
height. This pair takes precedence over size and resolution for text-to-image dimensions.Both width and height must be at least 768, with no more than 2,359,296 total pixels. Use multiples of 32; otherwise each output dimension is rounded down to a multiple of 32.This parameter does not determine image-to-image output dimensions.Exact pixel height. Must be provided together with
width and follows the constraints above. Does not determine image-to-image output dimensions.Reference image list, up to 5 images. Omit for text-to-image; provide one for single-image editing or multiple for composition.Each entry supports a publicly accessible HTTP(S) image URL or a Base64 Data URL such as
data:image/png;base64,....JPEG and PNG are supported; WEBP and GIF are automatically converted to PNG. Image URLs must be publicly accessible or the task will fail.Image-to-image output dimensions are determined by the model from the references, at about 1 million pixels with a similar aspect ratio. size, resolution, width, and height cannot set these dimensions.Set to
true to let the model choose an aspect ratio based on the prompt, equivalent to size: "auto".Set to
true to retrieve real-time information before generation, useful for images involving real people, places, or events.Only
1 is supported. Submit separate tasks for multiple images. Values above 1 return HTTP 400.Text-to-image dimensions
| Requirement | Parameters |
|---|---|
| Default square | Omit size parameters: 1:1 + 1K, producing 1024×1024 |
| Resolution tier + aspect ratio | size: "16:9", resolution: "2K" |
| Exact pixels | size: "1536x1024", or width: 1536, height: 1024 |
| Automatic aspect ratio | size: "auto" or auto_aspect_ratio: true |
width / height → exact-pixel size → aspect-ratio size combined with resolution.
Resolution tiers and aspect ratios
| Aspect ratio | 1K | 2K |
|---|---|---|
| 1:1 | 1024×1024 | 1536×1536 |
| 4:3 / 3:4 | 1152×864 / 864×1152 | 1760×1312 / 1312×1760 |
| 3:2 / 2:3 | 1248×832 / 832×1248 | 1856×1248 / 1248×1856 |
| 16:9 / 9:16 | 1344×768 / 768×1344 | 2048×1152 / 1152×2048 |
| 2:1 / 1:2 | 1536×768 / 768×1536 | 2144×1056 / 1056×2144 |
| 21:9 / 9:21 | 1792×768 / 768×1792 | 2336×992 / 992×2336 |
| 4:1 / 1:4 | 3072×768 / 768×3072 | 3072×768 / 768×3072 |
1K. Billing uses the token count corresponding to the actual output pixels.
Exact-pixel constraints
- Both width and height must be at least 768.
- Width × height must not exceed 2,359,296 (1536 × 1536).
- Each dimension is rounded down to a multiple of 32. For example,
1000x1000produces992x992. Use multiples of 32 for exact dimensions.
1536x1024, 2048x1152, and 3072x768 are supported. 512x512 is rejected because the sides are too small; 2048x2048 exceeds the total pixel limit.
The maximum applies to total pixels, not a 1536 limit on each side. Therefore,
2048x1152 and 3072x768 are valid, but the 4K tier is unsupported. These dimension settings apply only to text-to-image.Request examples
Exact pixels and web grounding
{
"model": "mai-image-2.6-flash",
"prompt": "The Eiffel Tower at night with fireworks, travel poster style",
"width": 2048,
"height": 1152,
"web_grounding": true
}
Single-image editing
{
"model": "mai-image-2.6",
"prompt": "Make the bicycle blue and add a small dog next to it",
"image_urls": ["https://example.com/bicycle.png"]
}
Multi-image composition
{
"model": "mai-image-2.6-flash",
"prompt": "Combine both reference images into a clean futuristic product photo",
"image_urls": [
"https://example.com/first.png",
"https://example.com/second.jpg"
]
}
Unsupported parameters
quality, style, background, output_format, response_format, and mask_url are unsupported and ignored if provided. Output is always PNG. Mask-based editing is not supported.
Submission response
Query task results
curl --request GET \
--url https://api.apimart.ai/v1/tasks/task_01K... \
--header 'Authorization: Bearer <token>'
{
"code": 200,
"data": {
"id": "task_01K...",
"status": "completed",
"progress": 100,
"result": {
"images": [
{
"url": ["https://example.com/generated-image.png"]
}
]
}
}
}
| Status | Action |
|---|---|
pending | Queued; continue polling |
processing | Processing; continue polling |
completed | Success; get image links from the data.result.images[0].url array |
failed | Failure; read data.error.message and stop polling. Full refund |
Billing
Billed by actual input and output token usage. Refer to model pricing for unit prices.- Image output tokens = actual output width × height ÷ 1024. For example, 1024×1024 corresponds to 1024 tokens; 1536×1536 to 2304 tokens.
- Input tokens per reference image are approximately its width × height ÷ 1024. Text prompts also count toward input usage.
- An amount based on the tier is charged upfront, then adjusted after success to actual token usage with a refund or additional charge.
- Failed tasks receive an automatic full refund. Parameter errors rejected at submission create no task and incur no charge.
Common errors
| HTTP | Cause and action |
|---|---|
| 400 | Unsupported resolution, such as 4K; use 1K or 2K |
| 400 | Width or height below 768, or total pixels above 2,359,296 |
| 400 | Only width or height provided; both are required together |
| 400 | Aspect ratio outside 1:4 to 4:1, or unrecognized size format |
| 400 | n above 1, or more than 5 reference images |