Meitu Design Studio: AI Commercial Photography Web SDK

Description

The Meitu Design Studio AI Commercial Photography SDK integrates AI Model, AI Virtual Try-On, and Clothing Recoloring features. It supports online virtual try-on, clothing color replacement, and intelligent model generation, enabling efficient, intelligent photography for e-commerce and design scenarios.

Demo

https://public.static.meitudata.com/xiuxiu-pc/image-editor-sdk/3.0.0/demo/aicp.html

SDK Overview

Version

3.6.3

Supported Browsers

Chrome and other modern browsers

Supported Integration Methods

  1. Enterprise-level in-depth partnership integration (unified account authorization and login)
  2. Standard integration (not yet available)

Prerequisites

Obtain an Access Key

  • Visit the Meitu AI Open Platform to log in and register an account.
  • Go to the Access Keys management page.
  • Click the “Create Key” button to generate and obtain your Access Key.

    The Access Key is the core credential for SDK authentication. Keep it secure and avoid disclosure.

Silent Login Configuration

  • Enable the Inpainting Web SDK feature.
  • On the “Overview” page, go to the service list and click “Silent Login Authorization”.
  • In Application Whitelist Address, enter the domain of the website where you plan to embed the SDK.
  • In Application Silent Login Address, configure your silent login callback URL.

    For integration instructions, refer to: Meitu Products (Web) Silent Login Integration Guide

Quick Start

Include the SDK

The SDK provides two integration methods: installation via NPM or inclusion via CDN. Choose the appropriate method for your project environment.

Method 1: Install via NPM
# Install the SDK
npm i mt-image-editor-sdk
// Import the SDK module
import MTImageEditor, { MTImageEditorClass } from 'mt-image-editor-sdk';

// Multi-instance mode is supported starting from version 3.0.0
// Initialization is the same as in singleton mode
const MTEditor1 = new MTImageEditorClass();
MTEditor1.init({...});
Method 2: Include via CDN
<script src="https://public.static.meitudata.com/xiuxiu-pc/image-editor-sdk/3.0.0/dist/index.min.js"></script>

Initialization and Usage

It is recommended to initialize the SDK immediately after the page finishes loading to improve the speed of the first launch.

MTImageEditor.init({
  // Required: Authentication key obtained from the Meitu Open Platform
  accessKey: 'your_access_key',

  // Silent login key
  appKey: 'your_app_key',

  // Required: Specify the module to integrate
  moduleName: 'ai-commercial-photography-sdk',

  // Required when silent login is enabled; refer to the login documentation below
  // https://titan-h5.meitu.com/xiuxiu-pc/design-open/doc/美图产品(web)静默登录接入文档v0.1.pdf
  code: '',

  // Optional: SDK title
  title: 'Meitu Design Studio — AI Commercial Photography',

  // Optional: Mount node; if omitted, the SDK is displayed as a popup
  el: '',

  // Optional: Whether to enable the fullscreen feature
  fullscreen: true,

  // Optional: Whether to automatically resize on window.onresize
  resizeAble: true,

  // Additional business parameters (optional)
  extraInfo: {
    /**
     * [Optional parameter] Used for model try-on to specify the subfeatures to display.
     * If omitted or empty, all features will be displayed.
     * @type {Array<'model' | 'clothes' | 'wig'>}
     * - model: Model image
     * - clothes: Clothing image
     * - wig: Wig image
     */
    modelFunctionSet: ['model'],

    /**
     * [Optional parameter] The business module to open by default.
     * If omitted, the purchased feature module will open by default.
     * @type {'product' | 'portrait' | 'model' | 'clothes' | 'wig' | 'recolor'}
     */
    redirect: 'product',

    /**
     * [Optional parameter] The set of features to display.
     * If omitted or empty, all features will be displayed.
     * @type {Array<'product' | 'portrait' | 'model' | 'clothes' | 'wig' | 'recolor'>}
     */
    functionSet: ['product', 'portrait'],

    /**
     * [Optional parameter] Whether to prevent the default download event.
     * 0: Allow downloads; 1: Prevent downloads.
     */
    downloadPreventDefault: 1,

    /**
     * [Optional parameter] Custom text for the download button.
     */
    customDownloadText: 'Custom',

    /**
     * [Optional parameter] Callback for a failure to open an image.
     */
    onError: (data) => console.log('Failed to open image', data),
  },
});

SDK Methods

Open an Image
//  Open the specified image by clicking a button
//  Additional business parameters can be passed to specify the module to open. If omitted, the business parameters configured during SDK initialization will be used
//  redirect: Has the same meaning as the redirect business parameter configured during SDK initialization
MTImageEditor.openImage(URL, {
  redirect?: 'product' | 'model' | 'clothes' | 'wig' | 'recolor'
});
Support for Passing Multiple Images
MTImageEditor.openImage([
  'https://xiuxiu-pro-pre.meitudata.com/ai_product/58494ab25ef237f9822a3bd1774b4ae3.jpeg',
  'https://xiuxiu-pro.meitudata.com/ai_material/static/13-ui.png',
  'https://xiuxiu-pro.meitudata.com/ai_material/static/33-ui.png',
  'https://xiuxiu-pro.meitudata.com/ai_material/static/4-ui.png',
]);

