STOPHY_API_KEY. See the Quickstart. A question that takes one search and two page reads costs about $0.003.
1. Find pages
Search returns a short list of pages for a query. This request asks for 3 results.data.web holds the results. Each has a url, a title and usually a description. This is the real answer.
2. Read one page
Scrape reads a page the agent picked.maxChars keeps each answer short, so a long page does not fill the agent’s context.
metadata are left out.
nextOffset says where the next part starts. Send the same request with "offset": 1493 to read on. The read cost $0.001. See Content filtering.
3. Wrap both as tools
Each tool takes a string and returns a string. A failed call returns the error as text, so the model can try something else instead of the loop crashing.readPage puts Source: <url> at the top of everything it returns. That line is what lets the agent cite.
4. Describe the tools to the model
Give the model one definition for each tool. The shape below works with the Anthropic, OpenAI and Vercel AI SDK tool calls, with the field names each one uses.Source: URL it came from.
5. Try the failures first
Before you connect a model, call each tool with input that fails. A page that is not public returns400 invalidRequest, and the tool turns it into text. This is the real error for http://localhost/admin.
readPage("http://localhost/admin") returned Read failed: url: Expected a public website URL. A failed call costs nothing.
What to check
- The agent calls
search_webfirst andread_pageon one or two of the URLs it got back. - Every URL in the answer appeared in a tool result. Open two of them and check the claim.
- A long page is read in parts with
offset, not guessed from the first 1,500 characters. - A failing tool leaves the loop running.
What it costs
A search with no results, and a page that cannot be read, cost nothing. See Pricing.
Related
- Search for sources, filters and page text in the same call.
- Scrape for formats such as
highlights, which returns only the passages that match a query. - Rate limits to keep a busy agent under its limits.
- Research papers for an agent that reads scholarly papers.