Product Image Restoration
Description
Restores product images.
Version
1.0
Image Requirements
- Supported image formats: PNG and JPEG.
- Supported image size: no larger than 20 MB.
API URL
Production environment: https://openapi.meitu.com
Task submission endpoint: https://openapi.meitu.com/api/v1/sdk/sync/push
Task name (task): /v1/goods_image_repair/493222
Task type (task_type): formulaMethod
POST
Content-Type: application/json
Authentication
Request Parameters
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | params | string | Algorithm parameters (JSON string) |
| Yes | init_images | object[] | Media file list |
| Yes | task | string | Fixed value: /v1/goods_image_repair/493222 |
| Yes | task_type | string | Fixed value: formula |
| No | sync_timeout | int | Synchronous timeout; defaults to 30 |
The init_images media file parameters have the following structure:
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | url | string | Image URL or Base64-encoded data |
| Yes | profile | object | Attribute information |
The profile object has the following structure:
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | media_profiles | object | Media attributes |
| Yes | version | string | Fixed value: v1 |
The media_profiles object has the following structure:
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | media_data_type | string | url indicates a URL; types such as jpg indicate Base64-encoded data |
The params inference parameter is a JSON string with the following structure:
| Required | Field | Type | Description |
|---|---|---|---|
| No | rsp_media_type | string | Defaults to url; jpg returns Base64-encoded data, while url returns a URL |
| Yes | parameter | object | Core algorithm parameter object |
Algorithm parameters in parameter:
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | version | string | Algorithm version, such as 1.0.0 or 2.0.0; defaults to 1.0.0 |
| No | create_value | int | Creativity value in the range -100 to 100; defaults to 0 |
| No | hdr_value | int | HDR enhancement value in the range 0 to 100; defaults to 30 |
| No | resemblance_value | int | Resemblance value in the range 0 to 100; defaults to 100 |
| No | prompt | string | Prompt; defaults to an empty string |
| No | sr_num | int | Upscaling factor; allowed values are 2 and 4, and the default is 2. For 2× upscaling, the source image can be up to 2560×2560; for 4× upscaling, it can be up to 1280×1280 |
| No | portraits_xz | int | Whether to enable portrait-scene processing; defaults to 0. 0: disabled; 1: enabled |
| No | custom_size_flag | int | Whether to enable adaptive sizing; defaults to 0. 0: disabled; 1: enabled |
| Not specified in source | guidance_value | int | The source JSON example establishes only that the type is int and the example value is 120; the source does not specify its meaning, whether it is required, its valid range, or its default value |
| Not specified in source | mode | int | The source JSON example establishes only that the type is int and the example value is 2; the source does not specify its meaning, whether it is required, its valid range, or its default value |
| Not specified in source | algorithm_version | string | The source JSON example establishes only that the type is string and the example value is v3; the source does not specify its meaning, whether it is required, its valid range, or its default value |
Request Example
{
"task": "/v1/goods_image_repair/493222",
"task_type": "formula",
"init_images": [
{
"url": "https://file.style3d.com/app/intellistyle/company/ai/1784340525931/CAL020-DDPD.png",
"profile": {
"media_profiles": {
"media_data_type": "url"
},
"version": "v1"
}
}
],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"version\":\"1.0.0\",\"create_value\":100,\"hdr_value\":30,\"resemblance_value\":100,\"prompt\":\"\",\"sr_num\":2,\"portraits_xz\":0,\"custom_size_flag\":1,\"guidance_value\":120,\"mode\":2,\"algorithm_version\":\"v3\"}}",
"sync_timeout": 30
}Response Fields
Note: Generated results are periodically deleted. Download and save them promptly.| Field | Type | Description |
|---|---|---|
| request_id | string | Request identifier |
| trace_id | string | Trace identifier |
| code | int | Business status code; 0 indicates that the request was accepted successfully |
| error_code | int | Error code; 0 on success |
| message | string | Business message |
| tips | any | Additional information; may be null |
| data | object | Task status and algorithm result |
Fields in data:
| Field | Type | Description |
|---|---|---|
| status | int | Status code: -1, task not found; 0, created successfully; 1, processing; 2, failed; 9, timed out—use the query API; 10, succeeded |
| result | object | Algorithm result |
| progress | number | Task progress |
| predict_elapsed | int | Estimated processing time, in milliseconds |
| create_time | int64 | Creation timestamp, in milliseconds |
| task_id | string | Task ID |
| custom_task_id | string | Client-defined task ID |
| trace_id | string | Trace identifier |
| client_info | string | Client information |
| init_images | object[]/null | Echo of the input media |
Fields in data.result:
| Field | Type | Description |
|---|---|---|
| id | string | Unique task identifier |
| urls | array | List of generated image URLs |
| parameters | object | Algorithm parameter information, including the response media type and algorithm version |
| data | object | Detailed data returned by the algorithm |
| msg | string | Message returned by the algorithm |
| msg_id | string | Message ID |
| images | array | List of generated media URLs |
| mtlab_res | object | Underlying algorithm result |
| media_info_list | array | Media information list |
Fields in data.result.parameters:
| Field | Type | Description |
|---|---|---|
| rsp_media_type | string | Response media type |
| version | string | Algorithm version |
Fields in data.result.data:
| Field | Type | Description |
|---|---|---|
| duration | object | Processing-time statistics for each stage |
| error_code | int | Algorithm error code; 0 indicates success |
| error_msg | string | Algorithm error message |
| extra | object | Extended metadata |
| media_info_list | array | Media information list |
| msg_id | string | Message ID |
| parameter | object | Echo of the parameters |
Fields in data.result.data.duration:
| Field | Type | Description |
|---|---|---|
| alg_process_time | int | Algorithm processing time, in milliseconds |
| created_timestamp | int | Task creation timestamp |
| pull_timestamp | int | Resource retrieval timestamp |
| repost_time | int | Reprocessing time, in milliseconds |
| upload_time | int | Resource upload time, in milliseconds |
| waiting_time | int | Queue wait time, in milliseconds |
Fields in data.result.data.extra.trans_meta:
| Field | Type | Description |
|---|---|---|
| req_meta | array | Request media metadata list; media_type in each item indicates the media type |
| rsp_meta | array | Response media metadata list; each item contains height, media_type, size, and width |
Fields in each item of data.result.media_info_list and data.result.data.media_info_list:
| Field | Type | Description |
|---|---|---|
| media_data | string | Media data URL |
| media_extra | object/null | Additional media information |
| media_profiles | object | Media profile information |
Fields in media_profiles:
| Field | Type | Description |
|---|---|---|
| media_data_height | int | Media height, in pixels |
| media_data_size | int | Media size, in bytes |
| media_data_type | string | Media data type, such as url |
| media_data_width | int | Media width, in pixels |
Fields in data.result.mtlab_res:
| Field | Type | Description |
|---|---|---|
| ErrorCode | int | Underlying error code |
| ErrorMsg | string | Underlying error message |
| error_code | int | Error code (compatibility field) |
| error_msg | string | Error message (compatibility field) |
| media_info_list | array/null | Media information list |
| msg_id | string | Message ID |
| parameter | object/null | Parameter information |
Error codes and messages specific to this API:
| Error Code | Error Message | Description |
|---|---|---|
| 20001 | PROCESS_ERROR | Processing error |
Response Examples
Successful Response Example
{
"request_id": "",
"trace_id": "",
"code": 0,
"error_code": 0,
"message": "success",
"tips": null,
"data": {
"status": 10,
"result": {
"id": "t_mt1a3i5n7b8e22d6dc-44ee-4834-a6a3-e30e2292f5d8",
"urls": [
"https://obs-large.mtlab.meitu.com/mtopen/ff56d688358849259556be0f50065a60/d69631a2-d6b3-4bac-6d52-7b4b46fe11a5.jpeg"
],
"parameters": {
"rsp_media_type": "url",
"version": "1.0.35"
},
"data": {
"duration": {
"alg_process_time": 4505,
"created_timestamp": 1784536063,
"pull_timestamp": 1784536063,
"repost_time": 0,
"upload_time": 211,
"waiting_time": 135
},
"error_code": 0,
"error_msg": "success",
"extra": {
"trans_meta": {
"req_meta": [
{
"media_type": "image"
}
],
"rsp_meta": [
{
"height": 3314,
"media_type": "image",
"size": 1726,
"width": 1977
}
]
}
},
"media_info_list": [
{
"media_data": "https://obs-large.mtlab.meitu.com/mtopen/ff56d688358849259556be0f50065a60/d69631a2-d6b3-4bac-6d52-7b4b46fe11a5.jpeg",
"media_extra": null,
"media_profiles": {
"media_data_height": 3314,
"media_data_size": 1767986,
"media_data_type": "url",
"media_data_width": 1977
}
}
],
"msg_id": "130a0c98-b631-4ef8-4b1d-r009b6117553",
"parameter": {
"rsp_media_type": "url",
"version": "1.0.35"
}
},
"msg": "success",
"msg_id": "130a0c98-b631-4ef8-4b1d-r009b6117553",
"images": [
"https://obs-large.mtlab.meitu.com/mtopen/ff56d688358849259556be0f50065a60/d69631a2-d6b3-4bac-6d52-7b4b46fe11a5.jpeg"
],
"mtlab_res": {
"ErrorCode": 0,
"ErrorMsg": "",
"error_code": 0,
"error_msg": "",
"media_info_list": null,
"msg_id": "130a0c98-b631-4ef8-4b1d-r009b6117553",
"parameter": null
},
"media_info_list": [
{
"media_data": "https://obs-large.mtlab.meitu.com/mtopen/ff56d688358849259556be0f50065a60/d69631a2-d6b3-4bac-6d52-7b4b46fe11a5.jpeg",
"media_extra": null,
"media_profiles": {
"media_data_height": 3314,
"media_data_size": 1767986,
"media_data_type": "url",
"media_data_width": 1977
}
}
]
},
"progress": 1,
"predict_elapsed": 10000,
"create_time": 1784536063640,
"task_id": "t_mt1a3i5n7b8e22d6dc-44ee-4834-a6a3-e30e2292f5d8",
"custom_task_id": "",
"trace_id": "",
"client_info": "",
"init_images": null
}
}Pending Response Example
Use the query API to retrieve the result.
Response Status: 200
Content-Type: application/json; charset=utf-8
{
"request_id": "",
"trace_id": "",
"code": 0,
"error_code": 0,
"message": "success",
"tips": null,
"data": {
"status": 9,
"result": {
"id": "t_mt1a3i5n7b8e22d6dc-44ee-4834-a6a3-e30e2292f5d8"
},
"progress": 0,
"predict_elapsed": 10000,
"create_time": 1784536063640,
"task_id": "t_mt1a3i5n7b8e22d6dc-44ee-4834-a6a3-e30e2292f5d8",
"custom_task_id": "",
"trace_id": "70b45244-3360-4859-bc01-9ec4435a81e8",
"client_info": "",
"init_images": null
}
}Failed Response Example
Response Status: 400
Content-Type: application/json; charset=utf-8
{
"request_id": "",
"trace_id": "",
"code": 20001,
"error_code": 20001,
"message": "PROCESS_ERROR",
"tips": null,
"data": {
"status": 2,
"result": {
"error_code": 20001,
"message": "PROCESS_ERROR"
},
"progress": 0,
"predict_elapsed": 0,
"create_time": 0,
"task_id": "",
"custom_task_id": "",
"trace_id": "",
"client_info": "",
"init_images": null
}
}General Error Codes
See API Error Codes.
SDK Examples
Python
import json
import requests
from sign_sdk import sign
def api_call_example():
key = "your_api_key"
secret = "your_api_secret"
url = "https://openapi.meitu.com/api/v1/sdk/sync/push"
method = "POST"
headers = {
"Content-Type": "application/json",
sign.HeaderHost: "openapi.meitu.com",
}
inner_params = {
"rsp_media_type": "url",
"parameter": {
"version": "1.0.0",
"create_value": 100,
"hdr_value": 30,
"resemblance_value": 100,
"prompt": "",
"sr_num": 2,
"portraits_xz": 0,
"custom_size_flag": 1,
"guidance_value": 120,
"mode": 2,
"algorithm_version": "v3",
},
}
payload = {
"task": "/v1/goods_image_repair/493222",
"task_type": "formula",
"init_images": [
{
"url": "https://file.style3d.com/app/intellistyle/company/ai/1784340525931/CAL020-DDPD.png",
"profile": {
"media_profiles": {"media_data_type": "url"},
"version": "v1",
},
}
],
"params": json.dumps(inner_params, ensure_ascii=False),
"sync_timeout": 30,
}
body = json.dumps(payload, ensure_ascii=False)
signer = sign.Signer(key, secret)
signed_request = signer.sign(url, method, headers, body)
response = requests.Session().send(signed_request)
print(f"Status: {response.status_code}")
print(f"Response: {response.text}")
if __name__ == "__main__":
api_call_example()Go
package main
import (
"fmt"
"io"
"net/http"
"github.com/mtlab/api/signer"
)
func main() {
key := "your_api_key"
secret := "your_api_secret"
signObj := signer.NewSigner(key, secret)
url := "https://openapi.meitu.com/api/v1/sdk/sync/push"
method := http.MethodPost
headers := make(http.Header)
headers.Set(signer.HeaderHost, "openapi.meitu.com")
headers.Set("Content-Type", "application/json")
body := `{
"task": "/v1/goods_image_repair/493222",
"task_type": "formula",
"init_images": [{
"url": "https://file.style3d.com/app/intellistyle/company/ai/1784340525931/CAL020-DDPD.png",
"profile": {
"media_profiles": {"media_data_type": "url"},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"version\":\"1.0.0\",\"create_value\":100,\"hdr_value\":30,\"resemblance_value\":100,\"prompt\":\"\",\"sr_num\":2,\"portraits_xz\":0,\"custom_size_flag\":1,\"guidance_value\":120,\"mode\":2,\"algorithm_version\":\"v3\"}}",
"sync_timeout": 30
}`
req, err := signObj.Sign(url, method, headers, body)
if err != nil {
fmt.Println("Failed to sign request:", err)
return
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println("Failed to send request:", err)
return
}
defer resp.Body.Close()
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Read response failed:", err)
return
}
fmt.Println("Response:", resp.StatusCode, string(responseBody))
}PHP
<?php
require 'signer.php';
$key = 'your_api_key';
$secret = 'your_api_secret';
$signer = new Signer($key, $secret);
$url = 'https://openapi.meitu.com/api/v1/sdk/sync/push';
$method = 'POST';
$headers = ['Content-Type' => 'application/json'];
$innerParams = json_encode([
'rsp_media_type' => 'url',
'parameter' => [
'version' => '1.0.0',
'create_value' => 100,
'hdr_value' => 30,
'resemblance_value' => 100,
'prompt' => '',
'sr_num' => 2,
'portraits_xz' => 0,
'custom_size_flag' => 1,
'guidance_value' => 120,
'mode' => 2,
'algorithm_version' => 'v3',
],
]);
$body = json_encode([
'task' => '/v1/goods_image_repair/493222',
'task_type' => 'formula',
'init_images' => [
[
'url' => 'https://file.style3d.com/app/intellistyle/company/ai/1784340525931/CAL020-DDPD.png',
'profile' => [
'media_profiles' => ['media_data_type' => 'url'],
'version' => 'v1',
],
],
],
'params' => $innerParams,
'sync_timeout' => 30,
]);
$curl = $signer->sign($url, $method, $headers, $body);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status === 0) {
echo 'Error: ' . curl_error($curl);
} else {
echo 'Status: ' . $status . "\n";
echo 'Response: ' . $response . "\n";
}
curl_close($curl);
?>Java
package com.meitu.openai.common;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws Exception {
Signer signer = new Signer("your_api_key", "your_api_secret");
String url = "https://openapi.meitu.com/api/v1/sdk/sync/push";
String method = "POST";
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
headers.put(Signer.HeaderHost, "openapi.meitu.com");
String body = "{\n" +
" \"task\": \"/v1/goods_image_repair/493222\",\n" +
" \"task_type\": \"formula\",\n" +
" \"init_images\": [{\n" +
" \"url\": \"https://file.style3d.com/app/intellistyle/company/ai/1784340525931/CAL020-DDPD.png\",\n" +
" \"profile\": {\n" +
" \"media_profiles\": {\"media_data_type\": \"url\"},\n" +
" \"version\": \"v1\"\n" +
" }\n" +
" }],\n" +
" \"params\": \"{\\\"rsp_media_type\\\":\\\"url\\\",\\\"parameter\\\":{\\\"version\\\":\\\"1.0.0\\\",\\\"create_value\\\":100,\\\"hdr_value\\\":30,\\\"resemblance_value\\\":100,\\\"prompt\\\":\\\"\\\",\\\"sr_num\\\":2,\\\"portraits_xz\\\":0,\\\"custom_size_flag\\\":1,\\\"guidance_value\\\":120,\\\"mode\\\":2,\\\"algorithm_version\\\":\\\"v3\\\"}}\",\n" +
" \"sync_timeout\": 30\n" +
"}";
Map<String, String> signedHeaders = signer.sign(url, method, headers, body);
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestMethod(method);
for (Map.Entry<String, String> entry : signedHeaders.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
connection.setDoOutput(true);
connection.getOutputStream().write(body.getBytes(StandardCharsets.UTF_8));
int status = connection.getResponseCode();
InputStream stream = status >= 400
? connection.getErrorStream()
: connection.getInputStream();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
System.out.println("Response: " + status + " " + response);
}
}
}