AI Super Resolution V1
Description
This API processes image super-resolution requests in the cloud.
Image Requirements
JPG, JPEG, and BMP formats are supported.
API URL
Production environment: https://openapi.meitu.com
Task submission endpoint: https://openapi.meitu.com/api/v1/sdk/sync/push
Task name (task): /v1/Ultra_High_Definition/466657
Task type (task_type): formulaMethod
POST
Content-Type: application/json
Authentication
Credits cannot be used to pay for API calls. Please visit the MV console to activate this API and purchase or manage resource packages.
Request Parameters
The request body contains exactly the following five top-level fields:
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | params | string | Inference parameters as a JSON string |
| Yes | init_images | object[] | Image file list |
| Yes | task | string | Fixed value: /v1/Ultra_High_Definition/466657 |
| Yes | task_type | string | Fixed value: formula |
| No | sync_timeout | int | Default: 30. Set to -1 to return immediately without waiting. If the synchronous wait times out, status 9 is returned; use the status API to retrieve the result |
init_images image parameter structure
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | url | string | Image URL or base64 data |
| No | profile | object | Media parameters |
profile media parameter structure
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | media_extra | object | Additional media parameters. The source document does not further define the internal fields |
| No | media_profiles | object | Media description |
| No | version | string | The source request example uses v1 |
media_profiles media description structure
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | media_data_type | string | Default: url. url passes the image by URL; jpg passes JPG base64 data |
params is a JSON string whose deserialized structure is described below
| Required | Field | Type | Description |
|---|---|---|---|
| No | rsp_media_type | string | Default: url. url returns the result image as a URL; jpg returns it as JPG base64 data |
| Yes | parameter | object | Super-resolution algorithm parameter object |
parameter algorithm parameters
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | style_id | int | Adaptive style ID. Obtain it from the adaptive style enumeration API |
| No | sr_num | int | Image scaling factor. Only 2 and 4 are supported; default: 2. At 2x, the maximum supported source-image size is 2560 x 2560; at 4x, it is 1280 x 1280 |
| No | create_value | int | Creativity value in the range 0 to 100. If omitted, the default configured for the adaptive style is used |
| No | hdr_value | int | HDR enhancement value in the range 0 to 100. If omitted, the default configured for the adaptive style is used |
| No | resemblance_value | int | Resemblance value in the range 0 to 100. If omitted, the default configured for the adaptive style is used |
| No | save_photo_format | int | Default: 1, for JPG encoding. 2 selects PNG encoding |
Request Example
The following example preserves the algorithm parameter values from the source document. The source example passes -1 for create_value, hdr_value, and resemblance_value, while the parameter table declares a range of 0 to 100. For integration, follow the current adaptive style configuration and server-side validation rules. To use the default configuration, these three optional fields may also be omitted.
{
"task": "/v1/Ultra_High_Definition/466657",
"task_type": "formula",
"init_images": [
{
"url": "https://example.com/input.jpg",
"profile": {
"media_profiles": {
"media_data_type": "url"
},
"version": "v1"
}
}
],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"sr_num\":2,\"style_id\":26,\"create_value\":-1,\"hdr_value\":-1,\"resemblance_value\":-1}}",
"sync_timeout": 30
}Response Fields
| Field | Type | Description |
|---|---|---|
| request_id | string | Request identifier |
| trace_id | string | Trace identifier |
| code | int | Business status code. 0 means the request was accepted successfully |
| error_code | int | Error code. 0 on success |
| message | string | Business or error message |
| tips | any | Additional information; may be null |
| data | object | Task status and algorithm result |
data field structure
| Field | Type | Description |
|---|---|---|
| status | int | Status code: -1 task not found; 0 task created; 1 processing; 2 failed; 9 requires a query through the status API; 10 succeeded |
| msg | string | Task status description |
| result | object | Algorithm result |
| progress | number | Task progress, for example 0.1, 0.85, or 1 |
| predict_elapsed | int | Estimated 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 | Echoed input media |
result field structure
| Field | Type | Description |
|---|---|---|
| id | string | Task ID |
| urls | string[] | Result image list. When rsp_media_type=url, the values are image URLs; when rsp_media_type=jpg, the values are JPG base64 data |
| parameter | object | Algorithm result media-type indicator. The source document defines its rsp_media_type field |
| media_info_list | object[] | Algorithm media result list. Each item contains image data and its corresponding information |
parameter response fields
| Field | Type | Description |
|---|---|---|
| rsp_media_type | string | Result media type. url means media_data is an image URL; jpg means media_data is JPG base64 data |
Fields in each media_info_list item
| Field | Type | Description |
|---|---|---|
| media_data | string | Result image URL or base64-encoded media file data, depending on rsp_media_type |
| media_profiles | object | Media file attribute information |
media_profiles response fields
| Field | Type | Description |
|---|---|---|
| media_data_type | string | Result media data type. url means a URL; jpg means JPG base64 data |
When a task fails, result may also contain the following fields defined in the source document:
| Field | Type | Description |
|---|---|---|
| ErrorCode | int | Error code |
| ErrorMsg | string | Error message |
| Data | string/null | Detailed information |
Response Examples
Successful Response (status=10)
Response Status: 200
content-type: application/json; charset=utf-8
{
"request_id": "req_1234567890",
"trace_id": "trace_1234567890",
"code": 0,
"error_code": 0,
"message": "success",
"tips": null,
"data": {
"status": 10,
"msg": "success",
"result": {
"id": "task_1234567890",
"urls": [
"https://example.com/result.jpg"
],
"parameter": {
"rsp_media_type": "url"
},
"media_info_list": [
{
"media_data": "https://example.com/result.jpg",
"media_profiles": {
"media_data_type": "url"
}
}
]
},
"progress": 1,
"predict_elapsed": 0,
"create_time": 1718172000000,
"task_id": "task_1234567890",
"custom_task_id": "",
"trace_id": "trace_1234567890",
"client_info": "",
"init_images": null
}
}Query-Required Response (status=9)
When data.status is 9, retrieve the result from the status API using the returned task ID.
Response Status: 200
content-type: application/json; charset=utf-8
{
"request_id": "req_1234567890",
"trace_id": "trace_1234567890",
"code": 0,
"error_code": 0,
"message": "success",
"tips": null,
"data": {
"status": 9,
"msg": "processing",
"result": {
"id": "task_1234567890"
},
"progress": 0,
"predict_elapsed": 10000,
"create_time": 1718172000000,
"task_id": "task_1234567890",
"custom_task_id": "",
"trace_id": "trace_1234567890",
"client_info": "",
"init_images": null
}
}Failed Response (status=2)
Response Status: 400
content-type: application/json; charset=utf-8
{
"request_id": "req_1234567890",
"trace_id": "trace_1234567890",
"code": 20001,
"error_code": 20001,
"message": "PROCESS_ERROR",
"tips": null,
"data": {
"status": 2,
"msg": "PROCESS_ERROR",
"result": {
"id": "task_1234567890",
"ErrorCode": 20001,
"ErrorMsg": "PROCESS_ERROR",
"Data": null
},
"progress": 1,
"predict_elapsed": 0,
"create_time": 1718172000000,
"task_id": "task_1234567890",
"custom_task_id": "",
"trace_id": "trace_1234567890",
"client_info": "",
"init_images": null
}
}API-Specific Error Codes and Messages
| ErrorCode | Error Message | Description |
|---|---|---|
| 20001 | PROCESS_ERROR | Processing error |
| 20003 | DETECT_NOT_FACE | Face missing |
| 20004 | MORE_THAN_ONE_FACE | More than one face detected |
| 20007 | MISSING_LANDMARK_ARGUMENTS | Facial landmarks were not provided |
| 20008 | UNSUITABLE_IMAGE | The image does not meet the requirements |
| 20009 | UNSUPPORT_TYPE | Unsupported type |
| 20010 | DETECT_NOT_FACE | No face detected in the second image |
| 20011 | UNSUITABLE_VERTICAL_IMAGE | Vertical height requirement not met |
| 20012 | UNSUITABLE_HORIZONTAL_IMAGE | Horizontal width requirement not met |
| 20013 | RESOLUTION_TOO_LARGE_ERROR | Resolution too large |
| 20014 | NOT_FOUND | Image not found |
| 20015 | PICTURE_OVERRUN_ERROR | Image limit exceeded |
| 20020 | DETECT_FACE_OUTOFIMAGE | Facial features missing |
| 20021 | DETECT_FACE_PITCHANGLE_BIG | Non-frontal face; pitch angle too large |
| 20022 | DETECT_FACE_YAWANGLE_BIG | Non-frontal face; yaw or rotation angle too large |
| 20023 | DETECT_FACE_LOWAREA | Face occupies too little of the image or has too few pixels |
| 21001 | LOAD_MODEL_ERROR | Model loading failed |
| 21002 | HAIR_MASK_LOSS | Hair mask missing |
| 21003 | FACE_NUM_ERROR | Invalid number of faces |
| 21004 | AR_PARSE_FAULT | Failed to parse the plist in AR |
| 21005 | AR_EEEOR_COUNT | AR face error |
| 21006 | AR_FACE_OUT | AR exceeds the face range |
| 21007 | JSON_ERROR | Invalid JSON content |
| 21008 | BACKGROUND_IMAGE_LOSS | Background image missing |
| 21009 | BODY_MASK_LOSS | Body mask missing |
| 21010 | FACE_ANGLE_ERROR | Invalid face angle |
| 21011 | SKIN_MASK_LOSS | Skin mask missing |
| 21012 | BODY_INFO_LOSS | Skeletal points or outer contour points missing |
| 21013 | RECT_OUT_IMAGE | Rectangle exceeds the image bounds |
| 30001 | GEN_ERROR | Generation error |
General Error Codes and Messages
See API Error Codes.
SDK Examples
Each example signs the complete final JSON body that is sent. The body has only five top-level fields: task, task_type, init_images, params, and sync_timeout.
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": {
"style_id": 26,
"sr_num": 2,
},
}
payload = {
"task": "/v1/Ultra_High_Definition/466657",
"task_type": "formula",
"init_images": [
{
"url": "https://example.com/input.jpg",
"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/Ultra_High_Definition/466657",
"task_type": "formula",
"init_images": [{
"url": "https://example.com/input.jpg",
"profile": {
"media_profiles": {"media_data_type": "url"},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"style_id\":26,\"sr_num\":2}}",
"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' => [
'style_id' => 26,
'sr_num' => 2,
],
]);
$body = json_encode([
'task' => '/v1/Ultra_High_Definition/466657',
'task_type' => 'formula',
'init_images' => [
[
'url' => 'https://example.com/input.jpg',
'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/Ultra_High_Definition/466657\",\n" +
" \"task_type\": \"formula\",\n" +
" \"init_images\": [{\n" +
" \"url\": \"https://example.com/input.jpg\",\n" +
" \"profile\": {\n" +
" \"media_profiles\": {\"media_data_type\": \"url\"},\n" +
" \"version\": \"v1\"\n" +
" }\n" +
" }],\n" +
" \"params\": \"{\\\"rsp_media_type\\\":\\\"url\\\",\\\"parameter\\\":{\\\"style_id\\\":26,\\\"sr_num\\\":2}}\",\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);
}
}
}