Photo Colorization API

Try on PicWish

AI colorizes black-and-white photos by restoring natural colors for people, objects, and scenes. It works for old photos, portraits, and design materials, with async and sync request modes.

The result image URL is 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 a photo colorization task

POST /api/tasks/visual/colorization

Body Parameters

image_url string optional

Source image URL. If this parameter is present, the other image source parameter must be empty.

one required
image_file file optional

Source image file as binary data. If this parameter is present, the other image source parameter must be empty.

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

sync integer optional

Whether to return the result image in real time. Use 0 to return a task_id asynchronously and fetch the result later; use 1 to wait and return the result synchronously. Results are kept for up to 1 hour.

format string optional

Result image format. Supports jpeg/jpg, png, and webp. Default is jpeg/jpg.

return_type integer optional

Result return type. 1 returns an image URL; 2 returns a base64-encoded string; 3 returns binary data and is only available for synchronized requests. Default is 1.

Return Parameters

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

API response message. Usually success for a successful request.

data.task_id string

Async photo colorization task ID returned after the task is created. Use it to query the result later.

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

API response message. Usually success for a successful request.

data.task_id string

Photo colorization task ID.

data.created_at string

Timestamp of task creation.

data.processed_at string

Timestamp when the task started to be processed.

data.completed_at string

Timestamp of task completion.

data.image string

The result image URL or base64 data. The URL is valid for 1 hour.

data.progress number

Task progress. 100 means processing is complete.

data.state number

Task status code. 1 means succeeded, greater than 1 means processing, and less than 0 means failed. -7 means invalid image file. See Status Code Definitions.

Query photo colorization result

GET /api/tasks/visual/colorization/{task_id}

Path Parameters

task_id string required

Photo colorization task ID returned after creating an async task. Use it to query the processing result.

Return Parameters

status number

HTTP response status code. 200 means success, and non-200 means failure. See Status Code Definitions.

message string

API response message. Usually success for a successful request.

data.task_id string

Photo colorization task ID. If the task fails, contact support with this task_id.

data.created_at string

Timestamp of task creation.

data.processed_at string

Timestamp when the task started to be processed.

data.completed_at string

Timestamp of task completion.

data.image string

The result image URL or base64 data. The URL is valid for 1 hour.

data.progress number

Task progress. 100 means processing is complete.

data.state number

Task status code. 1 means succeeded, greater than 1 means processing, and less than 0 means failed. -7 means invalid image file. See Status Code Definitions.

Guidelines and Limits

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

  2. Each successful call consumes 1 credit.

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

    FormatResolutionSize
    jpg, jpeg, bmp, png, webp, tiff, tif, bitmap, raw, rgb, jfif, lzwUp to 4096 x 4096Up to 20MB