TencentCloud SDK for Python - VMS

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

The Tencent Cloud Voice Message Service (VMS) SDK for Python allows developers to integrate voice notification and verification capabilities. Current version 3.0.1459, updated frequently as part of the TencentCloud unified Python SDK.

pip install tencentcloud-sdk-python-vms
error ModuleNotFoundError: No module named 'tencentcloud.vms'
cause The SDK is separated into multiple packages. Installing the parent tencentcloud-sdk-python does not include all services.
fix
pip install tencentcloud-sdk-python-vms
error AttributeError: module 'tencentcloud.vms' has no attribute 'v20200902'
cause The package may not be installed or the import path is incorrect.
fix
Ensure you installed tencentcloud-sdk-python-vms and import using 'from tencentcloud.vms.v20200902 import vms_client'.
gotcha The VMS SDK uses a versioned subpackage (v20200902). Ensure you import from the correct API version.
fix Use 'from tencentcloud.vms.v20200902 import vms_client, models' instead of non-versioned imports.
gotcha The client constructor requires a region parameter, even if not all APIs use it. Missing region may cause errors.
fix Always pass a region string like 'ap-guangzhou' or your nearest region.

Sends a voice verification code using environment variables for credentials.

from tencentcloud.common import credential
from tencentcloud.vms.v20200902 import vms_client, models

cred = credential.Credential(
    os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
    os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = vms_client.VmsClient(cred, "ap-guangzhou")
req = models.SendCodeVoiceRequest()
req.CodeMessage = "123456"
req.CalledNumber = "+861234567890"
resp = client.SendCodeVoice(req)
print(resp.RequestId)