MAI Image 2.7 Edit API

Edit and combine up to five images, keeping fine details.

PlaygroundAPI
Pricing
~24.88s
POST /v2/mai-image-2.7-edit · submit + poll
 1# pip install "segmind>=1.1.0"
 2# export SEGMIND_API_KEY="YOUR_API_KEY"
 3import segmind
 4
 5# Async (v2): submit to the queue and block until COMPLETED.
 6# run() returns the final result dict (600s deadline, 1.0s poll by default).
 7result = segmind.run(
 8    "mai-image-2.7-edit",
 9    reference_images=["https://segmind-resources.s3.amazonaws.com/input/mai-image-2.7-edit-kiosk-8a7923f8.jpg", "https://segmind-resources.s3.amazonaws.com/input/mai-image-2.7-edit-keysign-8dd4012e.jpg"],
10    prompt="Swap the red enamel HEELS & KEYS sign above the kiosk hatch in image 1 for the carved wooden key sign from image 2, hung from its wrought-iron scroll bracket on the brick wall in the same spot. Keep the key's faded teal paint, chipped bare-wood edges and black carved KEYS letters exactly as in image 2. Change nothing else in image 1: the cobbler, the woman in the yellow raincoat, the brass key between their hands, the gold SHOE REPAIR · KEYS CUT lettering, the CLOSED SUNDAYS card and the shelves of boots and keys stay as they are.",
11    mode="standard",
12    aspect_ratio="auto",
13    resolution="1K",
14    background="opaque",
15    output_format="png",
16)
17print(result["status"])                      # COMPLETED
18print(result.get("output"))                  # model output (e.g. media URL)
19print(result["metrics"]["inference_time"])   # server compute seconds
20
21# --- Or submit + poll manually (track request_id, control the cadence) ---
22from segmind import SegmindClient, InferenceFailed, InferenceTimeout
23
24client = SegmindClient()                      # reads SEGMIND_API_KEY
25payload = {
26    "reference_images": ["https://segmind-resources.s3.amazonaws.com/input/mai-image-2.7-edit-kiosk-8a7923f8.jpg", "https://segmind-resources.s3.amazonaws.com/input/mai-image-2.7-edit-keysign-8dd4012e.jpg"],
27    "prompt": "Swap the red enamel HEELS & KEYS sign above the kiosk hatch in image 1 for the carved wooden key sign from image 2, hung from its wrought-iron scroll bracket on the brick wall in the same spot. Keep the key's faded teal paint, chipped bare-wood edges and black carved KEYS letters exactly as in image 2. Change nothing else in image 1: the cobbler, the woman in the yellow raincoat, the brass key between their hands, the gold SHOE REPAIR · KEYS CUT lettering, the CLOSED SUNDAYS card and the shelves of boots and keys stay as they are.",
28    "mode": "standard",
29    "aspect_ratio": "auto",
30    "resolution": "1K",
31    "background": "opaque",
32    "output_format": "png",
33}
34job = client.submit_async("mai-image-2.7-edit", **payload)
35print(job.request_id)                         # available immediately
36try:
37    result = job.wait(timeout=600, interval=1.0)
38except InferenceTimeout as e:
39    print("still running:", e.request_id)
40except InferenceFailed as e:
41    print("failed:", e.detail)

API Endpoint

POSThttps://api.segmind.com/v1/mai-image-2.7-edit

Parameters

promptrequired
string

What to change and what must stay the same, up to 32,000 characters.

Default: "Place the knitted elephant on a wooden shelf beside a small potted fern, soft daylight from the left. Keep its stitches, red felt heart and black bead eyes exactly as they are."
reference_imagesrequired
string[]

1 to 5 images to edit or combine, as URLs or base64.

Default: ["https://segmind-resources.s3.amazonaws.com/input/minimax-h3-image-edit-elephant-683ded41.jpg"]
aspect_ratiooptional
string

Output shape; auto follows the input image's size, up to 2048x2048, and a larger output costs more. Set a ratio to choose the resolution yourself.

Default: "auto"
Allowed values :
"auto""1:1""3:4""4:3""2:3""3:2""9:16""16:9"
backgroundoptional
string

transparent needs png or webp output and can leave traces of green around the subject.

Default: "opaque"
Allowed values :
"opaque""transparent"
modeoptional
string

standard for the best quality; flash for lower cost.

Default: "standard"
Allowed values :
"standard""flash"
output_formatoptional
string

Image file format.

Default: "png"
Allowed values :
"png""jpeg""webp"
resolutionoptional
string

1K is about 1 megapixel; 2K doubles each side. Applies when the aspect ratio is not auto.

Default: "1K"
Allowed values :
"1K""2K"

Response Type

Returns: Image

Asynchronous requests (v2)

Use Async for video, long-running (>~60s), or high-concurrency workloads; Sync is simplest for fast image & LLM calls. Async submits a request and you poll it to completion.

  1. 1
    POST /v2/mai-image-2.7-edit

    Submit — returns request_id, status_url, response_url

  2. 2
    GET /v2/requests/{id}/status

    Poll — until COMPLETED or FAILED

  3. 3
    GET /v2/requests/{id}

    Result — final response body

Status states

QUEUED— Accepted, waiting for a worker
PROCESSING— Running on a worker
COMPLETED— Done — result body is ready
FAILED— Errored (incl. content/RAI blocks)
  • A FAILED request is served as HTTP 422 — the body still carries the error detail.
  • An unknown or expired request_id returns HTTP 404.
  • Results are retained for 1 hour, then expire.
  • Content / RAI blocks surface as FAILED, not a separate state.
  • Track completion by polling the status endpoint.

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out