Scans text synchronously for pornography, advertising, spam, political content, abuse, and other violations.
Usage notes
Operation: /green/text/scan
Submit text moderation tasks through this endpoint. Construct HTTP requests as described in Request syntax, or use an SDK (SDK overview).
By default, this operation moderates Chinese text. To moderate other languages (English, French, German, Indonesian, Malaysian, Portuguese, Spanish, Thai, Vietnamese, Japanese, Arabic, Filipino, Hindi, Turkish, Russian, Italian, Dutch), contact your account manager.
Billing
This operation incurs charges. AI Guardrails Pricing.
QPS limit
Maximum: 100 calls per second per account. Exceeding this limit triggers throttling, which may affect your business.
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| bizType | String | No | default | The business scenario. Create business scenarios in the AI Guardrails console (Customize policies for machine-assisted moderation). |
| scenes | StringArray | Yes | ["antispam"] | The moderation scenario. Set to antispam for text moderation. |
| tasks | JSONArray | Yes | Text entries to moderate. Maximum: 100 elements per request, each structured as a task object (see the following table). To increase the concurrency limit, contact your account manager. |
task
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| clientInfo | JSONObject | No | Client information, as described in the "Common request parameters" section of Common parameters. Task-level clientInfo takes priority over the global clientInfo parameter. |
|
| dataId | String | No | cfd33235-71a4-468b-8137-a5ffe323\*\*\*\* | A unique identifier for the moderated object. Accepts letters, digits, underscores (\_), hyphens (-), and periods (.). Maximum length: 128 characters. |
| content | String | Yes | We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. | The text to moderate. Maximum length: 10,000 characters, including punctuation. |
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| code | Integer | 200 | HTTP status code. Common error codes. |
| msg | String | OK | The response message. |
| dataId | String | cfd33235-71a4-468b-8137-a5ffe323\*\*\*\* | The ID of the moderated object. Returned only if dataId was set in the request. |
| taskId | String | txt6HB8NQoEbU@5fosnj2xVEM-1t\*\*\*\* | The moderation task ID. |
| content | String | We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone. | The original text submitted in the request. |
| filteredContent | String | We are a \*\*\*\* company that provides an \*\*\* loan on the same day with reliable, fast, convenient, and \*\*\*\* services when you apply for a loan on your mobile phone. | The text with matched custom terms replaced by asterisks (\*). Customize terms through the CreateKeywordLib API or the AI Guardrails console (Manage custom text libraries). |
| results | JSONArray | The moderation results. On success (HTTP 200), returns an array of result objects (see the following table). |
result
| Parameter | Type | Example | Description |
|---|---|---|---|
| scene | String | antispam | The moderation scenario specified in the request. |
| suggestion | String | block | The recommended action. Valid values: pass (text is normal), review (text requires human review), block (text contains violations and can be deleted or blocked). |
| label | String | porn | The content category. Valid values: normal (normal content), spam (junk content), ad (advertising content), politics (political content), terrorism (terrorist content), abuse (abusive content), porn (pornographic content), flood (excessive junk content), contraband (prohibited content), meaningless (meaningless content), harmful (harmful content, including content related to mammonism, wealth flaunting, blind worshiping of idols, disruptive emotion, and negative enticing), customized (custom content, such as a custom term). |
| rate | Float | 99.91 | Confidence score from 0 to 100. When suggestion is pass, higher scores indicate more likely normal content. When suggestion is review or block, higher scores indicate more likely violations. Use suggestion, label, and sublabel to determine violations. sublabel is returned by specific operations. |
| extras | JSONObject | {"userId":"xxx"} | Additional information (extended parameter). |
| details | JSONArray | Details of the risky content detected. A text entry can match multiple risk categories. Each element is a detail object (see the following table). |
detail
| Parameter | Type | Example | Description |
|---|---|---|---|
| label | String | porn | The risk category of matched content. Valid values: spam (junk content), ad (advertising content), politics (political content), terrorism (terrorist content), abuse (abusive content), porn (pornographic content), flood (excessive junk content), contraband (prohibited content), meaningless (meaningless content), harmful (harmful content, including content related to mammonism, wealth flaunting, blind worshiping of idols, disruptive emotion, and negative enticing), customized (custom content, such as a custom term). |
| contexts | JSONArray | Context information for the matched risky content. Each element is a context object (see the following table). |
context
| Parameter | Type | Example | Description |
|---|---|---|---|
| context | String | door-to-door | The matched term. Returned only for term-based matches, not algorithmic model matches. |
| positions | JSONArray | [{"startPos":1, "endPos":10}] | The position of the matched term in the original text. |
| libName | String | Name of your custom text library | The name of the custom text library. Returned only when the text matches a term in a custom text library. |
| libCode | String | 123456 | The code of the custom text library. Returned only when the text matches a term in a custom text library. |
| ruleType | String | ip | The behavior rule type. Returned only when the text matches a behavior rule. Valid values: user_id, ip, umid, content, similar_content, imei, imsi. |
Examples
Sample request
http(s)://[Endpoint]/green/text/scan
&<Common request parameters>{
"scenes": [
"antispam"
],
"tasks": [
{
"dataId": "cfd33235-71a4-468b-8137-a5ffe323****",
"content": "We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone."
}
]
}
Sample response
{
"code": 200,
"data": [
{
"code": 200,
"content": "We are a micro-lending company that provides an unsecured loan on the same day with reliable, fast, convenient, and door-to-door services when you apply for a loan on your mobile phone.",
"dataId": "cfd33235-71a4-468b-8137-a5ffe323****",
"filteredContent": "We are a **** company that provides an *** loan on the same day with reliable, fast, convenient, and **** services when you apply for a loan on your mobile phone.",
"msg": "OK",
"results": [
{
"details": [
{
"contexts": [
{
"context": "unsecured",
"positions": [
{
"endPos": 19,
"startPos": 16
}
]
},
{
"context": "micro-lending",
"positions": [
{
"endPos": 6,
"startPos": 2
}
]
}
],
"label": "spam"
},
{
"contexts": [
{
"context": "door-to-door",
"libCode": "123456",
"libName": "Name of your custom text library",
"positions": [
{
"endPos": 34,
"startPos": 30
}
]
}
],
"label": "porn"
}
],
"label": "porn",
"rate": 99.91,
"scene": "antispam",
"suggestion": "block"
}
],
"taskId": "txt6HB8NQoEbU@5fosnj2xVEM-1t****"
}
],
"msg": "OK",
"requestId": "25711794-BF6D-4F32-A735-09CA21197D32"
}
该文章对您有帮助吗?