All Products
Search
Document Center

Content Moderation:SDK overview

Last Updated:Jun 24, 2024

This topic describes how to use the SDKs provided by Alibaba Cloud Content Moderation in different development languages for you to call the Content Moderation APIs.

SDK usage notes

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

  • In the SDKs, we expose the image moderation features, such as pornographic content detection, terrorist content detection, Optical Character Recognition (OCR), and logo detection, as one API. This API provides the following operations for you to call:

    • ImageSyncScanRequest operation: 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 in real time. We recommend that you call this operation to moderate one image each time.

    • ImageAsyncScanRequest operation: an asynchronous operation to moderate images. You can call this operation to moderate multiple images at a time. The operation returns a task ID for each image. You can use the task ID to obtain the moderation result of the corresponding image. If you want to moderate multiple images at a time, we recommend that you call this operation.

  • In the SDKs, we expose the video moderation features, such as pornography detection, terrorist content detection, and logo detection, as one API. This API provides the following operations for you to call:

    • VideoSyncScanRequest operation: 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 operation: 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 obtain 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 pieces of text.

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 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.

    Important

    APIs earlier than 2018-05-09 are discontinued. If you use a version earlier than 2018-05-09, the HTTP Code:400 , ErrorCode:InvalidAction.NotFound error is returned. In this case, replace the version with 2018-05-09.

  • Obtain third-party SDKs in other languages for reference.

    If you use a development language other than Java, PHP, Python, Go, and .NET, 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: 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 them.