Background Blur API

Try on PicWish

Blur the background of an image while keeping the subject sharp.

Result links are generally valid for 1 hour. Download and store them 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 a Background Blur Task

POST /api/tasks/visual/background-blur

Body Parameters

image_url string optional

Image download URL. Supports HTTP and OSS, up to 512 characters, with a 20-second download timeout.

one required
image_file file optional

Image file uploaded as multipart/form-data. The file takes priority if a URL is also supplied.

For image upload requirements, see Guidelines and Limits #2.

sync integer optional

Request mode.

  • 0 returns data.task_id for polling.
  • 1 waits for processing and returns the result directly.
bg_blur integer optional

Blur strength from 0 to 20, where 0 is the weakest and 20 is the strongest. Defaults to 5.

output_type integer optional

Select which images to return.

  • 1 returns the blurred image and the foreground mask.
  • 2 returns only image (default).
  • 3 returns only mask.
type string optional

Foreground type. Omit this field for automatic detection.

  • person selects people.
  • object selects objects.
  • stamp selects stamps.

Return Parameters

status integer

HTTP response status code. 200 indicates a successful request. See Status Code Definitions.

message string

Response message, when present.

data.task_id string

Task ID used to retrieve async results or troubleshoot a failure.

status integer

HTTP response status code. 200 indicates a successful request. See Status Code Definitions.

message string

Response message, when present.

data.task_id string

Task ID used to retrieve async results or troubleshoot a failure.

data.state integer

Task state. 1 indicates success, negative values indicate failure, and 0, 2, 3, or 4 indicate a pending task. See Status Code Definitions.

data.state_detail string

Task state details, such as Complete.

data.progress integer

Processing progress as a percentage from 0 to 100.

data.image string

Download URL or Base64 data for the blurred image. Returned when output_type is 1 or 2.

data.mask string

Download URL for the foreground mask. Returned when output_type is 1 or 3.

data.created_at integer

Unix timestamp in seconds when the task was created.

data.processed_at integer

Unix timestamp in seconds when processing started.

data.completed_at integer

Unix timestamp in seconds when processing completed.

Query a Background Blur Result

For asynchronous requests, poll the result once every 1 second. The maximum polling duration for this API is 300 seconds; if the total polling time exceeds this without a result, treat it as a timeout failure. Stop polling when the task succeeds (state = 1) or fails (state < 0).

GET /api/tasks/visual/background-blur/{task_id}

Path Parameters

task_id string required

The task ID returned by the async create request.

Return Parameters

status integer

HTTP response status code. 200 indicates a successful request. See Status Code Definitions.

message string

Response message, when present.

data.task_id string

Task ID used to retrieve async results or troubleshoot a failure.

data.state integer

Task state. 1 indicates success, negative values indicate failure, and 0, 2, 3, or 4 indicate a pending task. See Status Code Definitions.

data.state_detail string

Task state details, such as Complete.

data.progress integer

Processing progress as a percentage from 0 to 100.

data.image string

Download URL or Base64 data for the blurred image. Returned when output_type is 1 or 2.

data.mask string

Download URL for the foreground mask. Returned when output_type is 1 or 3.

data.created_at integer

Unix timestamp in seconds when the task was created.

data.processed_at integer

Unix timestamp in seconds when processing started.

data.completed_at integer

Unix timestamp in seconds when processing completed.

data.time_elapsed string

Processing duration.

Guidelines and Limits

  1. Each successful call consumes 1 credit.

  2. Uploaded images must meet the following format, resolution, and file size limits.

    FormatResolutionFile size
    JPG, PNG, BMP20–10,000 px per sideUp to 50 MB