Getting Started

1. Install

npm install -g meitu-cli
meitu --version

If you see meitu: command not found, close and reopen your terminal, then try again (global install only).


2. Configure credentials

Sign in to MeituHub and copy your Access Key and Secret Key

Local config (recommended)

meitu config set-ak --value <ACCESS_KEY>
meitu config set-sk --value <SECRET_KEY>

When using npx:

npx -y meitu-cli config set-ak --value <ACCESS_KEY>
npx -y meitu-cli config set-sk --value <SECRET_KEY>

Environment variables (take precedence over the local file; useful for CI and agents)

macOS / Linux:

export MEITU_OPENAPI_ACCESS_KEY="<ACCESS_KEY>"
export MEITU_OPENAPI_SECRET_KEY="<SECRET_KEY>"

Windows (PowerShell):

$env:MEITU_OPENAPI_ACCESS_KEY = "<ACCESS_KEY>"
$env:MEITU_OPENAPI_SECRET_KEY = "<SECRET_KEY>"

3. Verify

meitu auth verify --json

A response with code: 0 or ok: true means your credentials are valid. If verification fails, make sure the keys were copied in full with no leading or trailing spaces.

On first use, sync the local command metadata:

meitu tools update

4. Run your first command

Create an output directory:

mkdir -p ./output

Text-to-image example:

meitu text-to-image \
  --prompt "An orange cat, minimalist flat illustration" \
  --size 2K \
  --json \
  --download-dir ./output

On Windows, you can use .\output instead of ./output, and create the folder with:

New-Item -ItemType Directory -Force .\output

Success: an image file appears under output, and the JSON shows code: 0 or ok: true.


Quick reference

Flag / commandPurpose
--jsonPrint structured JSON for scripting
--download-dirDownload result files to a directory
meitu --helpList all commands
meitu <command> --helpShow options for one command

If an async job times out, poll manually: meitu task wait <task_id> --timeout-ms 600000 --json (use a higher timeout for video jobs).

For more commands, run meitu --help.