Agent tools

fetch

fetch({ url, type?, screenshot?, viewport?, deviceScaleFactor?, wait?, include? })

Open a web page and read it. With screenshot it also sees the page; with include it gets the JavaScript errors and the slowest requests — all from one capture and one credit.

category: read1 credit whatever you ask forone capture
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

urlstringrequired

The page. Private and internal addresses are refused.

typestringpage

Use screenshot for an image-only result; use page for readable page content.

screenshotbooleanfalse

Attach an image to a page result; this keeps the full page.

viewport{ width, height }1280 × 720

CSS viewport (320–2560 × 480–1600). With type: "screenshot" and deviceScaleFactor: 1, the image dimensions exactly match this viewport.

deviceScaleFactor1 | 2 | 31

Raster density multiplier; 2× and 3× increase output pixels.

waitinteger1000

Extra visual settling time, 0–10000 ms.

includestring[]

["console", "network"] — errors and slow requests from the same capture.

Asking for more costs nothing more

It is one capture

The page is rendered once; the text, the image, the console and the requests all come from it. So screenshot: true and include together are still one credit — and two separate calls for the same page are two.

Looking at what it built

fetch({ url: "http://…/preview", screenshot: true, include: ["console", "network"] })
# The call the model makes:
#   fetch {"url": "https://…/preview"}
# From your own code, the same capture with screenshot and console:
api.tools.fetch({"url": url, "screenshot": True, "include": ["console", "network"]})

The system prompt tells the agent to look at a page it built rather than assume it renders, and to read the console before guessing why something fails. This is the tool that makes that possible.

The address is checked

The scheme must be http or https and the host must resolve to a public address; a redirect does not escape the check. That matters most here, because the agent follows URLs it found in text.

A page that never settles is still returned

What had loaded is captured, with a flag saying it timed out. A credit is not spent for nothing.