# fetch

Canonical URL: https://developers.iagenify.com/zh/sdk/agent/tools/fetch/
Language: zh

`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.

Status: category: read · 1 credit whatever you ask for · one capture

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `url` | string | required | The page. Private and internal addresses are refused. |
| `type` | string | page | Use `screenshot` for an image-only result; use `page` for readable page content. |
| `screenshot` | boolean | false | 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. |
| `deviceScaleFactor` | 1 | 2 | 3 | 1 | Raster density multiplier; 2× and 3× increase output pixels. |
| `wait` | integer | 1000 | Extra visual settling time, 0–10000 ms. |
| `include` | string[] |  | `["console", "network"]` — errors and slow requests from the same capture. |

## Asking for more costs nothing more {#one-credit}

> **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 {#seeing}

```javascript
fetch({ url: "http://…/preview", 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 {#guard}

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 {#timedout}

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

- [search](/zh/sdk/agent/tools/search): Finding the page.
- [api.tools.fetch()](/zh/sdk/ref/tools/fetch): Every field it returns.
- [Agent tools](/zh/sdk/agent/tools): The 35, by family.

```python
# 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"]})
```
