MuseSpark
MuseSpark
Models & toolsTools

Image Eraser API guide

Image Eraser API: Remove selected objects or regions from an image and reconstruct the surrounding background. Guide the edit with a mask, a removal prompt, or both.

Model overview

Remove selected objects or regions from an image and reconstruct the surrounding background. Guide the edit with a mask, a removal prompt, or both.

API integration

DocumentationValue
API invocation identifierimage-eraser
IntegrationAsync task API

Use this invocation identifier in API requests. Check your authorized model catalog for access. Follow the Quickstart for your first complete call.

Request parameters

Studio presets describe the form setup, not guaranteed server defaults. Send preset values explicitly to reproduce them.

imagestringNon-nullRequired

The image containing the area you want to erase.

Media types: image/*.

mask_imagestringNon-nullOptional

The mask image to indicate the area to be erased. The area to be erased should be in white color and the area to be kept should be in black color.

Media types: image/*.

promptstringNon-nullOptional

The text prompt for specifying the objects or areas to be removed from the image. For example, 'dog' or 'hat'.

batch_sizeintegerNon-nullOptional

Standard quantity control field. The allowed range for this item is 1-15.

Repeats MuseSpark execution within one logical task. This is separate from a model-native output count.

Value: minimum 1; maximum 15.

Studio preset: 1.

No parameters match. Clear the search or reset the filters.

Model rules

Reference media

  • Choose a region with enough visible surrounding context to guide the replacement background.

Model behavior

  • The tool reconstructs the background in the area being removed.
  • In mask_image, use white for the region to erase and black for the region to keep. prompt should name what to remove, such as a chair or a bag. Both controls are optional in the public contract.

batch_size controls repeated MuseSpark executions. Output grouping, sequential image generation, and video shot count are separate concepts.

Request examples

Replace example media URLs and YOUR_... input identifiers with your own valid resources. Examples are checked against the exported item schema; media access and paid execution are separate runtime checks.

Set MUSESPARK_API_KEY and a stable MUSESPARK_REQUEST_ID before submitting. Preserve the request ID for retries of the same request and use a new ID for new work. Python examples use requests; JavaScript examples use Node.js 20 or later. The standalone Quickstart includes task polling and recovery.

Remove an object with a mask

curl --fail-with-body 'https://api.musespark.ai/api/v1/openapi/task' \
  -H "Authorization: Bearer $MUSESPARK_API_KEY" \
  -H "X-Idempotency-Key: $MUSESPARK_REQUEST_ID" \
  -H 'Content-Type: application/json' \
  -d '{
  "item_key": "image-eraser",
  "parameters": {
    "batch_size": 1,
    "image": "https://example.com/room-with-chair.jpg",
    "prompt": "Remove the chair.",
    "mask_image": "https://example.com/white-chair-black-background-mask.png"
  }
}'

Parameters used: batch_size · image · prompt · mask_image.

Output

The output is an edited image with the selected object or region replaced by reconstructed background.

Creation returns a task ID inside data. Poll that task until completion, then save data.result.output_urls and any data.result.batch_results. See the task lifecycle for terminal states, result retention, and errors.

Troubleshooting

The wrong region is removed. Check mask polarity: white marks the area to erase and black marks the area to retain.

mask_image

The edit adds unrelated scene content. Use a concise removal instruction that identifies the unwanted object.

prompt

For rejected inputs, check the field type, accepted values, and conditional requirements in Request parameters and Model rules. Correct the affected fields before submitting again.

If creation times out, preserve the request identity and any known task ID. Follow Errors, timeouts and retries before submitting again.

The public input snapshot was exported on 2026-11-09. Current prices and availability are listed in the model center.