Skip to content
Halaman ini belum tersedia dalam bahasa anda, jadi kandungannya dipaparkan dalam bahasa Inggeris.

MAI-Image-2.7 Image Generation

Asynchronous processing mode, returns task ID for subsequent queries

Semua dokumentasi
POST/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.7 and the fast mai-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

Contoh permintaan

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

Authorizationstringrequired

All 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:

text
Authorization: Bearer YOUR_API_KEY

Body

modelstringrequireddefault: mai-image-2.7

Image generation model name

ModelDescription
mai-image-2.7High-quality version, best for use cases where image quality matters most
mai-image-2.7-flashFast version with slightly lower image quality, faster speed, and lower cost

Both models have exactly the same capabilities and parameters.

nsfw_checkbooleandefault: false

Whether to run content moderation before submitting the image task.

  • true: use omni-moderation-latest to review prompts and input images
  • false or omitted: do not send a moderation request, adding no moderation cost or latency (default)
promptstringrequired

Text 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: 1

Number 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:1

Image aspect ratio or pixel dimensions, applies to text-to-image only

Two formats are supported:

  • Aspect ratio: any integer ratio from 1:4 to 4:1, such as 1:1, 16:9, 9:16, or 21:9; combined with resolution to determine the actual pixels
  • Pixel dimensions: widthxheight (also accepts width*height and width×height), such as 2048x1152; resolution is 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, 1000x1000 outputs 992x992

Examples: ✅ 2048x2048, 2048x1152, 2560x1536; ❌ 512x512 (side shorter than 768), 2080x2048 (exceeds the total pixel limit)

Warning

auto is not supported and returns 400

resolutionstringdefault: 1K

Output resolution tier, applies only when size is an aspect ratio

Options: 1K / 2K (lowercase also accepted)

size × resolution → actual pixel mapping:

size1K2K
1:11024×10242048×2048
4:31152×8642336×1760
3:4864×11521760×2336
3:21248×8322496×1664
2:3832×12481664×2496
16:91344×7682720×1536
9:16768×13441536×2720
2:11536×7682880×1440
1:2768×15361440×2880
21:91792×7683104×1312
9:21768×17921312×3104
4:13072×7684096×1024
1:4768×30721024×4096

Warning

4K is 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 the 1K tier.

widthinteger

Exact pixel width, must be provided together with height

  • Highest priority; when provided, overrides size and resolution
  • Same constraints as size pixel dimensions: width and height both ≥ 768, total pixels ≤ 4,194,304
  • Applies to text-to-image only
heightinteger

Exact pixel height, must be provided together with width; same constraints as width

image_urlsarray

Array 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 as data: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 / height have no effect on image-to-image
backgroundstring

Background type

Options: auto / opaque, same effect as omitting the parameter

Warning

Transparent background transparent is not yet available; passing transparent or any other value returns 400

Note

auto_aspect_ratio: true and web_grounding: true are not supported and return 400. quality, style, output_format, response_format, and mask_url are not supported and are ignored. Output is always PNG.

Usage Examples

Text-to-image (minimal request)

Defaults to 1:1 + 1K, outputting 1024×1024.

json
{
  "model": "mai-image-2.7",
  "prompt": "A university campus poster at dusk, photorealistic style, cinematic lighting"
}

Text-to-image (aspect ratio + 2K)

json
{
  "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)

json
{
  "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

json
{
  "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)

json
{
  "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

codeinteger

Response status code

dataarray

Response data array

Properties

statusstring

Task status

  • submitted - Submitted
task_idstring

Unique 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

json
{
  "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

StatusMeaning
pendingQueued, continue polling
processingGenerating, continue polling
completedSuccess, result.images available
failedFailed, check error.message

Respons

{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01K..."
    }
  ]
}

Menemui masalah dalam dokumentasi ini? E-mel support@apisea.ai.