Skip to content
Docs

Guides

Web fetch

Let the model read a URL: a web page, a text file or a PDF. Add openrouter:web_fetch to tools, and the model fetches the pages it needs and answers with what they say. Each fetch is free. Available on standard models.

How it works

  1. You add {"type": "openrouter:web_fetch"} to the tools array.
  2. The model decides when to read a URL: one you gave it, one from a web search, or one linked from a page it already read.
  3. The page is fetched and turned into text.
  4. The text, with its title and URL, goes back to the model.
  5. The model can read several URLs in the same request, in parallel, and answers with what they say.

It works alongside your own function tools: those still come back to you, as in Tool calling.

Quick start

curl https://api.libremodel.ai/v1/chat/completions \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-1017",
    "messages": [{"role": "user", "content": "Summarize https://en.wikipedia.org/wiki/Large_language_model in five bullet points."}],
    "tools": [{"type": "openrouter:web_fetch"}]
  }'

Which models

Available on standard models: the ones without the Uncensored mark on Models. With an Uncensored model, a request with the tool, under any of its names, returns 400 invalid_request:

JSON
{
  "error": {
    "message": "`openrouter:web_fetch` is not available for this model.",
    "type": "invalid_request_error",
    "code": "invalid_request",
    "param": null
  }
}

Configuration

Every parameter is optional, inside parameters:

JSON
{
  "type": "openrouter:web_fetch",
  "parameters": {
    "max_uses": 10,
    "max_content_tokens": 20000,
    "allowed_domains": ["docs.python.org"],
    "blocked_domains": ["example.com"]
  }
}
ParameterTypeDefaultDescription
enginestringautoauto, native or openrouter, which do the same. Any other engine returns 400 invalid_request
max_usesinteger50Fetches per request, at most. Higher values count as 50
max_content_tokensinteger25,000Tokens of content per fetch, from 1,000 to 100,000. Longer content is truncated. A lower value counts as 1,000
allowed_domainsstring[]—Fetch only from these domains
blocked_domainsstring[]—Never fetch from these domains

A value out of range returns 400 invalid_request, and the message names the parameter. max_tool_calls, at the root of the request, caps the steps in which the model can call server tools, counting web fetch and web search: 30 by default and at most.

Tool names

The same fetch runs under the names other SDKs and tools use, in any of the three formats. The model always sees a single tool.

NameWhere the parameters go
openrouter:web_fetchIn parameters, as in the table above
web_fetchAt the root of the tool, with the same names
web_fetch_20250910, web_fetch_20260209 and any web_fetch_<date> (Anthropic)At the root of the tool, with the same names

If the request brings more than one, the first one counts. With n greater than 1, or with a function of yours named web_fetch, the request returns 400 invalid_request.

Which URLs it reads

