建立 Tool
建立 Tool
支援在指定組織下建立 Tool,並可透過 OpenAPI Schema 自動產生 actions。
可以透過該 API,在指定組織下建立 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 | 伺服器錯誤 |
