建立一個新的 Agent 配置。
要求標頭
|
頭部 |
必選 |
說明 |
|
|
是 |
|
|
|
是 |
|
|
|
否 |
等冪鍵,防止重複建立 |
請求體
|
欄位 |
類型 |
必選 |
說明 |
|
|
string |
是 |
Agent 名稱,長度 1-256 字元 |
|
|
string/object |
是 |
模型標識,可以是字串(如 |
|
|
string |
否 |
系統提示詞(System Prompt) |
|
|
string |
否 |
Agent 描述 |
|
|
array |
否 |
工具配置列表,元素結構見下方” |
|
|
array |
否 |
MCP 伺服器配置列表,格式 |
|
|
array |
否 |
Skill 繫結資料行表,格式 |
|
|
object |
否 |
自訂中繼資料索引值對 |
tools 元素結構
{
"type": "agent_toolset_20260401",
"enabled_tools": ["Bash", "Read", "Write", "Edit", "Glob", "Grep", "WebFetch", "WebSearch"]
}
|
欄位 |
類型 |
必選 |
說明 |
|
|
string |
是 |
工具集類型標識符。當前可用值與最新版本見 Agent 工具配置。 |
|
|
array |
否 |
啟用的原子工具白名單。省略或填空數組 |
樣本請求
curl -X POST "https://api.qoder.com.cn/api/v1/cloud/agents" \
-H "Authorization: Bearer $QODER_PAT" \
-H "Content-Type: application/json" \
-d '{
"name": "doc-test-agent",
"model": "ultimate",
"instructions": "你是文檔測試助手",
"tools": [
{
"type": "agent_toolset_20260401",
"enabled_tools": ["Bash", "Read", "Write", "Edit", "Glob", "Grep", "WebFetch", "WebSearch"]
}
],
"mcp_servers": [
{
"type": "url",
"name": "weather-service",
"url": "https://mcp.example.com/sse"
}
]
}'
樣本響應
HTTP 201 Created
{
"type": "agent",
"id": "agent_019eXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"name": "doc-test-agent",
"description": "",
"model": "ultimate",
"system": "你是文檔測試助手",
"instructions": "你是文檔測試助手",
"tools": [
{
"type": "agent_toolset_20260401",
"enabled_tools": ["Bash", "Read", "Write", "Edit", "Glob", "Grep", "WebFetch", "WebSearch"]
}
],
"mcp_servers": [
{
"type": "url",
"name": "weather-service",
"url": "https://mcp.example.com/sse"
}
],
"default_environment": "",
"version": 1,
"archived": false,
"archived_at": null,
"created_at": "2026-05-18T15:26:39.61669Z",
"updated_at": "2026-05-18T15:26:39.61669Z"
}
響應欄位
|
欄位 |
類型 |
說明 |
|
|
string |
固定值 |
|
|
string |
Agent 唯一標識,首碼 |
|
|
string |
Agent 名稱 |
|
|
string |
Agent 描述 |
|
|
string |
模型標識 |
|
|
string |
系統提示詞 |
|
|
string |
|
|
|
array |
工具配置列表 |
|
|
array |
MCP 伺服器配置 |
|
|
string |
預設運行環境 |
|
|
integer |
目前的版本號,從 1 開始遞增 |
|
|
boolean |
是否已歸檔 |
|
|
string|null |
歸檔時間(ISO 8601),未歸檔時為 |
|
|
string |
建立時間(ISO 8601) |
|
|
string |
最後更新時間(ISO 8601) |
錯誤碼
|
HTTP |
type |
觸發條件 |
|
400 |
|
缺少必要欄位 |
|
400 |
|
|
|
400 |
|
缺少必要欄位 |
|
400 |
|
|
|
400 |
|
|
|
401 |
|
PAT 無效或到期 |
|
403 |
|
無許可權執行此操作 |
錯誤響應樣本:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "name must be between 1 and 256 characters"
}
}
完整錯誤信封說明詳見 錯誤參考。