Python SDK quick start

This page removes a watermark from an image with the SDK. After you install it and set your API keys, run either the Python or the CLI example. You need Python 3.9 or later and a test image. The shell commands below work on macOS and Linux.

1. Download the ZIP and install the SDK

Download the Vmake Labs Python SDK v2.0.3 (ZIP), or download and extract it in a terminal:

curl -fL -o vmake-sdk.zip "https://kapkap-common.stariidata.com/apk/6b06cf15693834304TYTssZLmW4966.zip"
unzip vmake-sdk.zip
cd vmake-2.0.3-*/

Create a virtual environment in the extracted directory and install the .whl file. If you use other builds of action-api-sdk, install each one in its own virtual environment.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install ./action_api_sdk-2.0.3-py3-none-any.whl
python -c "from action_api_sdk import SkillClient; print(SkillClient.__name__)"
action-api-sdk --help

If you see SkillClient and the command help, both the Python module and the CLI are installed. Run the following examples in the same virtual environment.

2. Set your API keys

Create a key pair on the API keys page of the Vmake Labs developer center. Put the Access Key in MT_AK and the Secret Key in MT_SK.

export MT_AK="your_access_key"
export MT_SK="your_secret_key"

You can also copy .env.example in the extracted directory to .env, fill in the same two variables, and run your Python scripts or the CLI from that directory. Keep the .env file that holds your keys out of version control.

3. Run your first task

Python
CLI

List image tools

from action_api_sdk import SkillClient

client = SkillClient()
for tool in client.get_task_catalog()["entries"]:
    if tool["media_type"] == "image":
        print(tool["material_id"], tool["name"])

Submit an image and read the result

Keep using client in the same script. Check that the catalog includes SKM0006, and replace the path with your test image. run_task uploads the image and consumes quota according to the task rules.

result = client.run_task(
    task_name="SKM0006",
    image_path="./input.jpg",
    params={"parameter": {"rsp_media_type": "url"}},
    on_async_submitted=lambda task_id: print("task_id:", task_id),
)
print(result)

The method returns the raw tool response. When the task completes, read the output from data.result. on_async_submitted receives the task_id of an asynchronous task before polling starts. If run_task returns None because polling ended without a final status, continue with client.poll_task_status(task_id).

The SDK polls at the intervals the server provides. If those intervals add up to less than 60 minutes, the SDK repeats the last interval until they do. The default interval is 60 seconds.

Troubleshooting

Set WAPI_DEBUG=1 to see sanitized request details from the CLI. Check the headers and body before you share logs.

ProblemWhat to do
action-api-sdk command not foundActivate the virtual environment you installed into, then run python -m action_api_sdk.cli --help to check the installation
--ak and --sk requiredSet MT_AK and MT_SK in the terminal that runs the CLI, or check the .env file in the current directory
config_unavailableThe config request failed. Check code and message in the response
quota_errorCheck tool access or remaining quota using code and message in the response