Examples

Runnable examples in the repository.

The repository's examples/ directory has a runnable example for each feature covered in the Guides:

ExampleDemonstrates
examples/basicgenerateText() against Google
examples/basic-openaigenerateText() against OpenAI
examples/agent-calculatorAgent + tool(), .generate() — see Agents
examples/agent-calculator-openaiSame, against OpenAI
examples/streaming.stream() and AgentEvent handling — see Streaming
examples/memory-chatMulti-turn session persistence — see Sessions & Memory
examples/structured-outputoutputSchema — see Structured Output
examples/handoffsMulti-agent handoffs — see Handoffs
examples/guardrailsInput/tool/output guardrails — see Guardrails
examples/tracingrunId / trace — see Tracing
examples/reliabilitymodelTimeoutMs / 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).