Skip to content

Task: Photo Colorization

Short description: Use the photo colorization API to convert grayscale or old photos into color.


Overview

  • Method: POST
  • Path: /task/pic/colorization
  • Content-Type: multipart/form-data

Authentication

  • Header: Authorization: Bearer <token>

Request Example

Form Parameters

ParameterTypeRequiredDescription
image_filefileNoSource image file (binary), mutually exclusive with image_url
image_urlstringNoSource image URL, mutually exclusive with image_file
formatstringNoOutput format, supports jpeg/jpg, png, webp; default jpeg/jpg
syncintegerNoWhether to wait for the result: 0=async (default), 1=sync
callback_urlstringNoCallback URL for notifications

curl Example

bash
curl -X POST "https://api.gpt.ge/task/pic/colorization" \
  -H "Authorization: Bearer sk-xxxx" \
  -F "image_url=https://example.com/old-photo.jpg" \
  -F "format=png" \
  -F "sync=1"

JavaScript (fetch) Example

javascript
const formData = new FormData();
formData.append('image_url', 'https://example.com/old-photo.jpg');
formData.append('format', 'png');
formData.append('sync', '1');

fetch('https://api.gpt.ge/task/pic/colorization', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk-xxxx'
  },
  body: formData
}).then(r => r.json()).then(console.log);

Python (requests) Example

python
import requests

url = 'https://api.gpt.ge/task/pic/colorization'
headers = {
    'Authorization': 'Bearer sk-xxxx'
}

files = {
    'image_url': (None, 'https://example.com/old-photo.jpg')
}
data = {
    'format': 'png',
    'sync': '1'
}

response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())

Response Example (200)

json
{
  "status": 200,
  "data": {
    "completed_at": 1742670627,
    "created_at": 1742670626,
    "download_time": 488,
    "err_info": "",
    "foreground_rect": {
      "x": 133,
      "y": 110,
      "width": 604,
      "height": 952
    },
    "image": "https://wxtechsz.oss-cn-shenzhen.aliyuncs.com/tasks/output/segmentation/3b950563-e53f-4036-a581-5ac04d0829b3-image.png",
    "image_height": 1152,
    "image_width": 864,
    "output_type": 2,
    "processed_at": 1742670626,
    "progress": 100,
    "result_type": "object",
    "return_type": 1,
    "state": 1,
    "state_detail": "Complete",
    "task_id": "3b950563-e53f-4036-a581-5ac04d0829b3",
    "time_elapsed": 384.54998779296875,
    "type": "auto"
  }
}

Note: This endpoint uses multipart/form-data to upload the image. Submit either image_url or image_file, not both. If format is omitted, the default output format is jpeg/jpg.