One-Click Packaging - Trendy Template
Description
Applies a trendy template to package a video in one click.
Version
1.0
Media Requirements
- Supported media format: MP4.
- Supported media size: no more than 200 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/smart_edit_package/492572
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/smart_edit_package/492572 |
| Yes | task_type | string | Fixed value: formula |
| No | sync_timeout | int | Synchronization timeout; default: 30 |
The init_images media file parameters are described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | url | string | MP4 media URL or base64-encoded data |
| Yes | profile | object | Media attribute information |
The profile attribute information is described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | media_profiles | object | Media profile information |
| Yes | version | string | Fixed value: v1 |
The media_profiles media profile information is described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| Yes | media_data_type | string | url indicates a URL; the corresponding media type indicates base64-encoded data |
The params inference parameter is a JSON string whose structure is described below.
| Required | Field | Type | Description |
|---|---|---|---|
| No | rsp_media_type | string | Default: url; jpg indicates base64-encoded data |
| Yes | parameter | object | Core algorithm parameter object |
The algorithm parameters in parameter are described below.
| Required | Parameter | Type | Description |
|---|---|---|---|
| No | material_id | string | Template asset ID: SEC0082 for Eye-Catching · Color-Customizable, SEC0056 for Minimalist Yellow & White, SEC0129 for Ultra-Minimalist Green, or SEC0023 for Minimalist Large Headline |
Request Example
{
"task": "/v1/smart_edit_package/492572",
"task_type": "formula",
"init_images": [
{
"url": "https://xiuxiu-pro-pre.meitudata.com/test_0520/4da2264785cd22c075ad214da06e2c7c.mp4",
"profile": {
"media_profiles": {
"media_data_type": "url"
},
"version": "v1"
}
}
],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"material_id\":\"SEC0082\"}}",
"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 |
| error_code | int | Error code |
| message | string | Business message |
| tips | any | Additional information |
| data | object | Task status and algorithm result |
The fields in data are described below.
| 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 | Custom task ID supplied by the client |
| trace_id | string | Trace identifier |
| client_info | string | Client information |
| init_images | object[]/null | Echoed input media |
The fields in result are described below.
| Field | Type | Description |
|---|---|---|
| id | string | Unique task identifier |
| urls | array | List of generated video URLs |
| parameters | object | Algorithm parameter information, including task processing details |
| data | object | Detailed data 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 |
The fields in result.parameters are described below.
| Field | Type | Description |
|---|---|---|
| category | string | Algorithm category; value: smart_edit_package |
| cover_url | string | Cover image URL |
| formula_id | string | Formula ID |
| material_id | string | Asset ID |
| rsp_media_type | string | Response media type |
| smart_edit_task_id | string | Smart-edit task ID |
| task_id | string | Task ID |
| trace_id | string | Trace ID |
| video_url | string | Video URL |
| watermark_url | string | Watermark URL |
The fields in result.data are described below.
| Field | Type | Description |
|---|---|---|
| duration | object | Processing-time statistics by stage |
| error_code | number | Algorithm error code; 0 indicates success |
| error_msg | string | Algorithm error message |
| media_info_list | array | Media information list |
| msg_id | string | Message ID |
| parameter | object | Echoed parameters |
The fields in duration are described below.
| Field | Type | Description |
|---|---|---|
| alg_process_time | number | Algorithm processing time, in milliseconds |
| created_timestamp | number | Task creation timestamp, in milliseconds |
| pull_timestamp | number | Resource retrieval timestamp, in milliseconds |
| waiting_time | number | Queue wait time, in milliseconds |
The fields in media_info_list are described below.
| Field | Type | Description |
|---|---|---|
| media_data | string | Media data URL |
| media_extra | object | Additional media information |
| media_profiles | object | Media profile information |
The fields in media_profiles are described below.
| Field | Type | Description |
|---|---|---|
| media_data_type | string | Media data type, such as url |
| media_type | string | Media type, such as video |
The fields in mtlab_res are described below.
| Field | Type | Description |
|---|---|---|
| ErrorCode | number | Underlying error code |
| ErrorMsg | string | Underlying error message |
| error_code | number | Error code (compatibility field) |
| error_msg | string | Error message (compatibility field) |
| media_info_list | array | Media information list |
| msg_id | string | Message ID |
| parameter | object | Parameter information |
Response Examples
Successful Response Example
{
"request_id": "",
"trace_id": "",
"code": 0,
"error_code": 0,
"message": "success",
"tips": null,
"data": {
"status": 10,
"result": {
"id": "t_mt1a3i5n7bbf1dcf9a-bda4-4870-a18d-1b79a4838490",
"urls": [
"https://action-common.meitudata.com/aigc_result_long/a67f4a2a-0152-44d4-496e-12998a3e39bc.mp4"
],
"parameters": {
"category": "smart_edit_package",
"cover_url": "https://action-public.meitudata.com/roboneo/photo/6a4471d0721370511Aye53qpko5651.jpg",
"formula_id": "smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"material_id": "SEC0082",
"rsp_media_type": "url",
"smart_edit_task_id": "9e321bb7-8121-418e-904f-a2201ff35beb",
"task_id": "smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"trace_id": "aigcp_smart_edit_package_smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"video_url": "https://action-common.meitudata.com/aigc_result_long/a67f4a2a-0152-44d4-496e-12998a3e39bc.mp4",
"watermark_url": ""
},
"data": {
"duration": {
"alg_process_time": 63240,
"created_timestamp": 1782870417546,
"pull_timestamp": 1782870417575,
"waiting_time": 29
},
"error_code": 0,
"error_msg": "",
"media_info_list": [
{
"media_data": "https://action-common.meitudata.com/aigc_result_long/a67f4a2a-0152-44d4-496e-12998a3e39bc.mp4",
"media_extra": null,
"media_profiles": {
"media_data_type": "url",
"media_type": "video"
}
}
],
"msg_id": "smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"parameter": {
"category": "smart_edit_package",
"cover_url": "https://action-public.meitudata.com/roboneo/photo/6a4471d0721370511Aye53qpko5651.jpg",
"formula_id": "smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"material_id": "SEC0082",
"rsp_media_type": "url",
"smart_edit_task_id": "9e321bb7-8121-418e-904f-a2201ff35beb",
"task_id": "smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"trace_id": "aigcp_smart_edit_package_smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"video_url": "https://action-common.meitudata.com/aigc_result_long/a67f4a2a-0152-44d4-496e-12998a3e39bc.mp4",
"watermark_url": ""
}
},
"msg_id": "smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"images": [
"https://action-common.meitudata.com/aigc_result_long/a67f4a2a-0152-44d4-496e-12998a3e39bc.mp4"
],
"mtlab_res": {
"ErrorCode": 0,
"ErrorMsg": "",
"error_code": 0,
"error_msg": "",
"media_info_list": null,
"msg_id": "smartedit_pkg_a5f3afa4-017f-41c7-affb-3b73a63ec357_1782870417",
"parameter": null
},
"media_info_list": [
{
"media_data": "https://action-common.meitudata.com/aigc_result_long/a67f4a2a-0152-44d4-496e-12998a3e39bc.mp4",
"media_extra": null,
"media_profiles": {
"media_data_type": "url",
"media_type": "video"
}
}
]
},
"progress": 1,
"predict_elapsed": 10000,
"create_time": 1782870417420,
"task_id": "t_mt1a3i5n7bbf1dcf9a-bda4-4870-a18d-1b79a4838490",
"custom_task_id": "",
"trace_id": "",
"client_info": "",
"init_images": null
}
}Query-Required 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_mt1a3i5n7bbf1dcf9a-bda4-4870-a18d-1b79a4838490"
},
"progress": 0,
"predict_elapsed": 10000,
"create_time": 1782870417420,
"task_id": "t_mt1a3i5n7bbf1dcf9a-bda4-4870-a18d-1b79a4838490",
"custom_task_id": "",
"trace_id": "98e11fa6-fd54-4dfc-9f34-4e09bc38ab08",
"client_info": "",
"init_images": null
}
}Failed Response Example
Response Status: 400
Content-Type: application/json; charset=utf-8
{
"request_id": "",
"trace_id": "",
"code": 0,
"error_code": 20001,
"message": "PROCESS_ERROR",
"tips": null,
"data": {
"status": 2,
"result": {
"error_code": 20001,
"error_msg": "PROCESS_ERROR"
},
"progress": 0,
"predict_elapsed": 0,
"create_time": 1782870417420,
"task_id": "t_mt1a3i5n7bbf1dcf9a-bda4-4870-a18d-1b79a4838490",
"custom_task_id": "",
"trace_id": "",
"client_info": "",
"init_images": null
}
}General Error Codes and Messages
For details, see API Error Codes.
API-specific error: 20001 PROCESS_ERROR, indicating a processing error.
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": {"material_id": "SEC0082"},
}
payload = {
"task": "/v1/smart_edit_package/492572",
"task_type": "formula",
"init_images": [
{
"url": "https://xiuxiu-pro-pre.meitudata.com/test_0520/4da2264785cd22c075ad214da06e2c7c.mp4",
"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/smart_edit_package/492572",
"task_type": "formula",
"init_images": [{
"url": "https://xiuxiu-pro-pre.meitudata.com/test_0520/4da2264785cd22c075ad214da06e2c7c.mp4",
"profile": {
"media_profiles": {"media_data_type": "url"},
"version": "v1"
}
}],
"params": "{\"rsp_media_type\":\"url\",\"parameter\":{\"material_id\":\"SEC0082\"}}",
"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' => ['material_id' => 'SEC0082'],
]);
$body = json_encode([
'task' => '/v1/smart_edit_package/492572',
'task_type' => 'formula',
'init_images' => [
[
'url' => 'https://xiuxiu-pro-pre.meitudata.com/test_0520/4da2264785cd22c075ad214da06e2c7c.mp4',
'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/smart_edit_package/492572\",\n" +
" \"task_type\": \"formula\",\n" +
" \"init_images\": [{\n" +
" \"url\": \"https://xiuxiu-pro-pre.meitudata.com/test_0520/4da2264785cd22c075ad214da06e2c7c.mp4\",\n" +
" \"profile\": {\n" +
" \"media_profiles\": {\"media_data_type\": \"url\"},\n" +
" \"version\": \"v1\"\n" +
" }\n" +
" }],\n" +
" \"params\": \"{\\\"rsp_media_type\\\":\\\"url\\\",\\\"parameter\\\":{\\\"material_id\\\":\\\"SEC0082\\\"}}\",\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);
}
}
}