1. 接口描述
接口请求域名: waf.tencentcloudapi.com 。
更新大模型内容安全规则
默认接口请求频率限制:20次/秒。
2. 输入参数
以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数。
| 参数名称 | 必选 | 类型 | 描述 |
|---|---|---|---|
| Action | 是 | String | 公共参数,本接口取值:ModifyLLMContentRule。 |
| Version | 是 | String | 公共参数,本接口取值:2018-01-25。 |
| Region | 是 | String | 公共参数,详见产品支持的 地域列表,本接口仅支持其中的: ap-guangzhou, ap-seoul, ap-singapore 。 |
| Name | 是 | String | 名称 示例值:test2 |
| Priority | 是 | Integer | 优先级 示例值:50 |
| Status | 是 | Integer | 规则开关 示例值:1 |
| CheckType | 是 | Integer | 检测范围,1:入向,2:出向,3:入向和出向 示例值:1 |
| RuleItem.N | 是 | Array of RuleItem | 检测内容匹配 |
| Options.N | 是 | Array of LLMOptionsItem | 匹配条件 |
| Domain | 否 | String | 域名 示例值:test.com |
| ActionType | 否 | String | 动作,观察monitor,拦截intercept 示例值:22 |
| ResponseText | 否 | String | 响应提示内容 示例值:ceshi |
| SessionApplied.N | 否 | Array of String | 规则需要启用的SessionID 示例值:["1312"] |
| RuleId | 否 | String | 规则ID,新增时填0 示例值:51000001 |
| PageId | 否 | Integer | 拦截页面id 示例值:51000001 |
| ContentLogicalOp | 否 | String | 检测内容and or表达式,默认为and 示例值:and |
| InstanceId | 否 | String | 实例id,必填项 示例值:"waf_padriq23131" |
| ReplyType | 否 | Integer | 代答类型:1-内置可信模型安全代答,2-自定义代答(ActionType=reply)时生效 枚举值:
示例值:1 |
| CustomReplyRuleId | 否 | String | 自定义回答模板 示例值:5000001 |
| ModalType | 否 | Integer | 模态类型:0-文本(默认),1-图片 枚举值:
示例值:0 |
| Category | 否 | String | 规则类别:black-普通规则(默认),white-白名单规则;空值按black处理。white时ActionType仅允许pass(放行),RuleItem支持白名单匹配字段(Key: ip/geo/type/content/chat_id/user_id/tool_name/tool_args/keyword_whitelist;Op: belong/not_belong/equal/not_equal/contain/not_contain/prefix/suffix/wildcard) 示例值:white |
| Domains.N | 否 | Array of String | 白名单规则生效范围:多个serviceId/domain列表(Category=white时使用),表示该白名单规则同时生效于哪些域名/serviceId。黑名单规则不使用此字段。 示例值:["10011"] |
| AppliedModules.N | 否 | Array of Integer | 加白生效模块type列表(Category=white时使用),表示该白名单规则命中后对哪些防护模块生效(放行)。取值:2-算力消耗规则,3-自定义防护规则,4-ToolCall防护,5-提示词攻击防护,6-内容合规检测,7-敏感数据检测。 示例值:[2] |
| RiskLevel | 否 | String | 严重程度:critical-超高危,high-高危,medium-中危(默认),low-低危。命中该规则时攻击日志按此展示风险等级;不传或空值按medium处理。 枚举值:
示例值:medium |
3. 输出参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| RuleId | String | 操作的RuleId 示例值:19000001 |
| RequestId | String | 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。 |
4. 示例
示例1 测试用例
输入示例
POST / HTTP/1.1
Host: waf.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: ModifyLLMContentRule
<公共请求参数>
{
"Domain": "jacky12220901.testwaf.com",
"Name": "ddptest",
"ActionType": "log",
"Priority": 50,
"Status": 1,
"ResponseText": "ceshi",
"CheckType": 1,
"RuleItem": [
{
"Key": "inappropriate_info",
"Op": "contain",
"Value": [
"601"
],
"Levels": [
{
"Label": "601",
"Level": 400
}
]
}
],
"SessionApplied": [
"0"
],
"Options": [
{
"Key": "protectpath_business",
"Op": "belong",
"Value": [
"`"
],
"Name": "5300000310"
}
],
"InstanceId": "waf_2l15d14809yfq9sf",
"ReplyType": 1,
"CustomReplyRuleId": "0"
}
输出示例
{
"Response": {
"RuleId": "5200039233",
"RequestId": "23a6c61f-825a-4a88-a03c-00a6859d1928"
}
}
5. 开发者资源
腾讯云 API 平台
腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。
API Inspector
用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。
SDK
云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。
- Tencent Cloud SDK 3.0 for Python: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Java: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for PHP: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Go: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Node.js: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for .NET: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for C++: CNB, GitHub, Gitee
- Tencent Cloud SDK 3.0 for Ruby: CNB, GitHub, Gitee
命令行工具
6. 错误码
以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码。
| 错误码 | 描述 |
|---|---|
| InternalError | 内部错误。 |
| LimitExceeded.ContentRuleErr | 当前域名下的内容规则数量已达上限 |
| LimitExceeded.LimitRuleErr | 当前域名下的算力消耗规则数量已达上限 |
| LimitExceeded.SpecificationErr | SpecificationErr |
| UnsupportedOperation | 操作不支持。 |