Skip to content

Conversation

@christian-bromann
Copy link
Member

This PR adds support for OpenAI's web search tool, enabling models to search the web for up-to-date information before generating responses.

Usage

import { ChatOpenAI, tools } from "@langchain/openai";

const model = new ChatOpenAI({ model: "gpt-4o" });

// Basic usage
const response = await model.invoke("What are today's top news stories?", {
  tools: [tools.webSearch()],
});

// With options
const response = await model.invoke("Local weather forecast", {
  tools: [tools.webSearch({
    userLocation: {
      type: "approximate",
      country: "US",
      city: "San Francisco",
    },
    filters: { allowedDomains: ["weather.gov"] },
  })],
});

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

🦋 Changeset detected

Latest commit: 6b2cf1c

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

This PR includes changesets to release 5 packages
Name Type
@langchain/openai Patch
@langchain/classic Patch
@langchain/community Patch
@langchain/deepseek Patch
@langchain/xai 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

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