Skip to main content
Register a tool and the function that runs it. The SDK owns the call-and-execute loop.

The tools namespace

All three are synchronous on Web. There is no clear(); unregister by name.

Defining a tool

Controlling the loop

Tools registered through tools.register are offered to every generation. Tools passed in options.tools apply to that call alone.

Watching the calls happen

The stream reports tool activity, which is what lets you show “checking the weather…” rather than a stalled cursor:
capabilities().tools reports { registry: true, parallel: false, cancellation: false } on Web, so tools run one at a time.

Executors run in the page

Your executor is ordinary page code, so it has the network, storage, and DOM. That also means it is subject to CORS: a fetch to an origin that does not allow you will fail inside the tool loop, and the model will see the failure rather than an answer.

Which models can do this

Tool calling needs a model with enough context to hold the tool definitions. The SDK gates on context length rather than a model allowlist, so any model with a large enough window can participate, though instruction-tuned models trained on tool use do it far more reliably.