Events and Callbacks

Save an Image
MTImageEditor.saveImage((base64, type) => {
  console.log('Image type:', type); // jpg | png
  console.log('Image data:', base64);
});
Listen for AIGC Task Status
// AIGC task started
MTImageEditor.onAigcStart(({ taskId }) => {
  console.log('AI generation task started, taskId:', taskId);
});

// AIGC task completed
MTImageEditor.onAigcFinish(({ taskId, urls }) => {
  console.log('AI generation completed:', urls);
  // urls contains the Meitu CDN URLs of the resulting images; saving your own copies is recommended
});
MTImageEditor.openImage();  // Open the popup
MTImageEditor.close();      // Close the popup

MTImageEditor.onClose(() => {
  console.log('Popup closed');
});

Feature Descriptions

FeatureMethodDescription
Initialize SDKMTImageEditor.init()Initialize the editor instance
Open imageMTImageEditor.openImage()Open one or multiple images for editing
Save imageMTImageEditor.saveImage()Retrieve the generated image data
Listen for generationonAigcStart / onAigcFinishListen for AI task status
Control popupopenImage / closeOpen or close the editor popup
Close callbackonCloseListen for the close event

Parameter Descriptions

RequiredParameterTypeDescription
RequiredaccessKeyStringAuthentication key obtained from the Meitu Open Platform, used to validate SDK requests.
RequiredappKeyStringUnique application identifier, corresponding to the application appid for silent login on the Open Platform.
RequiredaccessKeyStringAuthentication key obtained from the Meitu Open Platform, used to validate SDK requests.
RequiredmoduleNameStringSpecifies the name of the service module to integrate. Currently supported: ai-commercial-photography-sdk (AI Commercial Photography).
OptionalcodeStringIf Meitu silent login is enabled, provide the authorization code returned by silent login. For how to generate code, refer to the Meitu Products (Web) Silent Login Integration Guide
OptionaltitleStringEditor window title. Defaults to “Meitu Design Studio - AI Commercial Photography”.
OptionalelStringSelector for the DOM container where the SDK is mounted. If omitted, the SDK is displayed as a popup.
OptionalfullscreenBooleanWhether to enable fullscreen mode. Defaults to true.
OptionalresizeAbleBooleanWhether to automatically resize when the browser window size changes. Defaults to true.
OptionalextraInfoObjectAdditional business configuration options. See the extraInfo parameter descriptions below.

extraInfo Parameter Descriptions

RequiredParameterTypeDescription
OptionalmodelFunctionSetArrayThe set of subfeatures used for model try-on.
If omitted or empty, all features will be displayed.
⚠️ This property will be deprecated in the future. Use functionSet instead.
OptionalredirectStringThe module page to open by default. If omitted, the purchased module will be opened automatically.
Examples: 'product' (product images), 'recolor' (recoloring), etc.
OptionalfunctionSetArrayThe set of features to display. If omitted or empty, all features will be displayed.
Example of commonly used values: ['product', 'portrait'].
OptionaldownloadPreventDefaultNumberWhether to prevent the download button’s default event.
0: Allow downloads; 1: Prevent downloads.
OptionalcustomDownloadTextStringCustom text for the download button. For example: "Download Now".
OptionalonError-Callback function triggered when an image fails to open.
The data parameter is an error information object.

Frequently Asked Questions

IssuePossible CauseSolution
“403” error during initializationDomain not authorized or key mismatchCheck the whitelist configuration and accessKey
The page cannot load the editorSDK URL or network issueCheck whether the CDN URL is correct
Login verification failedcode has expiredRequest a new silent login credential

Notes

  • Risk notice: Data in [Generation History] and [My Images] is isolated by uid. It is recommended that each user access and use the SDK with a different id.

Versions

DateVersionDescription
2025-12-203.6.3Switched the domain from .com to .cn
2025-11-113.6.2SDK supports silent login
2025-07-163.6.0SDK supports multiple instances
2024-09-263.4.0openImage supports passing multiple images
2024-08-073.3.5Added custom download text, download prevention, and an openImage error callback for commercial photography
2024-06-133.2.0Changed the Meitu Design Studio domain to: www.designkit.com
2024-06-033.1.0Supports callbacks for the start and completion of AIGC generation
2024-04-162.4.3Unified the commercial photography SDK and added support for business parameters
2023-05-302.0.2Added domain whitelist support

Contact

For technical issues or integration inquiries, please contact Meitu Open Platform technical support: Meitu AI Open Platform