Optionalfields: Partial<ChatXAIInput>OptionalsearchDefault search parameters for the Live Search API.
Return profiling information for the model.
Provides information about the model's capabilities and constraints, including token limits, multimodal support, and advanced features like tool calling and structured output.
An object describing the model's capabilities and constraints
Protected_OptionaldefaultRole: "function" | "user" | "system" | "developer" | "assistant" | "tool"Protected_Protected_Get the effective search parameters, merging defaults with call options.
Optionaloptions: unknownCall options that may contain search parameters
Merged search parameters or undefined if none are configured
Protected_Check if any built-in tools (like live_search) are in the tools list.
Optionaltools: any[]List of tools to check
true if any built-in tools are present
Optionalkwargs: Partial<ChatXAICallOptions>Optionaloptions: anyOptionaloptions: anyFormats tools to xAI/OpenAI format, preserving provider-specific definitions.
The tools to format
The formatted tools
Optionalconfig: anyOptionalconfig: anyOptionalconfig: anyStaticlc_
xAI chat model integration.
The xAI API is compatible to the OpenAI API with some limitations.
Setup: Install
@langchain/xaiand set an environment variable namedXAI_API_KEY.Constructor args
Runtime args
Runtime args can be passed as the second argument to any of the base runnable methods
.invoke..stream,.batch, etc. They can also be passed via.withConfig, or the second arg in.bindTools, like shown in the examples below:Examples
Instantiate
Invoking
Streaming Chunks
Aggregate Streamed Chunks
Bind tools
Structured Output
Server Tool Calling (Live Search)
xAI supports server-side tools that are executed by the API rather than requiring client-side execution. The
live_searchtool enables the model to search the web for real-time information.