
alibaba/ z-image-turbo-inpaint/ image-to-image
Image to ImageAlibaba's Z-Image Turbo Inpaint repaints only the masked region of a photo from a prompt and leaves the rest intact. Handy for swapping objects, fixing flaws or changing outfits and backdrops, with adjustable inpaint strength, control scale and timing, output size and repeatable seeds.
More settings (10)
Fill in the required parameters marked * and check number formats.
$0.01 / megapixel · billed by each image's actual pixels

A young Asian woman with long, vibrant purple hair stands on a sunlit sandy beach, posing confidently with her left hand resting on her hip. She gazes directly at the camera with a neutral expression. A sleek black ribbon bow is tied neatly on the right side of her head, just above her ear. She wears a flowing white cotton dress with a fitted bodice and a flared skirt that reaches mid-calf, slightly lifted by a gentle sea breeze. The beach behind her features fine, pale golden sand with subtle footprints, leading to calm turquoise waves under a clear blue sky with soft, wispy clouds. The lighting is natural daylight, casting soft shadows to her left, indicating late afternoon sun. The horizon line is visible in the background, with a faint silhouette of distant dunes. Her skin tone is fair with a natural glow, and her facial features are delicately defined. The composition is centered on her figure, framed from mid-thigh up, with shallow depth of field blurring the distant waves slightly.
Pricing
Unit price $0.01 / megapixel
Billed by the actual pixels of each image; larger sizes and more images cost more. 1024×1024 is about 1 megapixel.
Each request temporarily reserves $0.02; you are charged for actual usage, usually within a minute: any unused amount is released and any usage above it is charged to your balance, even if that takes it below zero; while your balance is below zero, new requests are paused until a top-up covers it.
Failed generations are not charged.
API
Submit generation requests with this model ID.
/v1/model-tasksalibaba/z-image-turbo-inpaint/image-to-image{
"model": "alibaba/z-image-turbo-inpaint/image-to-image",
"input": {
"prompt": "A young Asian woman with long, vibrant purple hair stands on a sunlit sandy beach, posing confidently with her left hand resting on her hip. She gazes directly at the camera with a neutral expression. A sleek black ribbon bow is tied neatly on the right side of her head, just above her ear. She wears a flowing white cotton dress with a fitted bodice and a flared skirt that reaches mid-calf, slightly lifted by a gentle sea breeze. The beach behind her features fine, pale golden sand with subtle footprints, leading to calm turquoise waves under a clear blue sky with soft, wispy clouds. The lighting is natural daylight, casting soft shadows to her left, indicating late afternoon sun. The horizon line is visible in the background, with a faint silhouette of distant dunes. Her skin tone is fair with a natural glow, and her facial features are delicately defined. The composition is centered on her figure, framed from mid-thigh up, with shallow depth of field blurring the distant waves slightly.",
"image_url": "<image_url>",
"mask_image_url": "<mask_image_url>"
}
}Input schema
| Parameter | Type | Requirement | Default |
|---|---|---|---|
| image_url | string | Required | — |
| mask_image_url | string | Required | — |
| prompt | string | Required | — |
| acceleration | string | Optional | regular |
| control_end | number | Optional | 0.8 |
| control_scale | number | Optional | 0.75 |
| control_start | number | Optional | 0 |
| enable_prompt_expansion | boolean | Optional | false |
| image_size | object | string | Optional | auto |
| num_images | integer | Optional | 1 |
| num_inference_steps | integer | Optional | 8 |
| output_format | string | Optional | png |
| seed | integer | Optional | — |
| strength | number | Optional | 1 |
Response
The API returns a result or a pollable asynchronous task. See the examples and Schema below for the response mode and result fields.
Code examples
Async submission returns a task ID. Poll until status is completed, then retrieve the generated content from the result. Get your API key in the console.
# Use a new directory for each new generation. Rerunning here continues this task.
set -eu
test -s model-task-id.txt || python3 -c "import uuid; print(uuid.uuid4())" > model-task-id.txt
REQUEST_ID=$(cat model-task-id.txt)
# Idempotent: resending the same bytes with the same ID never charges twice.
curl --fail-with-body --retry 3 --retry-connrefused --request POST 'https://api.musespan.com/v1/model-tasks' \
--header "Authorization: Bearer $MUSESPAN_API_KEY" \
--header "X-Request-Id: $REQUEST_ID" \
--header "Content-Type: application/json" \
--data '{"model":"alibaba/z-image-turbo-inpaint/image-to-image","input":{"prompt":"A young Asian woman with long, vibrant purple hair stands on a sunlit sandy beach, posing confidently with her left hand resting on her hip. She gazes directly at the camera with a neutral expression. A sleek black ribbon bow is tied neatly on the right side of her head, just above her ear. She wears a flowing white cotton dress with a fitted bodice and a flared skirt that reaches mid-calf, slightly lifted by a gentle sea breeze. The beach behind her features fine, pale golden sand with subtle footprints, leading to calm turquoise waves under a clear blue sky with soft, wispy clouds. The lighting is natural daylight, casting soft shadows to her left, indicating late afternoon sun. The horizon line is visible in the background, with a faint silhouette of distant dunes. Her skin tone is fair with a natural glow, and her facial features are delicately defined. The composition is centered on her figure, framed from mid-thigh up, with shallow depth of field blurring the distant waves slightly.","image_url":"<image_url>","mask_image_url":"<mask_image_url>"}}'
# Poll every 5 seconds for up to 25 minutes until status is completed or failed.
# Still queued (with queue_position) 5 minutes after submission: failed with queue_timeout, not charged.
# No result 15 minutes after acceptance (or no confirmation 15 minutes after submission): failed with generation_timeout, not charged.
# Any failure is final: generate again in a new directory (a new X-Request-Id).
# A 404 means the POST did not arrive: rerun this script to resend it with the same ID.
curl --fail-with-body 'https://api.musespan.com/v1/model-tasks/'"$REQUEST_ID"'' --header "Authorization: Bearer $MUSESPAN_API_KEY"