Examples
Runnable examples in the repository.
The repository's examples/ directory has a runnable example for each
feature covered in the Guides:
| Example | Demonstrates |
|---|---|
examples/basic | generateText() against Google |
examples/basic-openai | generateText() against OpenAI |
examples/agent-calculator | Agent + tool(), .generate() — see Agents |
examples/agent-calculator-openai | Same, against OpenAI |
examples/streaming | .stream() and AgentEvent handling — see Streaming |
examples/memory-chat | Multi-turn session persistence — see Sessions & Memory |
examples/structured-output | outputSchema — see Structured Output |
examples/handoffs | Multi-agent handoffs — see Handoffs |
examples/guardrails | Input/tool/output guardrails — see Guardrails |
examples/tracing | runId / trace — see Tracing |
examples/reliability | modelTimeoutMs / toolTimeoutMs — see Reliability |
Each example is a standalone runnable script — run it from the repository
root with pnpm --filter <example-name> start (or check the example's own
package.json for its exact script name).