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
- You add
{"type": "openrouter:web_fetch"}to thetoolsarray. - 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.
- The page is fetched and turned into text.
- The text, with its title and URL, goes back to the model.
- 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"}]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://api.libremodel.ai/v1", api_key=os.environ["LIBREMODEL_API_KEY"])
response = client.chat.completions.create(
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"}],
)
print(response.choices[0].message.content)const response = await fetch('https://api.libremodel.ai/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LIBREMODEL_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
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' }],
}),
})
const data = await response.json()
console.log(data.choices[0].message.content)import os
from openai import OpenAI
client = OpenAI(base_url="https://api.libremodel.ai/v1", api_key=os.environ["LIBREMODEL_API_KEY"])
response = client.responses.create(
model="deepseek-v4.1-flash-1017",
store=False,
input="Summarize https://en.wikipedia.org/wiki/Large_language_model in five bullet points.",
tools=[{"type": "openrouter:web_fetch"}],
)
print(response.output_text)import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.libremodel.ai", api_key=os.environ["LIBREMODEL_API_KEY"])
message = client.messages.create(
model="deepseek-v4.1-flash-1017",
max_tokens=2048,
messages=[{"role": "user", "content": "Summarize https://en.wikipedia.org/wiki/Large_language_model in five bullet points."}],
tools=[{"type": "web_fetch_20250910", "name": "web_fetch", "max_uses": 3}],
)
print(message.content[-1].text)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:
{
"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:
{
"type": "openrouter:web_fetch",
"parameters": {
"max_uses": 10,
"max_content_tokens": 20000,
"allowed_domains": ["docs.python.org"],
"blocked_domains": ["example.com"]
}
}| Parameter | Type | Default | Description |
|---|---|---|---|
engine | string | auto | auto, native or openrouter, which do the same. Any other engine returns 400 invalid_request |
max_uses | integer | 50 | Fetches per request, at most. Higher values count as 50 |
max_content_tokens | integer | 25,000 | Tokens of content per fetch, from 1,000 to 100,000. Longer content is truncated. A lower value counts as 1,000 |
allowed_domains | string[] | — | Fetch only from these domains |
blocked_domains | string[] | — | 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.
| Name | Where the parameters go |
|---|---|
openrouter:web_fetch | In parameters, as in the table above |
web_fetch | At 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.comin the conversation lets the model readdocs.example.com,api.docs.example.comandexample.com. - On sites where each user has their own subdomain, such as
github.ioorvercel.app, only the host that appeared counts. - On sites where each user has their own path, such as
github.com,docs.google.comor link shorteners, only that path counts:github.com/acme/appopensgithub.com/acme/, not all ofgithub.com. - Only
httpandhttpsURLs 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-AgentLibremodel-WebFetch/1.0 (+https://libremodel.ai).
What it reads
| Content | What the model gets |
|---|---|
| HTML pages | The main content of the page, as Markdown: headings, paragraphs, lists, tables and links |
| Text: plain text, Markdown, JSON, CSV, XML | The text as it is |
The 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 files | failed, 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 asfailedwithno readable text. - Each fetch downloads up to 10 MB and takes up to 15 seconds. Past that, it comes back as
failed.
Domain filtering
{
"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
{
"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"]}
}]
}'import os
from openai import OpenAI
client = OpenAI(base_url="https://api.libremodel.ai/v1", api_key=os.environ["LIBREMODEL_API_KEY"])
response = client.chat.completions.create(
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"]},
}],
)
print(response.choices[0].message.content)Response format
The model gets each fetch as JSON. If it worked:
{
"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:
{
"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 PDFno readable text: the page is empty or needs JavaScript to show its contentthe URL's domain must appear in the conversation: fetch URLs the user gave, or from search results or fetched pagesthe domain of example.com is blocked for this requestno 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_tokenscaps 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
402in the middle of an answer.
Errors
| Case | Answer |
|---|---|
| An Uncensored model | 400 invalid_request, with the message in Which models |
An engine other than auto, native or openrouter | 400 invalid_request: Unsupported web fetch engine |
A parameter out of range, or max_tool_calls outside 1 to 30 | 400 invalid_request, with the parameter in the message |
n greater than 1 | 400 invalid_request |
A function of yours named web_fetch | 400 invalid_request: rename it |
| A page that can't be read | The 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.