Skip to content

Commit 7799988

Browse files
add docs
1 parent 27e489e commit 7799988

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

libs/providers/langchain-anthropic/README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,68 @@ const response = await llm.invoke("Latest news about AI?", {
179179

180180
For more information, see [Anthropic's Web Search Tool documentation](https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-search-tool).
181181

182+
### Web Fetch Tool
183+
184+
The web fetch tool (`webFetch_20250910`) allows Claude to retrieve full content from specified web pages and PDF documents. Claude can only fetch URLs that have been explicitly provided by the user or that come from previous web search or web fetch results.
185+
186+
> **⚠️ Security Warning:** Enabling the web fetch tool in environments where Claude processes untrusted input alongside sensitive data poses data exfiltration risks. We recommend only using this tool in trusted environments or when handling non-sensitive data.
187+
188+
```typescript
189+
import { ChatAnthropic, webFetch_20250910 } from "@langchain/anthropic";
190+
191+
const llm = new ChatAnthropic({
192+
model: "claude-sonnet-4-5-20250929",
193+
});
194+
195+
// Basic usage - fetch content from a URL
196+
const response = await llm.invoke(
197+
"Please analyze the content at https://example.com/article",
198+
{ tools: [webFetch_20250910()] }
199+
);
200+
```
201+
202+
The web fetch tool supports several configuration options:
203+
204+
```typescript
205+
const response = await llm.invoke(
206+
"Summarize this research paper: https://arxiv.org/abs/2024.12345",
207+
{
208+
tools: [
209+
webFetch_20250910({
210+
// Maximum number of times the tool can be used in the API request
211+
maxUses: 5,
212+
// Only fetch from these domains
213+
allowedDomains: ["arxiv.org", "example.com"],
214+
// Or block specific domains (cannot be used with allowedDomains)
215+
// blockedDomains: ["example.com"],
216+
// Enable citations for fetched content (optional, unlike web search)
217+
citations: { enabled: true },
218+
// Maximum content length in tokens (helps control token usage)
219+
maxContentTokens: 50000,
220+
}),
221+
],
222+
}
223+
);
224+
```
225+
226+
You can combine web fetch with web search for comprehensive information gathering:
227+
228+
```typescript
229+
import { webSearch_20250305, webFetch_20250910 } from "@langchain/anthropic";
230+
231+
const response = await llm.invoke(
232+
"Find recent articles about quantum computing and analyze the most relevant one",
233+
{
234+
tools: [
235+
webSearch_20250305({ maxUses: 3 }),
236+
webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),
237+
],
238+
}
239+
);
240+
```
241+
242+
For more information, see [Anthropic's Web Fetch Tool documentation](https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool).
243+
182244
## Development
183245

184246
To develop the Anthropic package, you'll need to follow these instructions:

0 commit comments

Comments
 (0)