Skip to main content

创建模型策略接口

创建模型策略组,将用户、部门或用户组与模型资源的允许或限制规则关联。可设置生效时间和启用状态;当前使用入口仅支持 qwenwork_pc。

  • Scope:admin.v1.model-policies.manage
  • 权限项:模型策略管理(model-policies)
  • 权限类型:管理
  • 接口:POST/api/openapi/v1/model-policies

认证与请求头

使用应用 API Key 调用。当前接口只校验上方独立 Scope;读取、管理与执行权限互不隐含。
名称位置类型必填说明示例
Authorizationheaderstring是应用 API Key,使用 Bearer 方式传递。Bearer qwk_***
X-Request-Idheaderstring否可选的调用追踪标识;未传入时由服务端生成。req-20260831-001

请求参数

名称位置类型必填说明示例
Idempotency-Keyheaderstring必填幂等键,用于避免重复提交"<string>"
descriptionbodystring否说明"<string>"
display_orderbodyinteger · int64否排序0
modebodystring必填策略模式"allowlist"
namebodystring必填策略名称"<string>"
resource_idsbodyarray | null必填主模型范围(资源 ID 列表)["<string>"]
resource_scopebodystring必填主模型范围"all"
statusbodystring否启用状态"enabled"
subject_scopebodystring必填生效范围"all_users"
subjectsbodyarray | null必填选择范围-
surfacesbodyarray | null必填目标端["<string>"]
valid_frombodystring · date-time否生效时间"2026-08-27T10:00:00Z"
valid_tobodystring · date-time否失效时间"2026-08-27T10:00:00Z"

subjects[] 字段

以下必填性针对对象存在时的子字段;父对象可否省略或为 null,以上层字段表为准。
字段类型必填说明
include_descendantsboolean否部门对象是否包含下级部门
subject_idstring是适用对象 ID
subject_typestring是适用对象类型;可选值:user, org_unit, user_group

请求示例

curl --request POST \
  --url 'https://example.invalid/api/openapi/v1/model-policies' \
  --header 'Authorization: Bearer <API_KEY>' \
  --header 'Idempotency-Key: <UNIQUE_REQUEST_ID>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "<string>",
  "display_order": 0,
  "mode": "allowlist",
  "name": "<string>",
  "resource_ids": [
    "<string>"
  ],
  "resource_scope": "all",
  "status": "enabled",
  "subject_scope": "all_users",
  "subjects": [
    {
      "include_descendants": false,
      "subject_id": "<string>",
      "subject_type": "user"
    }
  ],
  "surfaces": [
    "<string>"
  ],
  "valid_from": "2026-08-27T10:00:00Z",
  "valid_to": "2026-08-27T10:00:00Z"
}'

响应

201 Created

名称类型必填说明示例
created_atstring · date-time是创建时间"2026-08-27T10:00:00Z"
defaultboolean是是否为默认策略组false
descriptionstring是说明"<string>"
idstring是策略组 ID"<string>"
modestring是策略模式"<string>"
namestring是策略名称"<string>"
policy_typestring是策略类型"<string>"
resource_countinteger · int64是资源数量0
resource_scopestring是主模型范围"<string>"
statusstring是启用状态"<string>"
subject_countinteger · int64是适用对象数量0
subject_countsobject是适用对象分类数量-
subject_scopestring是生效范围"<string>"
surfacesarray | null是目标端["<string>"]
updated_atstring · date-time是更新时间"2026-08-27T10:00:00Z"

subject_counts 字段

以下必填性针对对象存在时的子字段;父对象可否省略或为 null,以上层字段表为准。
字段类型必填说明
{key}integer · int64否键为适用对象类型,值为该类型的对象数量
{
  "created_at": "2026-08-27T10:00:00Z",
  "default": false,
  "description": "<string>",
  "id": "<string>",
  "mode": "<string>",
  "name": "<string>",
  "policy_type": "<string>",
  "resource_count": 0,
  "resource_scope": "<string>",
  "status": "<string>",
  "subject_count": 0,
  "subject_counts": {},
  "subject_scope": "<string>",
  "surfaces": [
    "<string>"
  ],
  "updated_at": "2026-08-27T10:00:00Z"
}

default Flat business error

名称类型必填说明示例
codestring否Stable business error code"<string>"
detailstring是Human-readable error description"<string>"
detailsOpenapiErrorDetails否错误详情-
errorstring是Stable HTTP error type"<string>"

details 字段

以下必填性针对对象存在时的子字段;父对象可否省略或为 null,以上层字段表为准。
字段类型必填说明
fieldstring否校验失败的请求字段
reasonstring否校验失败的原因代码
suggestionstring否建议使用的规范化值
{
  "code": "<string>",
  "detail": "<string>",
  "details": {
    "field": "<string>",
    "reason": "<string>",
    "suggestion": "<string>"
  },
  "error": "<string>"
}