Skip to main content

Meitu OpenAPI command-line tool.

Project description

Meitu CLI

meitu is now a Python CLI for Meitu OpenAPI image tasks. It is the main runtime used by the skills in this repository.

It supports:

  • local or environment-based credential loading
  • auth verify
  • generate for image effect calls
  • automatic task polling
  • result download with --download-dir
  • local file upload through the strategy service

Install

Recommended for external CLI users:

pipx install meitu-ai

For local repository usage before the package is published:

cd /Users/lichao/openapi-cli/cli
pipx install .

Alternative for virtual environments or advanced users:

cd /Users/lichao/openapi-cli/cli
pip install .

For local development:

cd /Users/lichao/openapi-cli/cli
make develop

That installs the package in editable mode and makes the meitu command available in the current Python environment.

Configure

You can save credentials locally:

meitu config set-ak --value your_access_key
meitu config set-sk --value your_secret_key

Or provide them through environment variables:

export OPENAPI_ACCESS_KEY=your_access_key
export OPENAPI_SECRET_KEY=your_secret_key
export OPENAPI_BASE_URL=openapi.meitu.com

Environment 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

OPENAPI_BASE_URL can be written as openapi.meitu.com; the CLI normalizes it to https://openapi.meitu.com.

Advanced Overrides

For normal external usage, you usually only need:

  • OPENAPI_ACCESS_KEY
  • OPENAPI_SECRET_KEY
  • OPENAPI_BASE_URL if you want to override the default API domain

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:

  • 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 OPENAPI_STRATEGY_BASE_URL=https://strategy.example.com

Usage

Verify credentials:

OPENAPI_BASE_URL=openapi.meitu.com meitu auth verify --json

Tool commands:

  • video-motion-transfer -> task /v1/openclaw/default/488175
  • image-edit -> task /v1/openclaw/default/488176
  • image-generate -> task /v1/openclaw/default/488177
  • image-upscale -> task /v1/openclaw/default/488178
  • image-virtual-tryon -> task /v1/openclaw/default/488184
  • image-to-video -> task /v1/openclaw/default/488185
  • image-face-swap -> task /v1/openclaw/default/488186
  • image-cutout -> task /v1/openclaw/default/488187

These commands all use the same fixed internal defaults:

  • task_type = formula
  • task mapping 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-virtual-tryon --help

Parameter wrapping rules:

  • values from parameter_input_alias are wrapped as {"parameter": {...}}
  • values from params_input_alias stay at the top level of params
  • 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 \
  --json

Run image generation with a remote image URL:

meitu image-generate \
  --image https://example.com/test.jpg \
  --prompt "make it cinematic" \
  --json

Run virtual try-on with the required media inputs:

meitu image-virtual-tryon \
  --clothes_image_url ./cloth.png \
  --person_image_url ./person.png \
  --replace upper \
  --need_sd 1 \
  --json

Advanced 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 \
  --json

Run 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 \
  --json

Run 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}}' \
  --json

Wait for an existing task manually:

meitu task wait t_xxx --download-dir ./outputs --json

Task Behavior

  • meitu generate automatically polls /api/v1/sdk/status when the create call returns a task_id
  • default polling interval: 1s
  • status = 0, 1, or 9 means the task is still running
  • status = 10 means the task succeeded
  • status = 2 means 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 /Users/lichao/openapi-cli/cli
make test
make package

make test runs a syntax smoke test and a basic CLI help check.

make package builds a Python source distribution and wheel. If python -m build is not installed yet, install it first with python3 -m pip install build.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meitu_ai-0.1.2.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meitu_ai-0.1.2-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file meitu_ai-0.1.2.tar.gz.

File metadata

  • Download URL: meitu_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for meitu_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d5edfff1da382c0bb6ce4798c246e3b5ff74b3195d4dad422eb73c22bdf55631
MD5 bc9f046d6982a73944c7801698586509
BLAKE2b-256 acd004d27953c4c23ccb4afdb000316b116bf457df8cfa52b3a8ea4dd2ff4c28

See more details on using hashes here.

File details

Details for the file meitu_ai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: meitu_ai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for meitu_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 39cb62ad9d87e3363700d5acbdfee406f35e6c7f8d2c1cbb2c7e65c5061ea42a
MD5 ab9f904f56eee86934d5d8b33ce21201
BLAKE2b-256 2f591693bcdb6907327bb630e8098e0b4e76ecda66cdbbe10906ef13f95b1fdd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page