Skip to content

Commit 6830e26

Browse files
add docs
1 parent d502a32 commit 6830e26

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
@@ -182,6 +182,68 @@ const response = await llm.invoke("Latest news about AI?", {
182182

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

185+
### Web Fetch Tool
186+
187+
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.
188+
189+
> **⚠️ 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.
190+
191+
```typescript
192+
import { ChatAnthropic, webFetch_20250910 } from "@langchain/anthropic";
193+
194+
const llm = new ChatAnthropic({
195+
model: "claude-sonnet-4-5-20250929",
196+
});
197+
198+
// Basic usage - fetch content from a URL
199+
const response = await llm.invoke(
200+
"Please analyze the content at https://example.com/article",
201+
{ tools: [webFetch_20250910()] }
202+
);
203+
```
204+
205+
The web fetch tool supports several configuration options:
206+
207+
```typescript
208+
const response = await llm.invoke(
209+
"Summarize this research paper: https://arxiv.org/abs/2024.12345",
210+
{
211+
tools: [
212+
webFetch_20250910({
213+
// Maximum number of times the tool can be used in the API request
214+
maxUses: 5,
215+
// Only fetch from these domains
216+
allowedDomains: ["arxiv.org", "example.com"],
217+
// Or block specific domains (cannot be used with allowedDomains)
218+
// blockedDomains: ["example.com"],
219+
// Enable citations for fetched content (optional, unlike web search)
220+
citations: { enabled: true },
221+
// Maximum content length in tokens (helps control token usage)
222+
maxContentTokens: 50000,
223+
}),
224+
],
225+
}
226+
);
227+
```
228+
229+
You can combine web fetch with web search for comprehensive information gathering:
230+
231+
```typescript
232+
import { webSearch_20250305, webFetch_20250910 } from "@langchain/anthropic";
233+
234+
const response = await llm.invoke(
235+
"Find recent articles about quantum computing and analyze the most relevant one",
236+
{
237+
tools: [
238+
webSearch_20250305({ maxUses: 3 }),
239+
webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),
240+
],
241+
}
242+
);
243+
```
244+
245+
For more information, see [Anthropic's Web Fetch Tool documentation](https://docs.anthropic.com/en/docs/build-with-claude/tool-use/web-fetch-tool).
246+
185247
## Development
186248

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

0 commit comments

Comments
 (0)