AI Aliyun Content Moderation Configuration
Configuration reference for the AI Aliyun Content Moderation plugin (`ai-aliyun-content-moderation`): the parameters, each attribute with its type, whether it is required, its default and its accepted values.
Parameters
See plugin common configurations (opens in Apache APISIX docs) for configuration options available to all plugins.
access_key_id — string · required · since APISIX 3.14.0 · API7 Gateway 3.8.0
Aliyun access key ID.
access_key_secret — string · required · since APISIX 3.14.0 · API7 Gateway 3.8.0
Aliyun secret access key. The value is encrypted before being stored.
region_id — string · required · since APISIX 3.14.0 · API7 Gateway 3.8.0
Aliyun region ID.
endpoint — string · required · since APISIX 3.14.0 · API7 Gateway 3.8.0
Aliyun endpoint.
check_request — boolean · optional · default: true · since APISIX 3.14.0 · API7 Gateway 3.8.0
If true, moderate the request content.
check_response — boolean · optional · default: false · since APISIX 3.14.0 · API7 Gateway 3.8.0
If true, moderate non-streaming and streaming LLM response content according to stream_check_mode.
request_check_service — string · optional · default: llm_query_moderation · since APISIX 3.14.0 · API7 Gateway 3.8.0
Location where Aliyun should moderation the requests.
request_check_length_limit — number · optional · default: 2000 · since APISIX 3.14.0 · API7 Gateway 3.8.0
Request content length limit, in character count. If exceeded, the content will be sent in chunks.
For instance, if the request content has 250 characters and the request_check_length_limit is set to 100, then the content will be sent in 3 requests to Aliyun.
response_check_service — string · optional · default: llm_response_moderation · since APISIX 3.14.0 · API7 Gateway 3.8.0
Location where Aliyun should moderation the responses.
response_check_length_limit — number · optional · default: 5000 · since APISIX 3.14.0 · API7 Gateway 3.8.0
Response content length limit, in character count. If exceeded, the content will be sent in chunks.
For instance, if the response content has 250 characters and the response_check_length_limit is set to 100, then the content will be sent in 3 requests to Aliyun.
risk_level_bar — string · optional · default: high · since APISIX 3.14.0 · API7 Gateway 3.8.0
Valid values: none, low, medium, high, or max
If the evaluated risk level is lower than the risk_level_bar, the request/response will be passed through to upstream LLM / client respectively.
deny_code — integer · optional · default: 200 · since APISIX 3.14.0 · API7 Gateway 3.8.0
Valid values: between 200 and 599 inclusive
HTTP status returned when content is denied before response headers are sent. The default 200 returns a provider-compatible refusal; set a 4xx value to expose moderation as an HTTP error. After streaming starts, the status cannot be changed.
deny_message — string · optional · since APISIX 3.14.0 · API7 Gateway 3.8.0
Message returned when request or response content is denied. If unset, the plugin uses Aliyun's moderation advice.
timeout — integer · optional · default: 10000 · since APISIX 3.14.0 · API7 Gateway 3.8.0
Valid values: greater than or equal to 1
Timeout in milliseconds.
stream_check_mode — string · optional · default: final_packet · since APISIX 3.14.0 · API7 Gateway 3.8.0
Valid values: realtime or final_packet
Streaming check mode, which specifies how to handle content moderation for streaming (SSE) responses.
realtime performs incremental, batched moderation checks while the response is streaming. If a violation is detected, the stream is immediately interrupted with a denial message.
final_packet evaluates the complete response after the LLM finishes and appends the calculated risk level to the data field of the SSE messages.
stream_check_cache_size — integer · optional · default: 128 · since APISIX 3.14.0 · API7 Gateway 3.8.0
Valid values: greater than or equal to 1
Max characters per moderation batch in realtime mode.
stream_check_interval — number · optional · default: 3 · since APISIX 3.14.0 · API7 Gateway 3.8.0
Valid values: greater than or equal to 0.1
Seconds between batch checks in realtime mode.
keepalive — boolean · optional · default: true · since APISIX 3.14.0 · API7 Gateway 3.8.11
If true, enable HTTP keepalive to Aliyun.
keepalive_pool — integer · optional · default: 30 · since APISIX 3.14.0 · API7 Gateway 3.8.11
Valid values: greater than or equal to 1
Maximum number of connections in the keepalive pool.
keepalive_timeout — integer · optional · default: 60000 · since APISIX 3.14.0 · API7 Gateway 3.8.11
Valid values: greater than or equal to 1000
Keepalive timeout in milliseconds.
ssl_verify — boolean · optional · default: true · since APISIX 3.14.0 · API7 Gateway 3.8.0
If true, enable SSL verification.
fail_mode — string · optional · default: skip · since APISIX 3.18.0 · API7 Gateway 3.9.14
Valid values: skip, warn, or error
Behavior when the plugin receives a request it cannot moderate, such as non-AI traffic on a Consumer binding or a request that did not pass through AI Proxy. With skip, the request passes unchecked. With warn, it passes unchecked and a warning is logged. With error, the plugin rejects it with the applicable HTTP 400 or 500 response. None of these outcomes means moderation succeeded.
Introduced in API7 Enterprise 3.9.14 and APISIX 3.18.0.
request_check_mode — string · optional · default: last · since APISIX 3.18.0 · API7 Gateway 3.9.16
Valid values: last or all
Which turn messages in the request to moderate for roles selected by request_check_roles. With last, only the latest consecutive block of selected user and tool messages is moderated. With all, every selected user and tool message is moderated. The system role is always checked on every request when selected.
Introduced in API7 Enterprise 3.9.16 and 3.10.3, and APISIX 3.18.0.
request_check_roles — array[string] · optional · default: ["user"] · since APISIX 3.18.0 · API7 Gateway 3.9.16
Valid values: user, tool, or system
Message roles to moderate on the request side. user and tool follow request_check_mode; system is checked on every request because system content can be affected by malicious tool-call arguments.
In APISIX, selecting system also covers developer messages, which is the role OpenAI uses in place of system on newer models and on the Responses API. There is no separate developer entry. API7 Enterprise 3.9.18 and 3.10.5 use the same behavior; earlier API7 Enterprise versions did not moderate developer messages.
Tool-result moderation applies to OpenAI-compatible formats where tool output is represented as a distinct tool role or item.
Introduced in API7 Enterprise 3.9.16 and 3.10.3, and APISIX 3.18.0.