跳至內容

建立 Agent

POST/v1/agents

建立版本為 1 的已儲存 Agent。請求本文為嚴格 JSON:未知欄位會傳回 400。multi_agent 必須省略或為 null。

標頭

選用<string>Idempotency-Key

選用。省略時由服務自動產生,因此重試的請求可能會建立重複項目。重試時請傳送您自己的固定金鑰。

請求本文

JSON 物件。

stringmodel必填

必填,來自 Models API 的模型 ID,最多 200 個字元。沒有預設值;省略 model 會傳回 400。範例使用 deepseek/deepseek-v4-flash。

選用<string>name

顯示名稱,最多 128 個字元。

選用<string>instructions

系統指示,最多 256 KiB。

選用<string>runtime_profile

執行環境:codex(預設)、claude 或 mcode。

選用<array>skills

技能參照:{"skill_id": "skl_…", "version": null | "<version>"}。最多 32 個。新增繫結時,null 會在儲存 Agent 時鎖定當下的預設版本。對於既有繫結,null 會保留其已鎖定的版本;若要升級請提供明確的版本。

選用<array>mcp_connections

MCP 參照:{connection_id, server_label, allowed_tools, required}。最多 32 個;server_label 在 Agent 內必須唯一。省略時會使用內建的 SandBase 工具({"connection_id": "builtin:sandbase", "server_label": "sandbase_builtin"});您傳送的清單會取代此預設值,傳送 [] 則會建立沒有工具的 Agent。請參閱內建 SandBase 工具(/agents/mcp-tools#built-in-sandbase-tools)。

選用<array>tools

最多 64 個 function 工具,以及至多一個 web_search 工具。工作階段目前要求停用 web_search 模式,且尚不支援用戶端 function 結果。

選用<object>text

format.type 為 text 或 json_schema(搭配 object 結構描述);verbosity 為 low、medium 或 high。

選用<object>reasoning

effort 為 none、minimal、low、medium、high、xhigh 或 max;summary 為 concise、detailed 或 auto。

選用<string>service_tier

auto(預設)、default、flex、priority 或 fast。

選用<object>metadata

最多 16 組字串配對;鍵最多 64 個字元,值最多 512 個字元。

選用<string>description

較長的描述,最多 4096 個字元。

選用<string>note

記錄於版本 1 的變更說明。

Agent 物件

由 create、get、update、archive、unarchive、restore 與 clone 傳回。

stringid必填

帶有 agt_ 前綴的 Agent ID。

stringobject必填

固定為 agent。

integerversion必填

目前版本。每次有效寫入都會建立新版本。

integerrow_version必填

用於 PATCH、archive、unarchive 與 restore 的比較並設定(compare-and-set)權杖。

stringstatus必填

active 或 archived。

stringprojection_status必填

目前版本的執行就緒狀態。工作階段需要 ready;新建立的 Agent 可能短暫回報 pending。

stringruntime_profile必填

codex、claude 或 mcode。

stringvisibility必填

您的 Agent 為 private;目錄項目為 public。

integer · nullcreated_at · updated_at · archived_at必填

Unix 秒數。啟用期間 archived_at 為 null。