Skip to main content

Document content moderation

This topic describes the request syntax and provides examples for the Tongyi ZoneWit document content moderation API.

Request syntax

POST /zhiwen-chat/audit HTTP/1.1

Request parameters

Name

Type

Required

Description

Example

capabilityType

string

Yes

The capability type.

Content moderation for documents: CONTENT_REVIEW

CONTENT_REVIEW

userPrompt

string

Yes

The prompt.

You are an experienced senior document review expert, proficient in fraud detection, compliance checks, fact-checking, and professional communication. Your review standards are extremely strict, detail-oriented, and you provide constructive revision suggestions. Your task is to conduct a comprehensive and in-depth review of the provided document. Identify all issues within the document and generate a structured review report.

fileIdList

array

Yes

The list of document IDs.

[

"file_zhiwen_XXX"

]

stream

boolean

Yes

Specifies whether to return the response in a stream.

true

Response parameters

Name

Type

Description

output

object

-choices

array

-finishReason

string

Termination reason

-message

object

The message body.

-role

string

The role.

-content

string

The message content.

requestId

string

The request ID.

usage

object

The token usage information.

-inputTokens

int

The number of input tokens.

-outputTokens

int

The number of output tokens.

-totalTokens

int

The total number of tokens.

Examples

Request example

import os
import requests

'''
API name: Content Moderation
API path: https://dashscope.aliyuncs.com/api/v2/apps/zhiwen-chat/audit
Environment requirements: Python >= 3.7
'''

url = "https://dashscope.aliyuncs.com/api/v2/apps/zhiwen-chat/audit"
request_headers = {
    "Authorization": os.environ.get("DASHSCOPE_API_KEY"),  # If you have not configured the environment variable, replace your API-KEY here.
    "Content-Type": "application/json"
}
# Content moderation: CONTENT_REVIEW
request_body = {
    "capabilityType": "CONTENT_REVIEW",
    "userPrompt": "You are an experienced senior document review expert, proficient in fraud detection, compliance checks, fact-checking, and professional communication. Your review standards are extremely strict, detail-oriented, and you provide constructive revision suggestions. Your task is to conduct a comprehensive and in-depth review of the provided document. Identify all issues within the document and generate a structured review report.",
    "stream": True,
    "fileIdList": [
        "file_zhiwen_XXX"  # Replace with your document ID.
    ]
}

with requests.post(url, json=request_body, headers=request_headers) as response:
    if request_body["stream"]:
        for line in response.iter_lines():
            if line:
                line = line.decode('utf-8')
                if line.startswith('data:'):
                    print("Received:", line[5:].strip())
    else:
        print("Received:", response.json())

Successful response example

JSON format
{
  "output": {
    "choices": [{
      "finishReason": "stop",
      "message": {
        "role": "assistant",
        "content": "**Document Review Report: XXX.pdf**\nDocument content moderation results.\n**Note**: This report is generated based on the provided text. The actual review may require further refinement based on the complete document and its context."
      }
    }]
  },
  "requestId": "08bd24d4-6c85-9b2e-9ead-c9480b4b1651",
  "usage": {
    "inputTokens": 100,
    "outputTokens": 100,
    "totalTokens": 200
  }
}

Error codes

For more information, see Error codes for Tongyi ZoneWit.
Agent Development
Agent Context
Agent Governance & Evolution
Store
Application Marketplace