### Install meitu-cli and check version Source: https://meituhub.com/docs?f_id=1&id=48 Installs the meitu-cli globally via npm and verifies the installation. If 'meitu: command not found' appears, close and reopen the terminal (global install only). ```bash npm install -g meitu-cli meitu --version ``` -------------------------------- ### Install meitu-cli and meitu globally Source: https://meituhub.com/docs?f_id=1&id=150 Installs the meitu-cli and meitu packages globally via npm. If the 'meitu' command is not found after installation, reopen the terminal and try again (applies to global installs). ```bash npm install -g meitu-cli meitu ``` -------------------------------- ### Configure credentials with npx Source: https://meituhub.com/docs?f_id=1&id=150 Alternative to local config when using npx. Runs the same config commands via npx with the -y flag to auto-confirm installation. ```bash npx -y meitu-cli config set-ak --value npx -y meitu-cli config set-sk --value ``` -------------------------------- ### GET /api/v1/sdk/status?task_id={task_id} Source: https://meituhub.com/docs?f_id=11&id=179 Queries the status of a task in the cloud using the provided task ID. Returns the task status, progress, and result URLs if completed. ```APIDOC ## GET /api/v1/sdk/status?task_id={task_id} ### Description Queries the status of a task in the cloud. The task ID is required, and the response includes the current status, progress, and result URLs if the task completed successfully. ### Method GET ### Endpoint https://openapi.meitu.com/api/v1/sdk/status?task_id={task_id} ### Parameters #### Query Parameters - **task_id** (string) - Required - Task ID - **context** (string) - Optional - Client context information. Format: `v1:base64(data)`, where `v1` is the version number. In v1, `data` is defined in JSON format. ### Request Example ``` taskid example: t_mt1a3i5n7baf2b7e89-7f37-47a9-9085-9b406263c260 ``` ### Response #### Success Response (200) - **data** (Object) - Returned content - **message** (String) - Error message - **code** (Number) - Error code Field descriptions for an individual element in `data`: - **status** (Number) - Status code: `-1` = task not found, `0` = task created successfully, `1` = task in progress, `2` = task failed, `10` = task completed successfully. - **msg** (String) - Description of multimedia file-related attribute information - **result** (Object) - Result - **progress** (Number) - Task progress, for example: `0.1`, `0.85`, `1`. Field descriptions for an individual element in `data.result`: - **id** (String) - Task ID - **urls** (String[]) - Image URLs #### Response Example ```json { "code": 0, "message":"", "data": { "status": 10, "result": { "id": "50309bd5-a827-4125-bc96-62039c93770b", "urls": ["https: //obs.mtlab.meitu.com/mtopen/rF5GIhp5ReLKgLV91CKj5BO1q2FTLMmc/MTY5Mjg1MzIwMA==/1c39ef92-04f1-40b4-5b7e-8fcfca0c11ea.png"] }, "progress": 1 } } ``` #### Failed Response (400) - **data** (String) - Returned content - **message** (String) - Error message - **code** (Int) - Error code #### Response Example ```json { "code": 20008, "message": "UNSUITABLE_IMAGE", "data": null } ``` ``` -------------------------------- ### Create output directory Source: https://meituhub.com/docs?f_id=1&id=48 Creates the output directory for downloaded files. On Windows, use 'New-Item -ItemType Directory -Force .\output' instead. ```bash mkdir -p ./output ``` -------------------------------- ### Configure Access Key and Secret Key locally Source: https://meituhub.com/docs?f_id=1&id=150 Sets the Access Key and Secret Key in the local configuration file. Replace and with your actual keys from MeituHub. ```bash meitu config set-ak --value meitu config set-sk --value ``` -------------------------------- ### Generate an image with text-to-image Source: https://meituhub.com/docs?f_id=1&id=150 Creates an output directory and runs the text-to-image command with a prompt, size 2K, JSON output, and download directory. Success is indicated by an image file in the output directory and JSON containing 'code: 0' or 'ok: true'. ```bash mkdir -p ./output meitu text-to-image \ --prompt "a simple illustration of an orange cat" \ --size 2K \ --json \ --download-dir ./output ``` -------------------------------- ### Sync command metadata Source: https://meituhub.com/docs?f_id=1&id=150 Recommended on first use to sync the command metadata for the meitu CLI. ```bash meitu tools update ``` -------------------------------- ### Run text-to-image command Source: https://meituhub.com/docs?f_id=1&id=48 Generates an image from a text prompt. On success, an image file appears under 'output' and the JSON shows 'code: 0' or 'ok: true'. ```bash meitu text-to-image \ --prompt "An orange cat, minimalist flat illustration" \ --size 2K \ --json \ --download-dir ./output ``` -------------------------------- ### Create output directory on Windows PowerShell Source: https://meituhub.com/docs?f_id=1&id=48 Alternative to 'mkdir -p ./output' for Windows PowerShell. Creates the output folder. ```powershell New-Item -ItemType Directory -Force .\output ``` -------------------------------- ### Set credentials via environment variables Source: https://meituhub.com/docs?f_id=1&id=150 Sets the Access Key and Secret Key as environment variables. These take priority over the local config file and are useful for CI/agent environments. ```bash export MEITU_OPENAPI_ACCESS_KEY="" export MEITU_OPENAPI_SECRET_KEY="" ``` -------------------------------- ### Verify credentials with meitu auth verify Source: https://meituhub.com/docs?f_id=1&id=150 Checks if the configured credentials are valid. A result of 'code: 0' or 'ok: true' indicates success. If it fails, ensure the keys were copied in full without leading or trailing spaces. ```bash meitu auth verify --json ``` -------------------------------- ### Set environment variables on Windows PowerShell Source: https://meituhub.com/docs?f_id=1&id=48 Sets the Access Key and Secret Key as environment variables in PowerShell. These take precedence over the local file. ```powershell $env:MEITU_OPENAPI_ACCESS_KEY = "" $env:MEITU_OPENAPI_SECRET_KEY = "" ``` -------------------------------- ### Audio/Video Decoding Error Codes Source: https://meituhub.com/docs?f_id=11&id=178 Error codes related to decoding images, videos, and audio, covering format, size, channel, and decoder creation issues. ```APIDOC ## Audio/Video Decoding Error Codes ### Error Codes | ErrorCode | Error Message | Description | | --- | --- | --- | | 23101 | IMAGE_DECODE_ERROR | Image decoding error | | 23102 | IMAGE_DECODE_FORMAT_ERROR | Image format error | | 23103 | IMAGE_DECODE_SIZE_ERROR | Image size error | | 23104 | IMAGE_DECODE_CHANNEL_ERROR | Image channel error | | 23201 | VIDEO_DECODE_DECODE_ERROR | Video decoding error | | 23202 | VIDEO_DECODE_FORMAT_ERROR | Video format error | | 23203 | VIDEO_DECODE_SIZE_ERROR | Video size error | | 23204 | VIDEO_DECODE_CHANNEL_ERROR | Video channel error | | 23205 | - | Video decoder creation error | | 23206 | - | Video surface converter creation error | | 23207 | - | Video frame-to-surface conversion error | | 23301 | AUDIO_DECODE_ERROR | Audio decoding error | | 23302 | AUDIO_DECODE_FORMAT_ERROR | Audio format error | | 23303 | AUDIO_DECODE_SIZE_ERROR | Audio size error | | 23304 | AUDIO_DECODE_CHANNEL_ERROR | Audio channel error | ``` -------------------------------- ### Audio/Video Encoding Error Codes Source: https://meituhub.com/docs?f_id=11&id=178 Error codes related to encoding images, videos, and audio, covering format, size, channel, and encoder creation issues. ```APIDOC ## Audio/Video Encoding Error Codes ### Error Codes | ErrorCode | Error Message | Description | | --- | --- | --- | | 24101 | IMAGE_ENCODE_ERROR | Image encoding error | | 24102 | IMAGE_ENCODE_FORMAT_ERROR | Image format error | | 24103 | IMAGE_ENCODE_SIZE_ERROR | Image size error | | 24104 | IMAGE_ENCODE_CHANNEL_ERROR | Image channel error | | 24201 | VIDEO_ENCODE_ERROR | Video encoding error | | 24202 | VIDEO_ENCODE_FORMAT_ERROR | Video format error | | 24203 | VIDEO_ENCODE_SIZE_ERROR | Video size error | | 24204 | VIDEO_ENCODE_CHANNEL_ERROR | Video channel error | | 24205 | - | Video encoder creation error | | 24206 | - | Video encoding frame release error | | 24207 | - | Video encoding frame allocation error | | 24208 | - | Surface-to-video-frame conversion error | | 24301 | AUDIO_ENCODE_ERROR | Audio encoding error | | 24302 | AUDIO_ENCODE_FORMAT_ERROR | Audio format error | | 24303 | AUDIO_ENCODE_SIZE_ERROR | Audio size error | | 24304 | AUDIO_ENCODE_CHANNEL_ERROR | Audio channel error | ``` -------------------------------- ### HTTP Status Codes Source: https://meituhub.com/docs?f_id=11&id=178 Lists the HTTP status codes returned by the API, including their error messages and descriptions. ```APIDOC ## HTTP Status Codes ### Description Lists the HTTP status codes returned by the API, including their error messages and descriptions. ### Status Codes | Status Code | Error Message | Description | | --- | --- | --- | | 200 | Successful Request | Successful request | | 400 | Bad Request | Invalid request, typically caused by issues such as an image not meeting the required specifications. For details, see [Algorithm Error Codes](https://meituhub.com/docs?f_id=11&id=178#jump) | | 401 | Authentication Failed | Authentication failed. If this error occurs, verify that your AK/SK credentials are correct | | 403 | Authentication Failed | Authentication failed. If this error occurs, verify whether your application has expired | | 404 | Invalid API Endpoint | The requested API endpoint address is incorrect. Verify that the request endpoint address is correct | | 415 | Internal Algorithm Exception | An internal algorithm exception occurred. Please try again later | | 424 | Image Download Failed | Failed to download the image. Verify that the image URL you are using can be accessed and downloaded normally | | 429 | QPS Limit Exceeded | Verify whether the current QPS is abnormal. If you require a higher QPS limit, please contact Sales to purchase additional capacity | | 433 | Request Entity Too Large | The request entity is too large. Check whether your image exceeds the API limit | | 500 | Request Exception | An internal request exception occurred. Please try again later | | 502 | No Response | No response was received for the request. Please try again later | | 503 | Concurrency Too High | Request concurrency exceeds the limit | | 504 | Request Exception | An internal request exception occurred. Please try again later | | 599 | Request Timeout | The request timed out. Please try again later | ``` -------------------------------- ### Gateway Error Codes Source: https://meituhub.com/docs?f_id=11&id=178 Lists the gateway error codes returned by the API, including their error messages and descriptions. ```APIDOC ## Gateway Error Codes ### Description Lists the gateway error codes returned by the API, including their error messages and descriptions. ### Error Codes | ErrorCode | Error Message | Description | | --- | --- | --- | | 80001 | RIGHTS_LIMIT_EXCEEDED | Entitlement usage limit exceeded | | 80002 | ORDER_LIMIT_EXCEEDED | Order usage count limit exceeded | | 80999 | RIGHTS_UNKNOW_ERROR | `err` information: unknown entitlement-related error | | 90000 | GATEWAY_INVALID_PARAMETER | Invalid input parameter; parameter binding failed | | 90001 | GATEWAY_PARAMETER_ERROR | Invalid input parameter value; error caused by operations on the input parameter | | 90002 | GATEWAY_AUTHORIZED_ERROR | Authentication error | | 90003 | GATEWAY_AUTHORIZED_NOT_MATCH | Authentication mismatch | | 90004 | GATEWAY_INVALID_FORMFILE | Invalid form file; form file extraction failed | | 90005 | GATEWAY_AUTHORIZED_NOT_ACCEPTABLE | Authentication unavailable | | 90006 | GATEWAY_FORMAT_HEADERS_ERROR | Exception while formatting headers | | 90007 | GATEWAY_FORMAT_BODY_ERROR | Exception while formatting the body | | 90008 | GATEWAY_FORMAT_PARAMS_ERROR | Exception while formatting parameters | | 90009 | GATEWAY_TIMEOUT | Request timeout | | 90010 | GATEWAY_JSON_MARSHAL_ERROR | JSON encoding error | | 90011 | GATEWAY_JSON_UNMARSHAL_ERROR | JSON decoding error | | 90012 | GATEWAY_BASE64_ENCODE_ERROR | Base64 encoding error | | 90013 | GATEWAY_BASE64_DECODE_ERROR | Base64 decoding error | | 90014 | GATEWAY_NOT_FOUND | Data not found | | 90015 | GATEWAY_FOUND_ERROR | Data query exception | | 90016 | GATEWAY_PUSH_QUEUE_ERROR | Queue push exception | | 90017 | GATEWAY_GET_BODY_ERROR | Exception while reading the body | | 90020 | GATEWAY_REQUEST_FORWARD_ERROR | Exception while processing the algorithm request | | 90021 | GATEWAY_FORWARD_RESPONSE_ERROR | Exception while processing the algorithm response | | 90022 | GATEWAY_ALGORITHM_DISABLE | Algorithm unavailable | | 90023 | GATEWAY_QUEUE_RESPONSE_ERROR | Algorithm queue response exception | | 90024 | GATEWAY_QPS_LIMIT | Current QPS limit exceeded | | 90099 | GATEWAY_UNKNOWN_ERROR | Unknown error | ``` -------------------------------- ### Asynchronous Algorithm-Specific Error Codes Source: https://meituhub.com/docs?f_id=11&id=178 Error codes returned by asynchronous algorithm operations, including success, record not found, processing in progress, timeout, image processing failure, concurrency limit, internal error, empty response, and unknown error. ```APIDOC ## Asynchronous Algorithm-Specific Error Codes ### Error Codes | ErrorCode | Error Message | Description | | --- | --- | --- | | 0 | SUCCESS | Success | | 29900 | RECORD_NOT_FOUND | Specified record not found | | 29901 | NOT_RESULT | The algorithm is processing. Please try again later | | 29902 | TIMEOUT_EXCEPTION | Timeout exception handling | | 29903 | PROCESS_IMAGE_ERROR | Image processing or upload failed | | 29904 | ALGORITHM_OVER_CONCURRENT | Algorithm concurrency limit exceeded | | 29905 | ALGORITHM_INNER_ERROR | Internal algorithm error | | 29915 | RESPONSE_EMPTY | Algorithm processing failed | | 29950 | UNKNOW_ERROR | Unknown error | ``` -------------------------------- ### External-Cause Error Codes Source: https://meituhub.com/docs?f_id=11&id=178 Error codes caused by external factors such as invalid parameters, network issues, file operations, and upload/download failures. ```APIDOC ## External-Cause Error Codes ### Error Codes | ErrorCode | Error Message | Description | | --- | --- | --- | | 21101 | PARAM_ERROR | Parameter error | | 21102 | PARAM_MISSING_ERROR | Missing parameter | | 21103 | PARAM_TYPE_ERROR | Parameter type error | | 21104 | PARAM_VALUE_ERROR | Parameter value error | | 21105 | PARAM_JSON_DECODE_ERROR | Parameter value error | | 21201 | DOWNLOAD_TIMEOUT_ERROR | File download timeout | | 21202 | INVALID_URL_ERROR | Invalid URL | | 21203 | FILE_NOT_EXIST_ERROR | Invalid file | | 21204 | NETWORK_ERROR | Network error | | 21205 | DOWNLOAD_UNKNOWN_ERROR | Download error | | 22101 | SAVE_ERROR | Save error | | 22102 | SAVE_PATH_ERROR | Save path error | | 22103 | SAVE_FORMAT_ERROR | Save format error | | 22201 | UPLOAD_ERROR | Upload error | | 22202 | UPLOAD_PATH_ERROR | Upload path error | | 22203 | UPLOAD_FILE_TOO_LARGE_ERROR | Uploaded file is too large | | 22204 | UPLOAD_TIMEOUT_ERROR | File upload timeout | | 22301 | DELETE_FILE_ERROR | Delete error | ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.