meitu-ai
v0.1.8
Published
Node.js CLI for Meitu OpenAPI image and media tasks.
Readme
Meitu CLI
cli/ is the main Node.js implementation of the meitu CLI. It is the primary command-line runtime for this repository.
It supports:
- local or environment-based credential loading
auth verifygeneratefor low-level image effect calls- automatic task polling
- result download with
--download-dir - local file upload through the strategy service
- metadata-driven tool commands such as
image-cutout,image-generate, andimage-to-video
Install
Recommended for external CLI users after the npm package is published:
npm install -g meitu-aiThen 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-ai --help
npx -y meitu-ai auth verify --jsonTool commands work the same way through npx:
npx -y meitu-ai image-cutout --image ./test.png --jsonNotes:
npm install -g meitu-aiinstalls the package globally and exposes themeitucommand onPATH.npx -y meitu-ai ...runs the published package without a separate global install.- Both forms use the same CLI behavior, configuration file, and environment variables.
For local repository usage:
cd cli
npm install
npm linkThen verify:
meitu --help
meitu image-cutout --helpConfigure
You 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:
- verify endpoint:
/demo/authorization - image generate endpoint:
/api/v1/sdk/push - task status endpoint:
/api/v1/sdk/status
Advanced Overrides
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 these advanced overrides:
MEITU_OPENAPI_BASE_URLMEITU_OPENAPI_STRATEGY_BASE_URL
The strategy path and strategy type use built-in defaults and normally do not need to be configured:
- strategy path:
/ai/token_policy - strategy type:
mtai
Example:
export MEITU_OPENAPI_BASE_URL=https://api.example.com
export MEITU_OPENAPI_STRATEGY_BASE_URL=https://strategy.example.comUsage
Verify credentials:
meitu auth verify --jsonTool commands:
video-motion-transferimage-editimage-generateimage-upscaleimage-try-onimage-to-videoimage-face-swapimage-cutoutimage-beauty-enhance
These commands all use the same fixed internal defaults:
- task mapping is handled internally by the CLI
- task type is handled internally by the CLI
- media inputs are exposed from the MCP tool metadata
- local file paths and remote URLs are both supported for media inputs
- parameter definitions are exposed from MCP metadata and wrapped by the CLI automatically
The CLI loads media input and parameter definitions from the MCP tool metadata endpoint. Use per-tool help to inspect the exact arguments:
meitu image-cutout --help
meitu image-try-on --helpParameter wrapping rules:
- 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:
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 \
--jsonAdvanced Generate Usage
The 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 --jsonTask Behavior
meitu 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.
Development
cd cli
npm install
npm testIf you want to preview the npm package contents locally:
npm pack --dry-run --cache /tmp/meitu-node-npm-cachePython Reference
The previous Python implementation is still kept in:
cli-python/
