Skip to content

Support server tool calling in @langchain/xai #9465

@christian-bromann

Description

@christian-bromann

Privileged issue

  • I am a LangChain maintainer, or was asked directly by a LangChain maintainer to create an issue here.

Issue Content

Technically something like this should work:

import { createAgent } from "langchain";
import { ChatXAI } from "@langchain/xai";

const model = new ChatXAI({
  model: "grok-4-fast",
});

const agent = createAgent({
  model,
  tools: [
    {
      type: "web_search",
      filters: { excluded_domains: ["wikipedia.org"] },
    },
  ],
});

const result = await agent.invoke({ messages: "What is LangChainJS?" });

console.log(result);

However our @langchain/xai integration seems outdated and doesn't support latest features we have in the ChatOpenAI class. We should revise the integration and bring it up to speed.

Any community contribution is welcome!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedThis would make a good PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions