Skip to main content

Setup

Set ANTHROPIC_API_KEY in your environment. STOPHY_API_KEY is optional for this example.

The Stophy tool

This function calls Google search and returns the results as JSON, limited to 5 so the model’s context stays small. It reads your key from STOPHY_API_KEY, and works without one.
stophy.ts

Use it as a tool

Define the search as a tool with betaZodTool. The tool runner calls it whenever Claude asks, and returns Claude’s final message.