Getting Started
1. Install
npm install -g meitu-cli
meitu --versionIf 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 --jsonA 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 update4. Run your first command
Create an output directory:
mkdir -p ./outputText-to-image example:
meitu text-to-image \
--prompt "An orange cat, minimalist flat illustration" \
--size 2K \
--json \
--download-dir ./outputOn Windows, you can use .\output instead of ./output, and create the folder with:
New-Item -ItemType Directory -Force .\outputSuccess: an image file appears under output, and the JSON shows code: 0 or ok: true.
Quick reference
| Flag / command | Purpose |
|---|---|
--json | Print structured JSON for scripting |
--download-dir | Download result files to a directory |
meitu --help | List all commands |
meitu <command> --help | Show 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.