Product Retouching API

Try on PicWish

AI retouching improves material texture, line structure, and product details. Use an optional mask to specify the areas to retouch. It is suitable for ecommerce product images, accessories, bags, transparent objects, and metal objects, with async and sync request modes.

The result image URL is generally valid for 1 hour. Please download and store it promptly.

Authentication

Every API request must include your API Key in the X-API-KEY request header. Send it with each request exactly as shown in the examples and parameter descriptions.

X-API-KEY: YOUR_API_KEY

Create an object retouching task

POST /api/tasks/visual/retouching-collection

Body Parameters

image_url string optional

Image download URL. Optional, but one of image_file or image_url is required. Supports HTTP and OSS URLs, up to 512 characters, with a 10-second download timeout. If both image_file and image_url are provided, image_file takes priority.

one required
image_file file optional

Image file as binary data. Optional, but one of image_file or image_url is required. It takes priority over image_url.

  • Images must match the source size and resolution; see Guidelines and Limits #4.
  • For image upload requirements, see Guidelines and Limits #5.
mask_url string optional

Mask image download URL. You can provide either mask_url or mask_file, or omit both. Supports HTTP and OSS URLs, up to 512 characters, with a 10-second download timeout. If both mask_file and mask_url are provided, mask_file takes priority.

one optional
mask_file file optional

Mask image file. Both mask_file and mask_url are optional. If both are provided, mask_file takes priority.

  • Images must match the source size and resolution; see Guidelines and Limits #4.
  • Without a mask, the API retouches the entire image.
  • With a mask, the API retouches the areas where the mask’s grayscale value is greater than 0.
sync number optional

Whether to wait for the result and return it immediately.

  • 0: Return a task_id asynchronously, then fetch the result later with the task_id;
  • 1: Wait for and return the result synchronously.
retouch_strength number optional

Material strength, from 0 to 100. Default is 37. A higher value changes the material more. Only effective in the normal model.

line_strength number optional

Line strength, from 0 to 100. Default is 60. A higher value applies stronger line constraints. Only effective in the normal model.

Return Parameters

status number

HTTP response status code. See Status Code Definitions.

  • 200: The HTTP request succeeded, not necessarily that object retouching succeeded.
message string

API response message. Usually success for a successful request.

data.task_id string

Async object retouching task ID returned after the task is created. Use it to query the result later.

status number

HTTP response status code. See Status Code Definitions.

  • 200: The HTTP request succeeded, not necessarily that object retouching succeeded.
message string

API response message.

data.task_id string

Object retouching task ID.

data.created_at string

Task creation timestamp.

data.processed_at string

Timestamp when processing started.

data.completed_at string

Task completion timestamp.

data.image string

Object retouching result image URL or Base64 data. The URL is valid for 1 hour.

data.return_type number

Result return type.

data.type number

Retouch type used for the task.

data.progress number

Task progress.

  • 100: Processing is complete.
data.state number

Task status code. See Status Code Definitions.

  • 1: Completed;
  • > 1: Processing;
  • < 0: Failed.
data.time_elapsed string

Processing time.

data.state_detail string

Detailed task state.

Query object retouching result

For asynchronous requests, poll the result once every 1 second. The maximum polling duration for this API is 180 seconds; if the total polling time exceeds this without a result, treat it as a timeout failure.

GET /api/tasks/visual/retouching-collection/{task_id}

Path Parameters

task_id string required

Object retouching task ID returned after creating an async task. Use it to query the processing result.

Return Parameters

status number

HTTP response status code. See Status Code Definitions.

  • 200: The HTTP request succeeded, not necessarily that object retouching succeeded.
message string

API response message.

data.task_id string

Object retouching task ID.

data.created_at string

Task creation timestamp.

data.processed_at string

Timestamp when processing started.

data.completed_at string

Task completion timestamp.

data.image string

Object retouching result image URL or Base64 data. The URL is valid for 1 hour.

data.return_type number

Result return type.

data.type number

Retouch type used for the task.

data.progress number

Task progress.

  • 100: Processing is complete.
data.state number

Task status code. See Status Code Definitions.

  • 1: Completed;
  • > 1: Processing;
  • < 0: Failed.
data.time_elapsed string

Processing time.

data.state_detail string

Detailed task state.

Guidelines and Limits

  1. The result image URL is generally valid for 1 hour. Please download and store it promptly.

  2. HTTP status 200 indicates that the HTTP request succeeded, not that object retouching succeeded. See Status Code Definitions for details.

  3. When passing URLs as parameters, follow URL encoding standards to prevent parameter parsing confusion.

  4. If provided, the mask must match the dimensions and resolution of the source image.

    Original imageMask imageResult image
    Original image Mask image Result image
  5. Uploaded images must meet the following format, resolution, and file size limits.

    FormatResolutionSize
    jpg, jpeg, bmp, png, webp, tiff, bitmapUp to 4096 x 4096Up to 50MB