Meitu CLI is a command-line interface to Meitu's AI image and video capabilities. Everything accessible through the Meitu AI Open Platform — cutout, beauty enhancement, image generation, virtual try-on, image-to-video, and more — is available directly from the terminal with the same models, parameters, and quality.
It is designed for:
- AI agents — structured JSON output (
--json), deterministic exit codes, and automatic task polling make it a natural fit for agentic workflows that need to call Meitu's image and video AI as a tool step (e.g. Claude Code, Cursor, or custom LLM agents). - E-commerce & content teams — batch-process product images at scale: cutout backgrounds, virtual try-on for fashion listings, beauty enhancement for portrait shots, or generate marketing visuals without a GUI.
- Developers building on Meitu OpenAPI — prototype and debug API calls interactively from the terminal before integrating them into an application.
Recommended for most users (npm package):
npm install -g meitu-cliThen run the CLI directly:
meitu --help
meitu auth verify --jsonIf you do not want a global install, you can run the published package with npx:
npx -y meitu-cli --help
npx -y meitu-cli auth verify --jsonTool commands work the same way through npx:
npx -y meitu-cli image-cutout --image ./test.png --jsonNotes:
npm install -g meitu-cliinstalls the package globally and exposes themeitucommand onPATH.npx -y meitu-cli ...runs the published package without a separate global install.- Both forms use the same CLI behavior, configuration file, and environment variables.
Preferred (ClawHub):
npm install -g clawhub
clawhub install meitu-skillsFallback (GitHub URL):
npx -y skills add https://github.com/meitu/meitu-skills --yesYou can save credentials locally:
meitu config set-ak --value your_access_key
meitu config set-sk --value your_secret_keyOr provide them through environment variables:
export MEITU_OPENAPI_ACCESS_KEY=your_access_key
export MEITU_OPENAPI_SECRET_KEY=your_secret_keyEnvironment variables take priority over the local credentials file.
The local credentials file is stored at ~/.meitu/credentials.json.
Built-in defaults (unless overridden by environment variables below):
- OpenAPI gateway host and strategy (file-upload token) host are set inside the CLI; override them only if your documentation or environment requires a different host (see Advanced Overrides).
- verify path:
/demo/authorization - image generate path:
/api/v1/sdk/push - task status path:
/api/v1/sdk/status
For normal external usage, you usually only need:
MEITU_OPENAPI_ACCESS_KEYMEITU_OPENAPI_SECRET_KEY
The strategy service used for local file upload is built in and does not need to be configured in normal usage.
If you are testing against a private environment or a non-default deployment, the CLI also supports:
MEITU_OPENAPI_BASE_URL— overrides the built-in OpenAPI gateway hostMEITU_OPENAPI_IMAGE_BASE_URL— optional; image/task calls use this if set, otherwiseMEITU_OPENAPI_BASE_URL(or the built-in default when that is unset)MEITU_OPENAPI_STRATEGY_BASE_URL— overrides the built-in strategy host
The strategy path and strategy type use built-in defaults and normally do not need to be changed:
- strategy path:
/ai/token_policy(override:MEITU_OPENAPI_STRATEGY_PATH) - strategy type:
mtai(override:MEITU_OPENAPI_STRATEGY_TYPE)
Example:
export MEITU_OPENAPI_BASE_URL=https://api.example.com
export MEITU_OPENAPI_STRATEGY_BASE_URL=https://strategy.example.comVerify credentials:
meitu auth verify --jsonTool commands:
video-motion-transferimage-to-videotext-to-videovideo-to-gifimage-generateimage-poster-generateimage-editimage-upscaleimage-beauty-enhanceimage-face-swapimage-try-onimage-cutoutimage-grid-split
Behavior in short:
- task routing and task types are handled inside the CLI
- local file paths and remote URLs are supported for media inputs
- each subcommand exposes flags derived from the same tool metadata the CLI ships with; run
meitu <command> --helpfor the exact options
Parameter wrapping rules (for JSON payloads sent to the API):
- values from
parameter_input_aliasare wrapped as{"parameter": {...}} - values from
params_input_aliasstay at the top level ofparams - when a tool has no extra params, the CLI sends an empty string for
params
Run cutout with a local file:
meitu image-cutout \
--image ./test.jpg \
--model_type 2 \
--download-dir ./outputs \
--jsonRun beauty enhancement with the default beauty mode:
meitu image-beauty-enhance \
--image ./portrait.jpg \
--jsonRun beauty enhancement with stronger beauty mode (flag name matches the OpenAPI field spelling):
meitu image-beauty-enhance \
--image ./portrait.jpg \
--beatify_type 1 \
--jsonRun image generation with a prompt only:
meitu image-generate \
--prompt "make it cinematic" \
--jsonRun virtual try-on with the required media inputs:
meitu image-try-on \
--clothes_image_url ./cloth.png \
--person_image_url ./person.png \
--replace upper \
--need_sd 1 \
--jsonThe low-level generate command is still available when you need to call a custom task directly.
Run intelligent cutout with a local file through the low-level command:
meitu generate \
--task /v1/photo_scissors/sod \
--image-file ./test.jpg \
--params-json '{"parameter":{"nMask":false,"model_type":0}}' \
--download-dir ./outputs \
--jsonRun a task with an explicit init_images array:
meitu generate \
--task /v1/photo_scissors/sod \
--task-type mtlab \
--init-images-json '[{"media_data":"./test.jpg","resource_type":"file","profile":{"media_profiles":{"media_data_type":"url"},"version":"v1"}}]' \
--params-json '{"parameter":{"nMask":false,"model_type":0}}' \
--download-dir ./outputs \
--jsonRun a task with a remote image URL:
meitu generate \
--task /v1/photo_scissors/sod \
--image-url https://example.com/test.jpg \
--params-json '{"parameter":{"nMask":false,"model_type":0}}' \
--jsonWait for an existing task manually:
meitu task wait t_xxx --download-dir ./outputs --jsonmeitu generateautomatically polls/api/v1/sdk/statuswhen the create call returns atask_id- default polling interval:
1s status = 0,1, or9means the task is still runningstatus = 10means the task succeededstatus = 2means the task failed- any other non-success status is treated as a failure state
When --download-dir is used, the CLI downloads every result image URL it receives and returns downloaded_files in JSON output.
From the repository root:
npm install
npm testIf you want to preview the npm package contents locally:
npm pack --dry-run --cache /tmp/meitu-node-npm-cache