API Endpoint Access URL
https://api.pixlab.io/colorize
Get Your API Key & Try COLORIZE Now ↗Description
Perform automatic image colorization on grayscale images using deep learning models. The process may take a few seconds and is available from the Dev Plan. Based on the Colorful Image Colorization paper. Perform automatic image colorization on an input Grayscale image using deep learning models. A typical input image and the output result should look like the following after processing:
Input Picture

After Colorization

The colorization is a heavy process, should take few seconds to execute and is available starting from the Dev Plan and up. The PixLab model is based on the Colorful Image Colorization paper.
HTTP Methods
GET, POST
HTTP Parameters
Required
Fields | Type | Description |
---|---|---|
img |
URL | Input grayscale picture URL. If you want to upload your image directly from your app, then submit a multipart/form-data POST request. |
key |
String | Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to. |
Optional
Fields | Type | Description |
---|---|---|
blob |
Boolean | By default, this API endpoint returns a JSON Object holding the link to the image output. Set to true to receive the raw image binary data instead. |
POST Request Body
Use when submitting POST requests instead of GET:
Allowed Content-Types:
multipart/form-data
application/json
Use multipart/form-data
for direct file uploads (check the REST API code samples or The PixLab Github Repository↗ for implementation examples). For JSON requests, the media file must be hosted externally. Call store to upload images before processing with this endpoint.
HTTP Response
Required
The endpoint expects the following parameters in the request body:
Fields | Type | Description |
---|---|---|
key |
String | Your API key |
image |
URL/String | Input image URL or base64 encoded string |
Optional
Fields | Type | Description |
---|---|---|
blob |
Boolean | Return binary image data instead of JSON response |
The endpoint returns application/json
if the optional blob parameter is not set.
This API endpoint returns a JSON Object after each call only if the optional blob parameter is not set. Otherwise the image binary contents is returned instead. The following are the JSON fields
returned in response body:
Fields | Type | Description |
---|---|---|
status |
Integer | Status code 200 indicates success, any other code indicates failure. |
link |
URL | Link to the media output which is usually stored on the pixlab.xyz storage server unless you set your own S3 keys (refer to your dashboard ↗ on how to do that). |
id |
String | Unique media ID. |
error |
String | Error message if status != 200. |
Code Samples
import requests
def colorize_image(image_url: str, api_key: str) -> str:
"""Colorize a grayscale image using PixLab API.
Args:
image_url: URL of the grayscale image to colorize.
api_key: PixLab API key.
Returns:
URL of the colorized image.
Raises:
requests.exceptions.RequestException: If the API request fails.
ValueError: If the API returns an error.
"""
try:
response = requests.get(
'https://api.pixlab.io/colorize',
params={'img': image_url, 'key': api_key},
timeout=10
)
response.raise_for_status()
data = response.json()
if data['status'] != 200:
raise ValueError(data.get('error', 'Unknown error from API'))
return data['link']
except requests.exceptions.RequestException as e:
raise requests.exceptions.RequestException(f"API request failed: {e}")
except json.JSONDecodeError:
raise ValueError("Invalid JSON response from API")
if __name__ == "__main__":
try:
colorized_url = colorize_image(
'https://storage.googleapis.com/i2s/tiger.jpg',
'PIXLAB_API_KEY'
)
print(f"Link to the colorized picture: {colorized_url}")
except Exception as e:
print(f"Error: {e}")
fetch('https://api.pixlab.io/colorize?img=https://storage.googleapis.com/i2s/tiger.jpg&key=PIXLAB_API_KEY')
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
console.log("Link to the colorized picture: " + reply.link);
}
})
.catch(error => console.error('Error:', error));
<?php
$apiUrl = 'https://api.pixlab.io/colorize';
$params = [
'img' => 'https://storage.googleapis.com/i2s/tiger.jpg',
'key' => 'PIXLAB_API_KEY'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . '?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
throw new RuntimeException('Curl error: ' . curl_error($ch));
}
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
echo "Link to the colorized picture: " . $reply['link'];
}
require 'net/http'
require 'json'
uri = URI('https://api.pixlab.io/colorize')
params = { img: 'https://storage.googleapis.com/i2s/tiger.jpg', key: 'PIXLAB_API_KEY' }
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
reply = JSON.parse(response.body)
if reply['status'] != 200
puts reply['error']
else
puts "Link to the colorized picture: #{reply['link']}"
end
Similar API Endpoints
nsfw, ocr, grayscale, crop, faceverify ↗, tagimg, mogrify, blur, edge