跳到正文

创建 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 schema);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必填

你的 Agents 为 private;目录条目为 public。

integer · nullcreated_at · updated_at · archived_at必填

Unix 秒级时间戳。处于 active 状态时 archived_at 为 null。