Tencent Cloud SDK for Python - TICM

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

Tencent Cloud Image Content Moderation (TICM) SDK for Python. Provides image moderation APIs. Latest version: 3.0.1416. Released weekly or on-demand.

pip install tencentcloud-sdk-python-ticm
error ModuleNotFoundError: No module named 'tencentcloud.ticm'
cause Trying to use tencentcloud-sdk-python-ticm without installing it, or incorrect import path.
fix
Run 'pip install tencentcloud-sdk-python-ticm'. Then import from tencentcloud.ticm.v20181127.
error AttributeError: module 'tencentcloud.ticm.v20181127' has no attribute 'TicmClient'
cause Importing the module directly instead of the class from the module.
fix
Use 'from tencentcloud.ticm.v20181127 import ticm_client' then ticm_client.TicmClient.
gotcha All imports must use versioned subpackage. tencentcloud.ticm is not the correct import path.
fix Use from tencentcloud.ticm.v20181127 import ...
breaking Python 2 is not supported and imports may fail if using old Python 2 syntax.
fix Use Python 3.6 or later.
breaking Region argument is required when initializing clients, no longer optional.
fix Always pass a region like 'ap-guangzhou' to client constructor.

Initializes client and calls ImageModeration. Set SECRET_ID and SECRET_KEY env vars.

from tencentcloud.ticm.v20181127 import ticm_client, models
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException

try:
    cred = credential.Credential(SecretId=os.environ.get('SECRET_ID', ''), SecretKey=os.environ.get('SECRET_KEY', ''))
    client = ticm_client.TicmClient(cred, 'ap-guangzhou')
    req = models.ImageModerationRequest()
    req.FileUrl = 'https://example.com/image.jpg'
    resp = client.ImageModeration(req)
    print(resp.to_json_string())
except TencentCloudSDKException as err:
    print(err)