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 wait for and return the result immediately. Results are kept for up to 1 hour.

  • 0: Return a task_id asynchronously and fetch the result later with task_id;
  • 1: Wait for and return the result synchronously.
format string optional

Result image format. Default: jpeg / jpg.

  • jpeg / jpg: Return a JPEG image;
  • png: Return a PNG image;
  • webp: Return a WebP image.
return_type integer optional

Result return type. Default: 1.

  • 1: Return an image URL;
  • 2: Return a Base64-encoded string;
  • 3: Return binary data, available only for synchronous requests.

Return Parameters

status number

HTTP response status code. See Status Code Definitions.

  • 200: Request succeeded;
  • Non-200: Request failed.
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. See Status Code Definitions.

  • 200: Request succeeded;
  • Non-200: Request failed.
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: Processing is complete.
data.state number

Task status code. See Status Code Definitions.

  • 1: Succeeded;
  • > 1: Processing;
  • < 0: Failed;
  • -7: Invalid image file.

Query photo colorization result

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

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. See Status Code Definitions.

  • 200: Request succeeded;
  • Non-200: Request failed.
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: Processing is complete.
data.state number

Task status code. See Status Code Definitions.

  • 1: Succeeded;
  • > 1: Processing;
  • < 0: Failed;
  • -7: Invalid image file.

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