api.agents

create()

api.agents.create(options) → LocalAgent | Agent

根据其选项构建代理。 此处所有的东西都得到验证, 任何东西都没有发送 - 对象已经准备好, 账户对此还不知道 。

no requeststrict validationreturns an object
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

当地代理商

const agent = api.agents.create({
  runtime: "local",
  machine: pc,                      // required
  model: "gemini-3.5-flash",        // required
  mode: "ask",
  tools: ["read", "list", "glob", "grep", "write", "edit", "bash"],
  budget: 200,
  memory: true,
  onPermission: async ({ tool, category, args }) => "once",
  onQuestion: async ({ question }) => answer(question),
});
agent = api.agents.create(
    runtime="local",
    machine=pc,                       # required
    model="gemini-3.5-flash",         # required
    mode="ask",
    tools=["read", "list", "glob", "grep", "write", "edit", "bash"],
    budget=200,
    memory=True,
    on_permission=lambda request: "once",
    on_question=lambda request: answer(request["question"]),
)

需要哪些

runtimestring

"local" 用于您进程中的引擎。缺席构建 服务器侧边代理服务器.

machineConnectedStorage必填

计算机、电话或云工作空间。请参见 机 机 机 机.

modelstring必填

除非你经过 id,在这种情况下,它来自届会。

每种选择

选项选项默认默认Page
machine · workspace—机 机 机 机
model · fallbackModels · thinking · maxOutputTokens- · [] · 无效 16 000模式和思维
tools · skills · subagents · mcp · agent· 全部 · 全部 · 全部 · 全部 · 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 全部 —— 取消工具库
mode · onPermission · onQuestion · system"ask" · — · — · ""模式和权限
budget · maxSteps · contextTokens100 200 000预算及背景
media{}媒体媒体
memory · id · memories · checkpoints假的——真的——真的——真的内存和会话
files · shell · terminals · customTools—桥梁

被拒,和被拒,

代码触发条件
machine_required无 无 machine,或者不是计算机, 电话或云工作空间。
files_required手机或云工作空间没有六个文件操作。 信件中指定了丢失的 。
model_required无 无 model 和无 id.
invalid_mode四号外的一个模式
unknown_tool引擎不知道的工具名。 信件列出了它所要做的 。
invalid_contextcontextTokens 并不是整数至少为10 000。
invalid_shellA A A shell 没有 a 中 run 函数。
invalid_custom_tool自定义工具,无描述,无 run,保留的名称,或四个以外的类别。
invalid_mediaA A A media 键不是 image, video, voice 或 music.
invalid_agentA 音 A agent 不是一个库名 。
invalid_session_idA 音 A id 不是一个会话标识符。
workspace_not_allowedA A A workspace 排 的 SDK自己的文件夹 。
全部被抛在创造的轨道上,不是在运行的时段

这是故意的: 错误配置的代理器在配置它的线上应该失败。 唯一的例外是上下文Tokens 大于模型窗口, 需要目录, 因此在第一个运行时表面 。