Tencent Cloud TIAA SDK for Python

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

Tencent Cloud TIAA SDK for Python provides image analysis capabilities including image recognition, content moderation, and image search. Current version 3.1.69. Releases follow TencentCloud SDK release cadence with occasional breaking changes due to API updates.

pip install tencentcloud-sdk-python-tiia
error ImportError: cannot import name 'TiiaClient' from 'tencentcloud.tiia.v20190529.tiia_client'
cause Incorrect import path. The client is inside 'tiia_client' module.
fix
Use 'from tencentcloud.tiia.v20190529 import tiia_client' and then instantiate 'tiia_client.TiiaClient()'.
error TencentCloudSDKException: [TencentCloudSDKException] code: UnsupportedOperation, message: this action is not supported in this region
cause The TIAA service is not available in the selected region (e.g., ap-shanghai).
fix
Use a supported region like 'ap-guangzhou' or check TIAA region availability.
error AttributeError: module 'tencentcloud.tiia.v20190529' has no attribute 'models'
cause Forgot to import models separately.
fix
Add 'from tencentcloud.tiia.v20190529 import models'.
error TypeError: __init__() missing 2 required positional arguments: 'secret_id' and 'secret_key'
cause Credentials not provided or missing from environment.
fix
Set 'TENCENTCLOUD_SECRET_ID' and 'TENCENTCLOUD_SECRET_KEY' environment variables, or pass them directly to Credential() constructor.
gotcha Always specify the API version (v20190529) in imports. Many examples omit it, causing ImportError.
fix Use 'from tencentcloud.tiia.v20190529 import tiia_client' instead of 'from tencentcloud.tiia import tiia_client'.
breaking In version 3.x, the client class name changed from 'TiiaClient' to 'tiia_client.TiiaClient' due to automatic code generation. Older code using 'TiiaClient' directly may break if package structure changes.
fix Import as 'from tencentcloud.tiia.v20190529 import tiia_client' and use 'tiia_client.TiiaClient'.
deprecated Some old methods (e.g., 'DetectCelebrity') are deprecated. Check the official API documentation for current methods.
fix Use new method names as per API docs (e.g., 'RecognizeImage' instead of 'DetectCelebrity').
gotcha The environment variables for credentials are 'TENCENTCLOUD_SECRET_ID' and 'TENCENTCLOUD_SECRET_KEY', not 'SECRET_ID' or others. Common mistake leads to auth failure.
fix Set environment variables with correct names.

Instantiates a TIAA client with credentials from environment variables and calls AssessQuality on an image URL.

import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.tiia.v20190529 import tiia_client, models

secret_id = os.environ.get('TENCENTCLOUD_SECRET_ID', '')
secret_key = os.environ.get('TENCENTCLOUD_SECRET_KEY', '')

cred = credential.Credential(secret_id, secret_key)
client = tiia_client.TiiaClient(cred, "ap-guangzhou")

req = models.AssessQualityRequest()
req.ImageUrl = "https://example.com/image.jpg"

try:
    resp = client.AssessQuality(req)
    print(resp.to_json_string())
except TencentCloudSDKException as e:
    print(e)