MAI-Image-2.7 Image Generation
Asynchronous processing mode, returns task ID for subsequent queries
Вся документация/v1/images/generations- Supports text-to-image, single-image editing, and multi-image composition, with up to 5 reference images
- Available as the high-quality
mai-image-2.7and the fastmai-image-2.7-flash, with identical capabilities and parameters - Control output size with
size(aspect ratio) +resolution(1K/2K), or specify exact pixels - Up to 2048×2048 per image (about 4.19 megapixels), 1 image per request
Примеры запросов
curl --request POST \
--url https://api.apisea.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "mai-image-2.7",
"prompt": "A university campus poster at dusk, photorealistic style, cinematic lighting",
"size": "16:9",
"resolution": "2K"
}'Authorizations
AuthorizationstringrequiredAll endpoints require Bearer Token authentication
Get your API Key:
Visit the API Key management page to get your API Key
Include it in the request header:
Authorization: Bearer YOUR_API_KEYBody
modelstringrequireddefault: mai-image-2.7Image generation model name
| Model | Description |
|---|---|
mai-image-2.7 | High-quality version, best for use cases where image quality matters most |
mai-image-2.7-flash | Fast version with slightly lower image quality, faster speed, and lower cost |
Both models have exactly the same capabilities and parameters.
nsfw_checkbooleandefault: falseWhether 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)
promptstringrequiredText description or editing instructions for the image
- Supports Chinese and English; detailed descriptions are recommended
- Up to 20,000 characters; longer prompts return 400
- Cannot be empty or whitespace only
nintegerdefault: 1Number of images to generate
Value: 1
Warning
Only 1 image can be generated per request; submit separate tasks for multiple images. Passing
0, a negative number, or a value greater than 1 returns 400
sizestringdefault: 1:1Image aspect ratio or pixel dimensions, applies to text-to-image only
Two formats are supported:
- Aspect ratio: any integer ratio from
1:4to4:1, such as1:1,16:9,9:16, or21:9; combined withresolutionto determine the actual pixels - Pixel dimensions:
widthxheight(also acceptswidth*heightandwidth×height), such as2048x1152;resolutionis ignored in this case
Pixel dimension constraints:
- Width and height must both be ≥ 768
- Width × height must be ≤ 4,194,304 (2048×2048)
- Width and height are each rounded down to a multiple of 32; for example,
1000x1000outputs992x992
Examples: ✅ 2048x2048, 2048x1152, 2560x1536; ❌ 512x512 (side shorter than 768), 2080x2048 (exceeds the total pixel limit)
Warning
autois not supported and returns 400
resolutionstringdefault: 1KOutput resolution tier, applies only when size is an aspect ratio
Options: 1K / 2K (lowercase also accepted)
size × resolution → actual pixel mapping:
| size | 1K | 2K |
|---|---|---|
1:1 | 1024×1024 | 2048×2048 |
4:3 | 1152×864 | 2336×1760 |
3:4 | 864×1152 | 1760×2336 |
3:2 | 1248×832 | 2496×1664 |
2:3 | 832×1248 | 1664×2496 |
16:9 | 1344×768 | 2720×1536 |
9:16 | 768×1344 | 1536×2720 |
2:1 | 1536×768 | 2880×1440 |
1:2 | 768×1536 | 1440×2880 |
21:9 | 1792×768 | 3104×1312 |
9:21 | 768×1792 | 1312×3104 |
4:1 | 3072×768 | 4096×1024 |
1:4 | 768×3072 | 1024×4096 |
Warning
4Kis not supported; any other tier returns 400. Because the shorter side must be at least 768, aspect ratios more extreme than 2:1 (or 1:2) produce more than about 1 million pixels at the1Ktier.
widthintegerExact pixel width, must be provided together with height
- Highest priority; when provided, overrides
sizeandresolution - Same constraints as
sizepixel dimensions: width and height both ≥ 768, total pixels ≤ 4,194,304 - Applies to text-to-image only
heightintegerExact pixel height, must be provided together with width; same constraints as width
image_urlsarrayArray of reference images; when provided, the request runs in image-to-image mode
- Provide 1 image for single-image editing, or multiple images for multi-image composition
Details
- Up to 5 reference images
- Supports
image URL(a publicly accessible direct link; an inaccessible URL causes the task to fail) - Supports
base64 data URI(such asdata:image/png;base64,...) - Supports JPEG and PNG; WEBP and GIF are automatically converted to PNG
- Output dimensions are determined by the model from the reference images;
size/resolution/width/heighthave no effect on image-to-image
backgroundstringBackground type
Options: auto / opaque, same effect as omitting the parameter
Warning
Transparent background
transparentis not yet available; passingtransparentor any other value returns 400
Note
auto_aspect_ratio: trueandweb_grounding: trueare not supported and return 400.quality,style,output_format,response_format, andmask_urlare not supported and are ignored. Output is always PNG.
Usage Examples
Text-to-image (minimal request)
Defaults to 1:1 + 1K, outputting 1024×1024.
{
"model": "mai-image-2.7",
"prompt": "A university campus poster at dusk, photorealistic style, cinematic lighting"
}Text-to-image (aspect ratio + 2K)
{
"model": "mai-image-2.7",
"prompt": "A university campus poster at dusk, photorealistic style, cinematic lighting",
"size": "3:2",
"resolution": "2K"
}Text-to-image (exact pixels)
{
"model": "mai-image-2.7-flash",
"prompt": "A glass perfume bottle on a white marble countertop, clean product photography",
"width": 2048,
"height": 2048
}Single-image editing
{
"model": "mai-image-2.7",
"prompt": "Make the bicycle blue and add a small dog next to it",
"image_urls": [
"https://example.com/bicycle.png"
]
}Multi-image composition (mixed URL + base64)
{
"model": "mai-image-2.7-flash",
"prompt": "Combine both reference images into a clean futuristic product photo",
"image_urls": [
"https://example.com/first.png",
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."
]
}Response
codeintegerResponse status code
dataarrayResponse data array
Properties
statusstringTask status
submitted- Submitted
task_idstringUnique task identifier, used for subsequent result queries
Querying Task Results
After successful submission, a task_id is returned. Poll the task status via GET /v1/tasks/{task_id}, see Task Query API for details. We recommend polling every 3–5 seconds with an overall timeout of 3 minutes.
Success Response Example
{
"code": 200,
"data": {
"id": "task_01K...",
"status": "completed",
"progress": 100,
"result": {
"images": [
{
"url": [
"https://cdn.example.com/f/image/xxxxxxxx.png"
],
"expires_at": 1791539365
}
]
}
}
}To get the image: data.result.images[0].url[0]. Image links expire after expires_at, so download and save them promptly.
Task Status
| Status | Meaning |
|---|---|
pending | Queued, continue polling |
processing | Generating, continue polling |
completed | Success, result.images available |
failed | Failed, check error.message |
Ответы
{
"code": 200,
"data": [
{
"status": "submitted",
"task_id": "task_01K..."
}
]
}Модели, использующие эту конечную точку
Нашли ошибку в документации? Напишите на support@apisea.ai.