CreateAttackTarget - AI Red Teaming 创建扫描目标

更新时间:
复制 MD 格式

创建一个 AI Red Teaming 扫描目标(Agent 或模型),保存其连接配置供后续连通性测试与扫描任务使用

接口说明

创建攻击目标(Agent 或模型),保存其连接配置,供后续连通性测试与扫描任务使用。

调用为同步返回:成功后在 Data 中返回系统生成的 TargetId,可用于后续调用 TestConnectivity、发起扫描任务等接口的 TargetId 参数。

参数说明:

  • ConnectionMethod=enterprise_relay(企业内网 Agent 接入)时,Endpoint 与 ModelName 的传值被忽略,平台使用固定内部值;真实目标端点与凭据由企业内网 Agent 持有。

  • ApiKey 传入后加密保存,后续查询不回明文。

  • ConnectionConfig 为 JSON 字符串格式的连接高级配置,常见 provider 模板见该参数说明。

创建成功后目标初始连通性状态为 verified,可随时调用 TestConnectivity 重新验证。

内网接入(enterprise_relay)后续链路:

  • 创建成功后调用 GenerateRelayPollerScript 获取安装脚本(仅 Linux 平台),在企业内网机器上运行;目标真实端点与凭据在安装时交互输入,平台不持有;

  • 安装完成后 poller 自动注册并进入轮询循环,无需手动调用注册/轮询接口;

  • 调用 TestConnectivity 验证端到端链路通过后,即可用 CreateTargetScanTask 发起扫描。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

当前API暂无授权信息透出。

请求语法

POST  HTTP/1.1

请求参数

名称

类型

必填

描述

示例值

TargetName

string

是

扫描目标的展示名称,用于列表展示与筛选;同一租户内建议使用可区分的名称。

我的百炼靶标

TargetType

string

是

扫描目标类型,决定扫描任务的选样维度:agent 对应智能体类样本,model 对应模型类样本。

枚举值:

  • agent :

    智能体(Agent)

  • model :

    模型

model

ConnectionMethod

string

是

目标服务的连接协议类型,系统按此选择对应的协议适配器。

枚举值:

  • openai :

    OpenAI 兼容协议

  • anthropic :

    Anthropic Messages API 协议

openai

Description

string

否

扫描目标的用途备注说明,可选。

生产环境百炼应用

Endpoint

string

是

目标模型服务的 HTTP/HTTPS 端点地址。ConnectionMethod=enterprise_relay 时传值被忽略,平台使用固定内部端点。

https://dashscope.aliyuncs.com/compatible-mode/v1

ApiKey

string

是

目标模型服务的 API 密钥,用于向 Endpoint 认证;传入后加密保存,后续查询不回明文。ConnectionMethod=enterprise_relay 时真实凭据由企业内网 Agent 持有。请通过 HTTPS 传输,避免在日志、URL 或客户端代码中明文暴露。

sk-abcd1234****

ModelName

string

否

目标模型的名称。ConnectionMethod=openai 时填 OpenAI 兼容协议下的模型 ID;ConnectionMethod=anthropic 时填 Anthropic Messages API 的模型 ID。ConnectionMethod=enterprise_relay 时传值被忽略,平台使用固定值。

qwen-flash

ConnectionConfig

string

否

连接高级配置,JSON 字符串格式。常见字段:authType(认证类型,custom_header=自定义请求头认证、none=无认证)、customAuthHeaderName(自定义认证请求头名称,如 X-API-Key)、requestHeaders(附加的 HTTP 请求头键值对)。

常见 provider 配置模板({{prompt}} 为提问占位符,按实际服务替换;authType=bearer 时 token 由 ApiKey 注入,模板中不含凭据):

  • Bailian:{"httpMethod":"POST","authType":"bearer","timeoutMs":30000,"requestTemplate":"{"input":{"prompt":"{{prompt}}"},"parameters":{"incremental_output":true},"debug":{}}","messageJsonPath":"$.output.text","requestHeaders":"{"X-DashScope-SSE": "enable" }","stream":true,"customAuthHeaderName":""}

  • PAI:{"httpMethod":"POST","authType":"bearer","timeoutMs":60000,"requestTemplate":"{"inputs":{"question":"{{prompt}}","chat_history":[]},"stream":true}","messageJsonPath":"$.outputs.answer","requestHeaders":"","stream":true,"customAuthHeaderName":""}

  • Dify:{"httpMethod":"POST","authType":"bearer","timeoutMs":30000,"requestTemplate":"{"inputs":{},"query":"{{prompt}}","response_mode":"streaming","conversation_id":"","user":"scanner"}","messageJsonPath":"$.answer","requestHeaders":"","stream":true,"customAuthHeaderName":""}

  • AgentRun:{"httpMethod":"POST","authType":"custom_header","timeoutMs":30000,"requestTemplate":"{"messages":[{"role":"user","content":"{{prompt}}"}],"stream":true}","messageJsonPath":"$.choices[0].delta.content","requestHeaders":"","customAuthHeaderName":"X-API-Key","stream":true}

  • AgentKit:{"httpMethod":"POST","authType":"bearer","timeoutMs":30000,"requestTemplate":"{"messages":[{"role":"user","content":"{{prompt}}"}]}","messageJsonPath":"$.content.parts[0].text","requestHeaders":"","stream":true,"customAuthHeaderName":""} ConnectionMethod=enterprise_relay 时,可通过 protocol 字段指定隧道协议(缺省为 openai);上述 provider 配置模板仅适用于非 enterprise_relay 连接。

{\"httpMethod\":\"POST\",\"authType\":\"bearer\",\"timeoutMs\":30000,\"requestTemplate\":\"{\\\"input\\\":{\\\"prompt\\\":\\\"{{prompt}}\\\"},\\\"parameters\\\":{\\\"incremental_output\\\":true},\\\"debug\\\":{}}\",\"messageJsonPath\":\"$.output.text\",\"requestHeaders\":\"{\\\"X-DashScope-SSE\\\": \\\"enable\\\" }\",\"stream\":true,\"customAuthHeaderName\":\"\"}

Provider

string

否

模型/Agent 提供商业务标签,用于界面筛选与表单展示;与 ConnectionMethod(技术协议)解耦:同一 Provider 可能走多种协议,反之亦然。

枚举值:

  • agentkit :

    AgentKit 平台

  • openai :

    OpenAI 服务

  • dify :

    Dify 平台

  • bailian :

    阿里云百炼

  • agentrun :

    AgentRun 平台

  • custom :

    其他或自研

  • anthropic :

    Anthropic 服务

  • pai :

    阿里云 PAI

  • openclaw :

    OpenClaw 平台

bailian

返回参数

名称

类型

描述

示例值

object

Data

object

操作结果。创建成功时返回新扫描目标的 TargetId。

TargetId

string

创建成功的扫描目标唯一标识,可用于后续调用 TestConnectivity、发起扫描任务等接口的 TargetId 参数。

target-abc123def4567

RequestId

string

本次请求的唯一标识,用于问题排查与日志追踪。

1EBD0C05-6C1F-4C95-9C63-B7AB7B5A9C8E

示例

正常返回示例

JSON格式

{
  "Data": {
    "TargetId": "target-abc123def4567"
  },
  "RequestId": "1EBD0C05-6C1F-4C95-9C63-B7AB7B5A9C8E"
}

错误码

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情。