What you’ll learn
- Defining a tool with
tool()and Zod parameter schema - Calling an external HTTP API inside a tool
- Using
outputSchemafor structured JSON output - Type-safe
Agent<TDeps, TOutput>generics
Prerequisites
- Vibes installed
ANTHROPIC_API_KEYset (Open-Meteo requires no key)
Complete example
Run it
How it works
Tool definition:tool() wraps an async function. The parameters Zod schema is used to generate the tool’s JSON schema for the model - the model sees field names and descriptions.
Execute function: _ctx is the RunContext (available when using dependencies - see Dependencies). The second argument is the validated, typed tool args.
Output schema: outputSchema makes the agent return a typed object instead of a string. Vibes instructs the model to produce structured output matching the Zod schema.
Type generics: Agent<undefined, z.infer<typeof WeatherReport>> - first param is deps type (none here), second is the output type. TypeScript infers result.output as WeatherReport.
Next steps
- Bank Support - dependency injection with tools
- Tools concept page - all tool types and options