Tencent Cloud VM SDK for Python

raw JSON →
3.1.67 verified Sat May 09 auth: no python

The Tencent Cloud VM (Video Moderation) SDK for Python enables integration with Tencent Cloud's content moderation services for video content. Current version 3.1.67. Release cadence is irregular, typically following Tencent Cloud API updates.

pip install tencentcloud-sdk-python-vm
error ModuleNotFoundError: No module named 'tencentcloud.vm'
cause Old import path used after version 3.x update.
fix
Use versioned import: from tencentcloud.vm.v20201229 import vm_client
error tencentcloud.common.exception.TencentCloudSDKException: [TencentCloudSDKException] code: UnsupportedRegion error: no available region
cause Region not set or invalid region.
fix
Pass a valid region (e.g., 'ap-guangzhou') to VmClient.
breaking Version 3.x uses new import paths (e.g., tencentcloud.vm.v20201229) instead of old 'tencentcloud.vm'.
fix Update imports to include the API version in the path.
gotcha Region must be set explicitly in client initialization; no default region.
fix Always pass a region string (e.g., 'ap-guangzhou') to VmClient.
gotcha The SDK requires the 'tencentcloud-sdk-python-common' package; missing it causes ImportError.
fix Install the common package: pip install tencentcloud-sdk-python-common

Initialize a VM client and create a video moderation task.

from tencentcloud.common import credential
from tencentcloud.vm.v20201229 import vm_client, models

def moderate_video():
    cred = credential.Credential(
        secret_id=os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
        secret_key=os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
    )
    client = vm_client.VmClient(cred, 'ap-guangzhou')
    req = models.CreateVideoModerationTaskRequest()
    req.Operator = 'user'
    req.BizType = ''
    req.Type = 'VIDEO'
    req.Tasks = [{'DataId': '123', 'Input': {'Url': 'https://example.com/video.mp4'}}]
    resp = client.CreateVideoModerationTask(req)
    return resp