Skip to content

Conversation

@christian-bromann
Copy link
Member

This PR adds support for Anthropic's Web Fetch tool (web_fetch_20250910) to @langchain/anthropic, enabling Claude to retrieve full content from specified web pages and PDF documents.

Usage

import { ChatAnthropic, tools } from "@langchain/anthropic";

const model = new ChatAnthropic({
  model: "claude-sonnet-4-5",
  clientOptions: {
    defaultHeaders: { "anthropic-beta": "web-fetch-2025-09-10" },
  },
});

// Basic usage
const response = await model.invoke(
  "Analyze the content at https://example.com/article",
  { tools: [tools.webFetch_20250910()] }
);

// Combined with web search
const response = await model.invoke(
  "Find articles about AI and analyze the most relevant one",
  {
    tools: [
      tools.webSearch_20250305({ maxUses: 3 }),
      tools.webFetch_20250910({ maxUses: 5, citations: { enabled: true } }),
    ],
  }
);

Notes

  • Requires beta header anthropic-beta: web-fetch-2025-09-10
  • ⚠️ Security consideration: Only use in trusted environments or when handling non-sensitive data (see docs)

Related

@changeset-bot
Copy link

changeset-bot bot commented Dec 2, 2025

🦋 Changeset detected

Latest commit: 6f83fef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@langchain/anthropic Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@hntrl hntrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that your note about needing the beta flag in the chat model initializer is a red herring -- adding the tool type to that betas map should add those beta flags automatically

@christian-bromann
Copy link
Member Author

@hntrl good call, removed the note to avoid confusion.

@github-actions github-actions bot added examples and removed examples labels Dec 8, 2025
Base automatically changed from cb/anthropic-websearch to main December 8, 2025 22:48
@christian-bromann christian-bromann merged commit 4836f6c into main Dec 8, 2025
7 checks passed
@christian-bromann christian-bromann deleted the cb/anthropic-webfetch branch December 8, 2025 22:50
@github-actions github-actions bot mentioned this pull request Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants