MAI Image 2.7 Edit API
Edit and combine up to five images, keeping fine details.
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) 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
https://api.segmind.com/v1/mai-image-2.7-editParameters
promptrequiredstringWhat to change and what must stay the same, up to 32,000 characters.
"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_imagesrequiredstring[]1 to 5 images to edit or combine, as URLs or base64.
["https://segmind-resources.s3.amazonaws.com/input/minimax-h3-image-edit-elephant-683ded41.jpg"]aspect_ratiooptionalstringOutput 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.
"auto""auto""1:1""3:4""4:3""2:3""3:2""9:16""16:9"backgroundoptionalstringtransparent needs png or webp output and can leave traces of green around the subject.
"opaque""opaque""transparent"modeoptionalstringstandard for the best quality; flash for lower cost.
"standard""standard""flash"output_formatoptionalstringImage file format.
"png""png""jpeg""webp"resolutionoptionalstring1K is about 1 megapixel; 2K doubles each side. Applies when the aspect ratio is not auto.
"1K""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
POST /v2/mai-image-2.7-editSubmit — returns request_id, status_url, response_url
- 2
GET /v2/requests/{id}/statusPoll — until COMPLETED or FAILED
- 3
GET /v2/requests/{id}Result — final response body
Status states
- 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.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out