api.agents

create()

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

Costruisce un agente a partir de ses opcions.Tutto è validato qui, nada è enviado — l'oggetto è pronto e il conto non sa nada al riguardo.

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.

Un agente locale

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"]),
)

- Cenès esige

runtimestring

"local" per il motor in vostro processo. Absente costruisce il agente lateral al server.

machineConnectedStorageobrigatório

Un computer, un telefono, o un nube workspace. Ved machine.

modelstringobrigatório

A meno che non passi id, in quel caso viene da sessione.

Ogni opzion

OptionPredeterminatoPagina
machine · workspace—machine
model · fallbackModels · thinking · maxOutputTokens— · [] · nul · 16 000modèle e rating
tools · skills · subagents · mcp · agenttutto · tutto · tutto · tutto · tutto · nulloutils e biblioteca
mode · onPermission · onQuestion · system"ask" · — · — — · ""modo e permissions
budget · maxSteps · contextTokensNull · 100 · 200 000budget e contexto
media{}media
memory · id · memories · checkpointsfalse · — · vero · veromemoria e sessioni
files · shell · terminals · customTools—bridges

Cenès che è negat, e quando

CódigoQuando
machine_requiredNo machine, o uno che non è un computer, un telefono o un nublat de workspace.
files_requiredUn telefono o un nube workspace senza le sei operazion de file. Il messaggio nomies os faltant.
model_requiredNo model e no id.
invalid_modeUn modo fuori dels quattro.
unknown_toolUn nome d'utensiliu che il motor non sa. Il messaggio listasquequele che fa.
invalid_contextcontextTokens che non è un numero intero di almeno 10 000.
invalid_shellA shell senza una funzione run.
invalid_custom_toolUn utensiliu personalizzato senza descripzion, no run, un nome reservat, o una categoria al di fuori del quattro.
invalid_mediaA media chiave che non è image, video, voice o music.
invalid_agentUn nome agent che non è un nome di biblioteca.
invalid_session_idUn id che non è un identificator di sessione.
workspace_not_allowedA workspace a part del dossier SDK.
Tutti geta a creazion, non in tempo di run

Un agente mal configurat deve fail in linea che lo configura. La una excepzion i contextTokens is beaver than the winest of the model's, which need the cataloga et donc superes on the first run.