This document details the parameters for the image erase completion model. This model removes one or more elements from an image, such as people, pets, objects, text, or watermarks, while preserving the background. You can specify the areas to remove using a mask image.
Related guide: Image erase completion
-
This document applies only to the China (Beijing) region. To use the model, you must use an API key from the China (Beijing) region.
-
The image-erase-completion model is currently available only as a free trial. Once you exhaust your free quota, you can no longer call the model, as paid options are not supported. As alternatives, we recommend using Image editing - Qwen or Image editing - Wan2.1.
Prerequisites
Obtain an API key and export the API key as an environment variable.
HTTP call
To reduce wait times and prevent request timeouts, the service processes requests asynchronously. You need to make two requests:
-
Create a task: Send a request to create an image generation task. This request returns a task ID.
-
Query the result by task ID: Use the returned task ID to query the result.
Step 1: Create a task
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/image2image/image-synthesis
Request headers |
Image erase completion |
|
Content-Type string Required The content type of the request. The value must be |
|
|
Authorization string Required We recommend using your Model Studio API key. You can also use your DashScope API key. Example: Bearer d1xxx2a. |
|
|
X-DashScope-Async string Required Specifies whether to enable asynchronous processing. You must set this parameter to |
|
Request body |
|
|
model string Required The model to call. |
|
|
input object Required Input image details, such as the image URL. |
|
|
parameters object Optional Parameters for image processing. |
Response |
Successful response
Error response
|
|
output object Task output details. |
|
|
code string The error code. This parameter is not returned if the request is successful. |
|
|
message string The error message. This parameter is not returned if the request is successful. |
|
|
request_id string The unique request ID. Use this ID to trace and troubleshoot issues. |
Step 2: Query the result
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
Request headers |
Task result |
|
Authorization string Required Your API key. Example: Bearer d1**2a. |
|
Path parameters |
|
|
task_id string Required The task ID. |
Response |
Completed taskCompleted task results are available for 24 hours. After this period, the system deletes the task and its results. The generated image URL also expires after 24 hours, so you must save the image after retrieving the task result.
In-progress task
Failed task
|
|
output object Task output details. |
|
|
usage object Usage statistics. |
|
|
request_id string The unique request ID. Use this ID to trace and troubleshoot issues. |
Status codes
For common status codes for Model Studio services, see Error messages.
This API also returns the following specific status codes:
|
HTTP status code |
Error code |
Error message |
Description |
|
400 |
InvalidParameter.JsonPhrase |
input json error |
Invalid JSON in the request. |
|
400 |
InvalidParameter.FileDownload |
oss download error |
Failed to download the input image. |
|
400 |
InvalidParameter.ImageFormat |
read image error |
Failed to read the image. |
|
400 |
InvalidParameter.ImageContent |
The image content is not compliant. |
The image content is not compliant. |
|
400 |
InvalidParameter |
An input parameter value is out of range: xxx |
An input parameter value is out of range. |
|
400 |
InvalidParameter.ImageResolution |
The input image size is too small or too large. |
The input image size is too small or too large. |
|
500 |
InternalError.Algo |
algorithm process error |
Algorithm error. |
|
500 |
InternalError.FileUpload |
oss upload error |
Failed to upload the file. |