> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stophy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic

> Give Claude live web search with Stophy. Save one search function, define it as a tool, and let the tool runner call it when Claude asks.

Give Claude live web search. Claude asks for a search, your code calls Stophy, and Claude answers from the results.

## The search tool

Save this as `stophy.ts`. It calls Google search and returns the top 5 results as JSON. It works with no key. Set `STOPHY_API_KEY` to lift the free limit.

```ts stophy.ts theme={null}
export async function stophySearch(query: string): Promise<string> {
  const headers: Record<string, string> = { "content-type": "application/json" };
  if (process.env.STOPHY_API_KEY) headers.authorization = `Bearer ${process.env.STOPHY_API_KEY}`;
  const response = await fetch("https://api.stophy.dev/v1/google/search", {
    method: "POST",
    headers,
    body: JSON.stringify({ query }),
  });
  const body = await response.json();
  if (!body.success) throw new Error(body.error.message);
  return JSON.stringify(body.data.results.slice(0, 5));
}
```

## Give it to Claude

```bash theme={null}
npm install @anthropic-ai/sdk zod
```

Set `ANTHROPIC_API_KEY` in your environment.

`betaZodTool` defines the search as a tool. The tool runner calls it whenever Claude asks, and returns Claude's final message.

```ts theme={null}
import Anthropic from "@anthropic-ai/sdk";
import { betaZodTool } from "@anthropic-ai/sdk/helpers/beta/zod";
import { z } from "zod";
import { stophySearch } from "./stophy";

const client = new Anthropic();

const webSearch = betaZodTool({
  name: "web_search",
  description: "Search the web. Returns the top results as JSON.",
  inputSchema: z.object({ query: z.string().describe("What to search for") }),
  run: async ({ query }) => stophySearch(query),
});

const message = await client.beta.messages.toolRunner({
  model: "claude-sonnet-5-5",
  max_tokens: 16000,
  tools: [webSearch],
  messages: [{ role: "user", content: "What changed in the latest Bun release?" }],
});

for (const block of message.content) {
  if (block.type === "text") console.log(block.text);
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.