logo
开发者文档
搜索
创建 Tool

创建 Tool

支持在指定组织下创建 Tool,并可通过 OpenAPI Schema 自动生成 actions。

可以通过该接口,在指定组织下创建 Tool。传入 api_schema 时会同步生成 actions;未传时仅创建 Tool 壳。

请求方式

POST

调用地址

https://api.${endpoint}/v1/org/tool/create

调用验证

使用账号级 DevKey / DevSecret 的 Basic 鉴权,并要求调用账号具备组织 Tool 创建权限。

请求

请求示例

curl -X POST 'https://api.${endpoint}/v1/org/tool/create' \ -H 'Authorization: Basic ${BASIC_TOKEN}' \ -H 'Content-Type: application/json' \ -d '{ "org_id": "p-xxxx", "name": "weather", "display_name": "Weather Lookup", "description": "Query current weather by city name", "logo": "https://cdn.example.com/weather.png", "url": "https://api.example.com", "show_request": true, "api_schema": "{\"openapi\":\"3.0.0\",\"paths\":{}}" }'
                      
                      curl -X POST 'https://api.${endpoint}/v1/org/tool/create' \
  -H 'Authorization: Basic ${BASIC_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{
    "org_id": "p-xxxx",
    "name": "weather",
    "display_name": "Weather Lookup",
    "description": "Query current weather by city name",
    "logo": "https://cdn.example.com/weather.png",
    "url": "https://api.example.com",
    "show_request": true,
    "api_schema": "{\"openapi\":\"3.0.0\",\"paths\":{}}"
  }'

                    
此代码块在浮窗中显示

请求头

字段 类型 说明
Authorization Basic ${BASIC_TOKEN} 使用 DevKey:DevSecret Base64 后的 Basic Token。
Content-Type application/json 请求体格式。

请求参数(Body Parameters)

参数 类型 说明 required
org_id String 组织 ID。 true
name String Tool 名称,最多 20 个字符。 true
display_name String Tool 展示名称,最多 50 个字符。 false
description String Tool 描述,最多 100 个字符。 true
logo String Tool 图标 URL。 true
url String Tool 基础 URL,必须为公网 http/https 地址。 true
show_request Boolean 是否在调用过程里展示请求内容。 true
api_schema String OpenAPI JSON Schema。传入时生成 actions,成功后 available=true;未传时 available=false false

响应

响应示例

{ "code": 0, "message": "OK", "data": { "tool_id": "tool-xxxx", "name": "weather", "available": true } }
                      
                      {
  "code": 0,
  "message": "OK",
  "data": {
    "tool_id": "tool-xxxx",
    "name": "weather",
    "available": true
  }
}

                    
此代码块在浮窗中显示

成功响应

字段 类型 说明
tool_id String 新建 Tool ID。
name String Tool 名称。
available Boolean Tool 是否可用。

失败响应

字段 类型 说明
code Integer 错误码。
message String 错误详情。

状态码

状态码 说明
200 成功
400 参数错误
401 未授权
403 权限不足
429 请求过于频繁
500 服务器错误