The model reads URLs whose domain already appears in the conversation: in your messages, in the system message, or in a tool result, including earlier searches and fetched pages. The model's own messages don't count. A URL from elsewhere comes back as failed, and doesn't count toward max_uses.

  • A domain opens itself, its subdomains and the domains above it, with any path: docs.example.com in the conversation lets the model read docs.example.com, api.docs.example.com and example.com.
  • On sites where each user has their own subdomain, such as github.io or vercel.app, only the host that appeared counts.
  • On sites where each user has their own path, such as github.com, docs.google.com or link shorteners, only that path counts: github.com/acme/app opens github.com/acme/, not all of github.com.
  • Only http and https URLs on public addresses. Up to 5 redirects, and each one has to meet the same rules.
  • Pages are read without cookies and without running JavaScript, with the User-Agent Libremodel-WebFetch/1.0 (+https://libremodel.ai).

What it reads

ContentWhat the model gets
HTML pagesThe main content of the page, as Markdown: headings, paragraphs, lists, tables and links
Text: plain text, Markdown, JSON, CSV, XMLThe text as it is
PDFThe text of the first 150 pages. Where there is an image, [image not included: web fetch reads text only; attach the PDF as a file to see its images]. To see the images, send the PDF as a file
Images, archives, Office documents and other binary filesfailed, with unsupported content type
  • Hidden text is left out: scripts, styles, and what the page marks as hidden.
  • A page that builds its content with JavaScript is read from the data it ships in its HTML for its scripts: the description, JSON-LD, the Next.js and Nuxt data and <noscript>. That text comes after a [page data: …] note, because it can include text the page doesn't show. A page with no text and no such data comes back as failed with no readable text.
  • Each fetch downloads up to 10 MB and takes up to 15 seconds. Past that, it comes back as failed.

Domain filtering

JSON
{
  "type": "openrouter:web_fetch",
  "parameters": {
    "allowed_domains": ["docs.python.org", "peps.python.org"],
    "blocked_domains": ["example.com"]
  }
}

allowed_domains limits the fetches to those domains and blocked_domains rejects them, subdomains included. Both apply to the URL and to each redirect, on top of the conversation rule.

Content truncation

JSON
{
  "type": "openrouter:web_fetch",
  "parameters": { "max_content_tokens": 5000 }
}

max_content_tokens keeps each page within that many tokens of the model, so a long page doesn't fill the context. A truncated page ends with [truncated].

Example with parameters

curl https://api.libremodel.ai/v1/chat/completions \
  -H "Authorization: Bearer $LIBREMODEL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash-1017",
    "messages": [{"role": "user", "content": "Read https://docs.python.org/3/whatsnew/ and list the main changes of the latest version."}],
    "tools": [{
      "type": "openrouter:web_fetch",
      "parameters": {"max_uses": 5, "max_content_tokens": 50000, "allowed_domains": ["docs.python.org"]}
    }]
  }'

Response format

The model gets each fetch as JSON. If it worked:

JSON
{
  "url": "https://docs.python.org/3/whatsnew/",
  "title": "What's New in Python",
  "content": "# What's New in Python\n\n...",
  "status": "completed",
  "retrieved_at": "2026-12-02T14:03:11.512Z"
}

url is the final address, after the redirects. If it didn't:

JSON
{
  "url": "https://example.com/missing",
  "status": "failed",
  "error": "HTTP 404: Not Found"
}

The error says why, for example:

  • HTTP 404: Not Found, or the code the site answered with.
  • unsupported content type: image/png. Web fetch reads web pages, text and PDF
  • no readable text: the page is empty or needs JavaScript to show its content
  • the URL's domain must appear in the conversation: fetch URLs the user gave, or from search results or fetched pages
  • the domain of example.com is blocked for this request
  • no more web fetches are available for this request

The model reads the error and goes on. The pages it read go into the url_citation annotations, like search results.

Usage tracking

In Chat Completions and Responses, usage.server_tool_use_details counts the fetches in tool_calls_requested and tool_calls_executed, next to the searches. In Anthropic Messages, usage.server_tool_use brings web_fetch_requests.

Pricing

  • Each fetch is free.
  • The content goes into the model's input, so it is charged as input tokens, at the model's price, every time it is sent again: in each later step of the same request, and in the next turns if your history keeps it. max_content_tokens caps it.
  • What the request cost comes in usage.cost.
  • If your balance does not cover another step, the model stops fetching and answers with what it has: you never get a 402 in the middle of an answer.

Errors

CaseAnswer
An Uncensored model400 invalid_request, with the message in Which models
An engine other than auto, native or openrouter400 invalid_request: Unsupported web fetch engine
A parameter out of range, or max_tool_calls outside 1 to 30400 invalid_request, with the parameter in the message
n greater than 1400 invalid_request
A function of yours named web_fetch400 invalid_request: rename it
A page that can't be readThe model gets failed with the reason, and answers anyway

Next steps

  • Web search: let the model find the pages first.
  • Files: send a PDF or an Office document inside the request, images included.
  • Tool calling: your own functions, next to the server tools.