This topic describes how to use the SDKs that Alibaba Cloud Content Moderation provides in different development languages for you to call the Content Moderation API.

SDK usage notes

Before you use the SDKs, read the corresponding documentation to understand the feature of each Content Moderation API. For more information, see List of operations by function.

  • In the SDKs, we encapsulate the image moderation features, such as pornography detection, terrorist content detection, Optical Character Recognition (OCR), and logo detection, into one API. This API provides the following operations for you to call:
    • ImageSyncScanRequest: a synchronous operation to moderate images. You can call this operation to moderate multiple images at a time. The operation returns the moderation results of all images. If you want to moderate one image at a time, we recommend that you call this operation.
    • ImageAsyncScanRequest: an asynchronous operation to moderate images. You can call this operation to moderate multiple images at a time. If you submit multiple tasks to moderate multiple images, the operation returns a task ID for each image. You can use the task ID to poll the moderation result of each image. If you want to moderate multiple images at a time, we recommend that you call this operation.
  • In the SDKs, we encapsulate the video moderation features, such as pornography detection, terrorist content detection, and logo detection, into one API. This API provides the following operations for you to call:
    • VideoSyncScanRequest: a synchronous operation to moderate videos. To call this operation to moderate a video, you must convert the video to a sequence of image frames and submit the image frames for moderation. We recommend that you do not call this operation to moderate videos.
    • VideoAsyncScanRequest: an asynchronous operation to moderate videos. You can call this operation to submit either a video or a sequence of image frames captured from the video for moderation. After you submit a video moderation task, the operation returns a task ID for the task. You can use the task ID to poll the moderation result. Alternatively, you can configure a callback URL to receive a callback notification of the moderation result. We recommend that you call this operation to moderate videos.
  • Audio anti-spam: The SDKs can detect spam in audio streams and audio files. Currently, the SDKs provide only an asynchronous operation to moderate audio content. After you submit an audio moderation task, the operation returns a task ID for the task. You can use the task ID to poll the moderation result. Alternatively, you can configure a callback URL to receive a callback notification of the moderation result.
  • Text anti-spam: The SDKs provide only a synchronous operation to detect spam in text. You can send a request to moderate one or more text entries.
Note If you specify multiple moderation scenarios when you call an operation, such as an image moderation operation, the expenses of all scenarios are calculated separately and summed up. The expense of a scenario equals the product of the unit price in that scenario and the quantity of scanned content.

Before you begin

  • Content Moderation provides the following SDKs in three different languages:
  • Download the SDK sample code.

    Click green-sdk-sample_doc to download the SDK code sample.

    The sample code provides complete call examples of SDKs for Java, PHP, and Python.

  • Obtain third-party SDKs in other languages for reference.
    If you use a development language other than Java, PHP, or Python, we recommend that you directly send an HTTP request to call the corresponding Content Moderation API operation. We have also listed some content moderation SDKs compiled by third-party developers for your reference. The third-party SDKs are available in the following languages and version: C#, C++, Node.js, and Python 3.5. For more information, see SDKs in other languages.
    Note The third-party SDKs are only for your reference. Alibaba Cloud does not provide follow-up maintenance for the third-party SDKs.