@langchain/xai 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/chat_models/completions.cjs +1 -1
- package/dist/chat_models/completions.cjs.map +1 -1
- package/dist/chat_models/completions.d.cts +5 -0
- package/dist/chat_models/completions.d.cts.map +1 -1
- package/dist/chat_models/completions.d.ts +5 -0
- package/dist/chat_models/completions.d.ts.map +1 -1
- package/dist/chat_models/completions.js +1 -1
- package/dist/chat_models/completions.js.map +1 -1
- package/dist/chat_models/responses-types.d.cts +37 -7
- package/dist/chat_models/responses-types.d.cts.map +1 -1
- package/dist/chat_models/responses-types.d.ts +37 -7
- package/dist/chat_models/responses-types.d.ts.map +1 -1
- package/dist/chat_models/responses.cjs +5 -0
- package/dist/chat_models/responses.cjs.map +1 -1
- package/dist/chat_models/responses.d.cts +2 -1
- package/dist/chat_models/responses.d.cts.map +1 -1
- package/dist/chat_models/responses.d.ts +2 -1
- package/dist/chat_models/responses.d.ts.map +1 -1
- package/dist/chat_models/responses.js +5 -0
- package/dist/chat_models/responses.js.map +1 -1
- package/dist/tools/code_execution.cjs +52 -0
- package/dist/tools/code_execution.cjs.map +1 -0
- package/dist/tools/code_execution.d.cts +64 -0
- package/dist/tools/code_execution.d.cts.map +1 -0
- package/dist/tools/code_execution.d.ts +64 -0
- package/dist/tools/code_execution.d.ts.map +1 -0
- package/dist/tools/code_execution.js +50 -0
- package/dist/tools/code_execution.js.map +1 -0
- package/dist/tools/collections_search.cjs +60 -0
- package/dist/tools/collections_search.cjs.map +1 -0
- package/dist/tools/collections_search.d.cts +90 -0
- package/dist/tools/collections_search.d.cts.map +1 -0
- package/dist/tools/collections_search.d.ts +90 -0
- package/dist/tools/collections_search.d.ts.map +1 -0
- package/dist/tools/collections_search.js +58 -0
- package/dist/tools/collections_search.js.map +1 -0
- package/dist/tools/index.cjs +11 -1
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.d.cts +10 -1
- package/dist/tools/index.d.cts.map +1 -1
- package/dist/tools/index.d.ts +10 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +12 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/live_search.cjs +14 -0
- package/dist/tools/live_search.cjs.map +1 -1
- package/dist/tools/live_search.d.cts +14 -1
- package/dist/tools/live_search.d.cts.map +1 -1
- package/dist/tools/live_search.d.ts +14 -1
- package/dist/tools/live_search.d.ts.map +1 -1
- package/dist/tools/live_search.js +14 -1
- package/dist/tools/live_search.js.map +1 -1
- package/dist/tools/web_search.cjs +57 -0
- package/dist/tools/web_search.cjs.map +1 -0
- package/dist/tools/web_search.d.cts +104 -0
- package/dist/tools/web_search.d.cts.map +1 -0
- package/dist/tools/web_search.d.ts +104 -0
- package/dist/tools/web_search.d.ts.map +1 -0
- package/dist/tools/web_search.js +55 -0
- package/dist/tools/web_search.js.map +1 -0
- package/dist/tools/x_search.cjs +63 -0
- package/dist/tools/x_search.cjs.map +1 -0
- package/dist/tools/x_search.d.cts +145 -0
- package/dist/tools/x_search.d.cts.map +1 -0
- package/dist/tools/x_search.d.ts +145 -0
- package/dist/tools/x_search.d.ts.map +1 -0
- package/dist/tools/x_search.js +61 -0
- package/dist/tools/x_search.js.map +1 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completions.js","names":["tool: ChatXAIToolType","fields?: Partial<ChatXAIInput>","options: this[\"ParsedCallOptions\"]","options?: this[\"ParsedCallOptions\"]","tools?: ChatXAIToolType[]","tools: ChatXAIToolType[]","kwargs?: Partial<ChatXAICallOptions>","extra?: { streaming?: boolean }","params: ChatXAICompletionsInvocationParams","request:\n | OpenAIClient.Chat.ChatCompletionCreateParamsStreaming\n | OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming","options?: OpenAICoreRequestOptions","filteredTools: OpenAIClient.ChatCompletionTool[] | undefined","delta: Record<string, any>","rawResponse: OpenAIClient.ChatCompletionChunk","defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"","message: OpenAIClient.ChatCompletionMessage & {\n reasoning_content?: string;\n }","rawResponse: OpenAIClient.ChatCompletion","PROFILES","outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>","config?: StructuredOutputMethodOptions<boolean>"],"sources":["../../src/chat_models/completions.ts"],"sourcesContent":["import {\n BaseLanguageModelInput,\n StructuredOutputMethodOptions,\n} from \"@langchain/core/language_models/base\";\nimport {\n BaseChatModelCallOptions,\n BindToolsInput,\n LangSmithParams,\n type BaseChatModelParams,\n} from \"@langchain/core/language_models/chat_models\";\nimport {\n isLangChainTool,\n convertToOpenAITool,\n} from \"@langchain/core/utils/function_calling\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Serialized } from \"@langchain/core/load/serializable\";\nimport {\n AIMessageChunk,\n BaseMessage,\n type UsageMetadata,\n} from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport {\n type OpenAICoreRequestOptions,\n type OpenAIClient,\n ChatOpenAICompletions,\n} from \"@langchain/openai\";\nimport {\n buildSearchParametersPayload,\n filterXAIBuiltInTools,\n mergeSearchParams,\n type XAISearchParameters,\n type XAISearchParametersPayload,\n} from \"../live_search.js\";\nimport PROFILES from \"../profiles.js\";\nimport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAILiveSearchTool,\n} from \"../tools/live_search.js\";\n\nexport type OpenAIToolChoice =\n | OpenAIClient.ChatCompletionToolChoiceOption\n | \"any\"\n | string;\n\n/**\n * Union type for all xAI built-in server-side tools.\n */\nexport type XAIBuiltInTool = XAILiveSearchTool;\n\n/**\n * Set of all supported xAI built-in server-side tool types.\n * This allows us to easily extend support for future built-in tools\n * without changing the core detection logic.\n */\nconst XAI_BUILT_IN_TOOL_TYPES = new Set<XAILiveSearchTool[\"type\"] | string>([\n XAI_LIVE_SEARCH_TOOL_TYPE,\n]);\n\n/**\n * Tool type that includes both standard tools and xAI built-in tools.\n */\ntype ChatXAIToolType =\n | BindToolsInput\n | OpenAIClient.ChatCompletionTool\n | XAIBuiltInTool;\n\n/**\n * xAI-specific invocation parameters that extend the OpenAI completion params\n * with xAI's search_parameters field.\n */\nexport type ChatXAICompletionsInvocationParams = Omit<\n OpenAIClient.Chat.Completions.ChatCompletionCreateParams,\n \"messages\"\n> & {\n /**\n * Search parameters for xAI's Live Search API.\n * When present, enables the model to search the web for real-time information.\n */\n search_parameters?: XAISearchParametersPayload;\n};\n\n/**\n * xAI-specific additional kwargs that may be present on AI messages.\n * Includes xAI-specific fields like reasoning_content.\n */\nexport interface XAIAdditionalKwargs {\n /**\n * The reasoning content from xAI models that support chain-of-thought reasoning.\n * This contains the model's internal reasoning process.\n */\n reasoning_content?: string;\n /**\n * Tool calls made by the model.\n */\n tool_calls?: OpenAIClient.ChatCompletionMessageToolCall[];\n /**\n * Additional properties that may be present.\n */\n [key: string]: unknown;\n}\n\n/**\n * xAI-specific response metadata that may include usage information.\n */\nexport interface XAIResponseMetadata {\n /**\n * Token usage information.\n */\n usage?: UsageMetadata;\n /**\n * Additional metadata properties.\n */\n [key: string]: unknown;\n}\n\n/**\n * Checks if a tool is an xAI built-in tool (like live_search).\n * Built-in tools are executed server-side by the xAI API.\n *\n * @param tool - The tool to check\n * @returns true if the tool is an xAI built-in tool\n */\nexport function isXAIBuiltInTool(\n tool: ChatXAIToolType\n): tool is XAIBuiltInTool {\n return (\n typeof tool === \"object\" &&\n tool !== null &&\n \"type\" in tool &&\n typeof (tool as { type?: unknown }).type === \"string\" &&\n XAI_BUILT_IN_TOOL_TYPES.has((tool as { type: string }).type)\n );\n}\n\nexport interface ChatXAICallOptions extends BaseChatModelCallOptions {\n headers?: Record<string, string>;\n /**\n * A list of tools the model may call.\n * Can include standard function tools and xAI built-in tools like `{ type: \"live_search\" }`.\n *\n * @example\n * ```typescript\n * // Using built-in live_search tool\n * const llm = new ChatXAI().bindTools([{ type: \"live_search\" }]);\n * const result = await llm.invoke(\"What happened in tech news today?\");\n * ```\n */\n tools?: ChatXAIToolType[];\n tool_choice?: OpenAIToolChoice | string | \"auto\" | \"any\";\n /**\n * Search parameters for xAI's Live Search API.\n * Enables the model to search the web for real-time information.\n *\n * @note This is an alternative to using `tools: [{ type: \"live_search\" }]`.\n * The Live Search API parameters approach may be deprecated in favor of\n * the tool-based approach.\n *\n * @example\n * ```typescript\n * const result = await llm.invoke(\"What's the latest news?\", {\n * searchParameters: {\n * mode: \"auto\",\n * max_search_results: 5,\n * }\n * });\n * ```\n */\n searchParameters?: XAISearchParameters;\n}\n\nexport interface ChatXAIInput extends BaseChatModelParams {\n /**\n * The xAI API key to use for requests.\n * @default process.env.XAI_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n * @default \"grok-beta\"\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n * @default 0.7\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n /**\n * Default search parameters for xAI's Live Search API.\n * When set, these parameters will be applied to all requests unless\n * overridden in the call options.\n *\n * @example\n * ```typescript\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * searchParameters: {\n * mode: \"auto\",\n * max_search_results: 5,\n * }\n * });\n * ```\n */\n searchParameters?: XAISearchParameters;\n}\n\n/**\n * xAI chat model integration.\n *\n * The xAI API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/xai` and set an environment variable named `XAI_API_KEY`.\n *\n * ```bash\n * npm install @langchain/xai\n * export XAI_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_xai.ChatXAI.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_xai.ChatXAICallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatXAI } from '@langchain/xai';\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatXAI({\n * model: \"grok-beta\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Server Tool Calling (Live Search)</strong></summary>\n *\n * xAI supports server-side tools that are executed by the API rather than\n * requiring client-side execution. The `live_search` tool enables the model\n * to search the web for real-time information.\n *\n * ```typescript\n * // Method 1: Using the built-in live_search tool\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * temperature: 0,\n * });\n *\n * const llmWithSearch = llm.bindTools([{ type: \"live_search\" }]);\n * const result = await llmWithSearch.invoke(\"What happened in tech news today?\");\n * console.log(result.content);\n * // The model will search the web and include real-time information in its response\n * ```\n *\n * ```typescript\n * // Method 2: Using searchParameters for more control\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * searchParameters: {\n * mode: \"auto\", // \"auto\" | \"on\" | \"off\"\n * max_search_results: 5,\n * from_date: \"2024-01-01\", // ISO date string\n * return_citations: true,\n * }\n * });\n *\n * const result = await llm.invoke(\"What are the latest AI developments?\");\n * ```\n *\n * ```typescript\n * // Method 3: Override search parameters per request\n * const result = await llm.invoke(\"Find recent news about SpaceX\", {\n * searchParameters: {\n * mode: \"on\",\n * max_search_results: 10,\n * sources: [\n * { type: \"web\", allowed_websites: [\"spacex.com\", \"nasa.gov\"] },\n * ],\n * }\n * });\n * ```\n * </details>\n *\n * <br />\n */\nexport class ChatXAI extends ChatOpenAICompletions<ChatXAICallOptions> {\n static lc_name() {\n return \"ChatXAI\";\n }\n\n _llmType() {\n return \"xai\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n apiKey: \"XAI_API_KEY\",\n };\n }\n\n lc_serializable = true;\n\n lc_namespace = [\"langchain\", \"chat_models\", \"xai\"];\n\n /**\n * Default search parameters for the Live Search API.\n */\n searchParameters?: XAISearchParameters;\n\n constructor(fields?: Partial<ChatXAIInput>) {\n const apiKey = fields?.apiKey || getEnvironmentVariable(\"XAI_API_KEY\");\n if (!apiKey) {\n throw new Error(\n `xAI API key not found. Please set the XAI_API_KEY environment variable or provide the key into \"apiKey\" field.`\n );\n }\n\n super({\n ...fields,\n model: fields?.model || \"grok-beta\",\n apiKey,\n configuration: {\n baseURL: \"https://api.x.ai/v1\",\n },\n });\n\n this.searchParameters = fields?.searchParameters;\n }\n\n toJSON(): Serialized {\n const result = super.toJSON();\n\n if (\n \"kwargs\" in result &&\n typeof result.kwargs === \"object\" &&\n result.kwargs != null\n ) {\n delete result.kwargs.openai_api_key;\n delete result.kwargs.configuration;\n }\n\n return result;\n }\n\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams {\n const params = super.getLsParams(options);\n params.ls_provider = \"xai\";\n return params;\n }\n\n /**\n * Get the effective search parameters, merging defaults with call options.\n * @param options Call options that may contain search parameters\n * @returns Merged search parameters or undefined if none are configured\n */\n protected _getEffectiveSearchParameters(\n options?: this[\"ParsedCallOptions\"]\n ): XAISearchParameters | undefined {\n return mergeSearchParams(this.searchParameters, options?.searchParameters);\n }\n\n /**\n * Check if any built-in tools (like live_search) are in the tools list.\n * @param tools List of tools to check\n * @returns true if any built-in tools are present\n */\n protected _hasBuiltInTools(tools?: ChatXAIToolType[]): boolean {\n return tools?.some(isXAIBuiltInTool) ?? false;\n }\n\n /**\n * Formats tools to xAI/OpenAI format, preserving provider-specific definitions.\n *\n * @param tools The tools to format\n * @returns The formatted tools\n */\n formatStructuredToolToXAI(\n tools: ChatXAIToolType[]\n ): (OpenAIClient.ChatCompletionTool | XAIBuiltInTool)[] | undefined {\n if (!tools || !tools.length) {\n return undefined;\n }\n return tools.map((tool) => {\n // 1. Check for provider definition first (from xaiLiveSearch factory)\n if (isLangChainTool(tool) && tool.extras?.providerToolDefinition) {\n return tool.extras.providerToolDefinition as XAIBuiltInTool;\n }\n // 2. Check for built-in tools (legacy { type: \"live_search\" })\n if (isXAIBuiltInTool(tool)) {\n return tool;\n }\n // 3. Convert standard tools to OpenAI format\n return convertToOpenAITool(tool) as OpenAIClient.ChatCompletionTool;\n });\n }\n\n override bindTools(\n tools: ChatXAIToolType[],\n kwargs?: Partial<ChatXAICallOptions>\n ): Runnable<BaseLanguageModelInput, AIMessageChunk, ChatXAICallOptions> {\n return this.withConfig({\n tools: this.formatStructuredToolToXAI(tools),\n ...kwargs,\n } as Partial<ChatXAICallOptions>);\n }\n\n /** @internal */\n override invocationParams(\n options?: this[\"ParsedCallOptions\"],\n extra?: { streaming?: boolean }\n ): ChatXAICompletionsInvocationParams {\n const baseParams = super.invocationParams(options, extra);\n\n // Cast to xAI-specific params type\n const params: ChatXAICompletionsInvocationParams = { ...baseParams };\n\n // Check if live_search tool is being used\n // We also need to extract params from the tool definition if present\n const liveSearchTool = options?.tools?.find(isXAIBuiltInTool) as\n | XAILiveSearchTool\n | undefined;\n\n const mergedSearchParams = mergeSearchParams(\n this.searchParameters,\n options?.searchParameters,\n liveSearchTool\n );\n\n // Add search_parameters if needed\n if (mergedSearchParams) {\n params.search_parameters =\n buildSearchParametersPayload(mergedSearchParams);\n }\n\n return params;\n }\n\n async completionWithRetry(\n request: OpenAIClient.Chat.ChatCompletionCreateParamsStreaming,\n options?: OpenAICoreRequestOptions\n ): Promise<AsyncIterable<OpenAIClient.Chat.Completions.ChatCompletionChunk>>;\n\n async completionWithRetry(\n request: OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming,\n options?: OpenAICoreRequestOptions\n ): Promise<OpenAIClient.Chat.Completions.ChatCompletion>;\n\n /**\n * Calls the xAI API with retry logic in case of failures.\n * @param request The request to send to the xAI API.\n * @param options Optional configuration for the API call.\n * @returns The response from the xAI API.\n */\n async completionWithRetry(\n request:\n | OpenAIClient.Chat.ChatCompletionCreateParamsStreaming\n | OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming,\n options?: OpenAICoreRequestOptions\n ): Promise<\n | AsyncIterable<OpenAIClient.Chat.Completions.ChatCompletionChunk>\n | OpenAIClient.Chat.Completions.ChatCompletion\n > {\n delete request.frequency_penalty;\n delete request.presence_penalty;\n delete request.logit_bias;\n delete request.functions;\n\n const newRequestMessages = request.messages.map((msg) => {\n if (!msg.content) {\n return {\n ...msg,\n content: \"\",\n };\n }\n return msg;\n });\n\n let filteredTools: OpenAIClient.ChatCompletionTool[] | undefined;\n if (request.tools) {\n filteredTools = filterXAIBuiltInTools({\n tools: request.tools,\n excludedTypes: [XAI_LIVE_SEARCH_TOOL_TYPE],\n }) as OpenAIClient.ChatCompletionTool[] | undefined;\n }\n\n const newRequest = {\n ...request,\n messages: newRequestMessages,\n tools: filteredTools,\n };\n\n if (newRequest.stream === true) {\n return super.completionWithRetry(newRequest, options);\n }\n\n return super.completionWithRetry(newRequest, options);\n }\n\n protected override _convertCompletionsDeltaToBaseMessageChunk(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delta: Record<string, any>,\n rawResponse: OpenAIClient.ChatCompletionChunk,\n defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"\n ): AIMessageChunk {\n const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(\n delta,\n rawResponse,\n defaultRole\n ) as AIMessageChunk;\n\n // Cast to xAI-specific types for proper typing\n const responseMetadata =\n messageChunk.response_metadata as XAIResponseMetadata;\n\n // Make concatenating chunks work without merge warning\n if (!rawResponse.choices[0]?.finish_reason) {\n delete responseMetadata.usage;\n delete messageChunk.usage_metadata;\n } else {\n messageChunk.usage_metadata = responseMetadata.usage;\n }\n return messageChunk;\n }\n\n protected override _convertCompletionsMessageToBaseMessage(\n message: OpenAIClient.ChatCompletionMessage & {\n reasoning_content?: string;\n },\n rawResponse: OpenAIClient.ChatCompletion\n ): AIMessageChunk {\n const langChainMessage = super._convertCompletionsMessageToBaseMessage(\n message,\n rawResponse\n ) as AIMessageChunk;\n\n // Cast additional_kwargs to xAI-specific type and add reasoning_content\n const additionalKwargs =\n langChainMessage.additional_kwargs as XAIAdditionalKwargs;\n additionalKwargs.reasoning_content = message.reasoning_content;\n\n return langChainMessage;\n }\n\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatXAI({ model: \"grok-beta\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile {\n return PROFILES[this.model] ?? {};\n }\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n > {\n const ensuredConfig = { ...config };\n if (ensuredConfig?.method === undefined) {\n ensuredConfig.method = \"functionCalling\";\n }\n return super.withStructuredOutput<RunOut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,QACP,QAAO;IACL,GAAG;IACH,SAAS;GACV;AAEH,UAAO;EACR,EAAC;EAEF,IAAIC;AACJ,MAAI,QAAQ,OACV,gBAAgB,sBAAsB;GACpC,OAAO,QAAQ;GACf,eAAe,CAAC,yBAA0B;EAC3C,EAAC;EAGJ,MAAM,aAAa;GACjB,GAAG;GACH,UAAU;GACV,OAAO;EACR;AAED,MAAI,WAAW,WAAW,KACxB,QAAO,MAAM,oBAAoB,YAAY,QAAQ;AAGvD,SAAO,MAAM,oBAAoB,YAAY,QAAQ;CACtD;CAED,AAAmB,2CAEjBC,OACAC,aACAC,aAOgB;EAChB,MAAM,eAAe,MAAM,2CACzB,OACA,aACA,YACD;EAGD,MAAM,mBACJ,aAAa;AAGf,MAAI,CAAC,YAAY,QAAQ,IAAI,eAAe;GAC1C,OAAO,iBAAiB;GACxB,OAAO,aAAa;EACrB,OACC,aAAa,iBAAiB,iBAAiB;AAEjD,SAAO;CACR;CAED,AAAmB,wCACjBC,SAGAC,aACgB;EAChB,MAAM,mBAAmB,MAAM,wCAC7B,SACA,YACD;EAGD,MAAM,mBACJ,iBAAiB;EACnB,iBAAiB,oBAAoB,QAAQ;AAE7C,SAAO;CACR;;;;;;;;;;;;;;;;;;CAmBD,IAAI,UAAwB;AAC1B,SAAOC,iBAAS,KAAK,UAAU,CAAE;CAClC;CAqCD,AAAS,qBAIPC,cAIAC,QAMI;EACJ,MAAM,gBAAgB,EAAE,GAAG,OAAQ;AACnC,MAAI,eAAe,WAAW,QAC5B,cAAc,SAAS;AAEzB,SAAO,MAAM,qBAAgC,cAAc,cAAc;CAC1E;AACF"}
|
|
1
|
+
{"version":3,"file":"completions.js","names":["tool: ChatXAIToolType","fields?: Partial<ChatXAIInput>","options: this[\"ParsedCallOptions\"]","options?: this[\"ParsedCallOptions\"]","tools?: ChatXAIToolType[]","tools: ChatXAIToolType[]","kwargs?: Partial<ChatXAICallOptions>","extra?: { streaming?: boolean }","params: ChatXAICompletionsInvocationParams","request:\n | OpenAIClient.Chat.ChatCompletionCreateParamsStreaming\n | OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming","options?: OpenAICoreRequestOptions","filteredTools: OpenAIClient.ChatCompletionTool[] | undefined","delta: Record<string, any>","rawResponse: OpenAIClient.ChatCompletionChunk","defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"","message: OpenAIClient.ChatCompletionMessage & {\n reasoning_content?: string;\n }","rawResponse: OpenAIClient.ChatCompletion","PROFILES","outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>","config?: StructuredOutputMethodOptions<boolean>"],"sources":["../../src/chat_models/completions.ts"],"sourcesContent":["import {\n BaseLanguageModelInput,\n StructuredOutputMethodOptions,\n} from \"@langchain/core/language_models/base\";\nimport {\n BaseChatModelCallOptions,\n BindToolsInput,\n LangSmithParams,\n type BaseChatModelParams,\n} from \"@langchain/core/language_models/chat_models\";\nimport {\n isLangChainTool,\n convertToOpenAITool,\n} from \"@langchain/core/utils/function_calling\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { Serialized } from \"@langchain/core/load/serializable\";\nimport {\n AIMessageChunk,\n BaseMessage,\n type UsageMetadata,\n} from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport {\n type OpenAICoreRequestOptions,\n type OpenAIClient,\n ChatOpenAICompletions,\n} from \"@langchain/openai\";\nimport {\n buildSearchParametersPayload,\n filterXAIBuiltInTools,\n mergeSearchParams,\n type XAISearchParameters,\n type XAISearchParametersPayload,\n} from \"../live_search.js\";\nimport PROFILES from \"../profiles.js\";\nimport {\n XAI_LIVE_SEARCH_TOOL_TYPE,\n XAILiveSearchTool,\n} from \"../tools/live_search.js\";\n\nexport type OpenAIToolChoice =\n | OpenAIClient.ChatCompletionToolChoiceOption\n | \"any\"\n | string;\n\n/**\n * Union type for all xAI built-in server-side tools.\n */\nexport type XAIBuiltInTool = XAILiveSearchTool;\n\n/**\n * Set of all supported xAI built-in server-side tool types.\n * This allows us to easily extend support for future built-in tools\n * without changing the core detection logic.\n */\nconst XAI_BUILT_IN_TOOL_TYPES = new Set<XAILiveSearchTool[\"type\"] | string>([\n XAI_LIVE_SEARCH_TOOL_TYPE,\n]);\n\n/**\n * Tool type that includes both standard tools and xAI built-in tools.\n */\ntype ChatXAIToolType =\n | BindToolsInput\n | OpenAIClient.ChatCompletionTool\n | XAIBuiltInTool;\n\n/**\n * xAI-specific invocation parameters that extend the OpenAI completion params\n * with xAI's search_parameters field.\n */\nexport type ChatXAICompletionsInvocationParams = Omit<\n OpenAIClient.Chat.Completions.ChatCompletionCreateParams,\n \"messages\"\n> & {\n /**\n * Search parameters for xAI's Live Search API.\n * When present, enables the model to search the web for real-time information.\n */\n search_parameters?: XAISearchParametersPayload;\n};\n\n/**\n * xAI-specific additional kwargs that may be present on AI messages.\n * Includes xAI-specific fields like reasoning_content.\n */\nexport interface XAIAdditionalKwargs {\n /**\n * The reasoning content from xAI models that support chain-of-thought reasoning.\n * This contains the model's internal reasoning process.\n */\n reasoning_content?: string;\n /**\n * Tool calls made by the model.\n */\n tool_calls?: OpenAIClient.ChatCompletionMessageToolCall[];\n /**\n * Additional properties that may be present.\n */\n [key: string]: unknown;\n}\n\n/**\n * xAI-specific response metadata that may include usage information.\n */\nexport interface XAIResponseMetadata {\n /**\n * Token usage information.\n */\n usage?: UsageMetadata;\n /**\n * Additional metadata properties.\n */\n [key: string]: unknown;\n}\n\n/**\n * Checks if a tool is an xAI built-in tool (like live_search).\n * Built-in tools are executed server-side by the xAI API.\n *\n * @param tool - The tool to check\n * @returns true if the tool is an xAI built-in tool\n */\nexport function isXAIBuiltInTool(\n tool: ChatXAIToolType\n): tool is XAIBuiltInTool {\n return (\n typeof tool === \"object\" &&\n tool !== null &&\n \"type\" in tool &&\n typeof (tool as { type?: unknown }).type === \"string\" &&\n XAI_BUILT_IN_TOOL_TYPES.has((tool as { type: string }).type)\n );\n}\n\nexport interface ChatXAICallOptions extends BaseChatModelCallOptions {\n headers?: Record<string, string>;\n /**\n * A list of tools the model may call.\n * Can include standard function tools and xAI built-in tools like `{ type: \"live_search\" }`.\n *\n * @example\n * ```typescript\n * // Using built-in live_search tool\n * const llm = new ChatXAI().bindTools([{ type: \"live_search\" }]);\n * const result = await llm.invoke(\"What happened in tech news today?\");\n * ```\n */\n tools?: ChatXAIToolType[];\n tool_choice?: OpenAIToolChoice | string | \"auto\" | \"any\";\n /**\n * Search parameters for xAI's Live Search API.\n * Enables the model to search the web for real-time information.\n *\n * @note This is an alternative to using `tools: [{ type: \"live_search\" }]`.\n * The Live Search API parameters approach may be deprecated in favor of\n * the tool-based approach.\n *\n * @example\n * ```typescript\n * const result = await llm.invoke(\"What's the latest news?\", {\n * searchParameters: {\n * mode: \"auto\",\n * max_search_results: 5,\n * }\n * });\n * ```\n */\n searchParameters?: XAISearchParameters;\n}\n\nexport interface ChatXAIInput extends BaseChatModelParams {\n /**\n * The xAI API key to use for requests.\n * @default process.env.XAI_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n * @default \"grok-beta\"\n */\n model?: string;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n * Alias for `stopSequences`\n */\n stop?: Array<string>;\n /**\n * Up to 4 sequences where the API will stop generating further tokens. The\n * returned text will not contain the stop sequence.\n */\n stopSequences?: Array<string>;\n /**\n * Whether or not to stream responses.\n */\n streaming?: boolean;\n /**\n * The temperature to use for sampling.\n * @default 0.7\n */\n temperature?: number;\n /**\n * The maximum number of tokens that the model can process in a single response.\n * This limits ensures computational efficiency and resource management.\n */\n maxTokens?: number;\n /**\n * Default search parameters for xAI's Live Search API.\n * When set, these parameters will be applied to all requests unless\n * overridden in the call options.\n *\n * @example\n * ```typescript\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * searchParameters: {\n * mode: \"auto\",\n * max_search_results: 5,\n * }\n * });\n * ```\n */\n searchParameters?: XAISearchParameters;\n /**\n * The base URL for the xAI API.\n * @default \"https://api.x.ai/v1\"\n */\n baseURL?: string;\n}\n\n/**\n * xAI chat model integration.\n *\n * The xAI API is compatible to the OpenAI API with some limitations.\n *\n * Setup:\n * Install `@langchain/xai` and set an environment variable named `XAI_API_KEY`.\n *\n * ```bash\n * npm install @langchain/xai\n * export XAI_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_xai.ChatXAI.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/_langchain_xai.ChatXAICallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // When calling `.withConfig`, call options should be passed via the first argument\n * const llmWithArgsBound = llm.withConfig({\n * stop: [\"\\n\"],\n * tools: [...],\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatXAI } from '@langchain/xai';\n *\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * temperature: 0,\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessage {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"tokenUsage\": {\n * \"completionTokens\": 82,\n * \"promptTokens\": 20,\n * \"totalTokens\": 102\n * },\n * \"finish_reason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"The\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" French\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" translation\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" of\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" \\\"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"I\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \" love\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ...\n * AIMessageChunk {\n * \"content\": \".\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": null\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"The French translation of \\\"I love programming\\\" is \\\"J'aime programmer\\\". In this sentence, \\\"J'aime\\\" is the first person singular conjugation of the French verb \\\"aimer\\\" which means \\\"to love\\\", and \\\"programmer\\\" is the French infinitive for \\\"to program\\\". I hope this helps! Let me know if you have any other questions.\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const llmForToolCalling = new ChatXAI({\n * model: \"grok-beta\",\n * temperature: 0,\n * // other params...\n * });\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llmForToolCalling.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_cd34'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_68rf'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call',\n * id: 'call_f81z'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\n * type: 'tool_call',\n * id: 'call_8byt'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llmForToolCalling.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: \"Why don't cats play poker in the wild?\",\n * punchline: 'Because there are too many cheetahs.'\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Server Tool Calling (Live Search)</strong></summary>\n *\n * xAI supports server-side tools that are executed by the API rather than\n * requiring client-side execution. The `live_search` tool enables the model\n * to search the web for real-time information.\n *\n * ```typescript\n * // Method 1: Using the built-in live_search tool\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * temperature: 0,\n * });\n *\n * const llmWithSearch = llm.bindTools([{ type: \"live_search\" }]);\n * const result = await llmWithSearch.invoke(\"What happened in tech news today?\");\n * console.log(result.content);\n * // The model will search the web and include real-time information in its response\n * ```\n *\n * ```typescript\n * // Method 2: Using searchParameters for more control\n * const llm = new ChatXAI({\n * model: \"grok-beta\",\n * searchParameters: {\n * mode: \"auto\", // \"auto\" | \"on\" | \"off\"\n * max_search_results: 5,\n * from_date: \"2024-01-01\", // ISO date string\n * return_citations: true,\n * }\n * });\n *\n * const result = await llm.invoke(\"What are the latest AI developments?\");\n * ```\n *\n * ```typescript\n * // Method 3: Override search parameters per request\n * const result = await llm.invoke(\"Find recent news about SpaceX\", {\n * searchParameters: {\n * mode: \"on\",\n * max_search_results: 10,\n * sources: [\n * { type: \"web\", allowed_websites: [\"spacex.com\", \"nasa.gov\"] },\n * ],\n * }\n * });\n * ```\n * </details>\n *\n * <br />\n */\nexport class ChatXAI extends ChatOpenAICompletions<ChatXAICallOptions> {\n static lc_name() {\n return \"ChatXAI\";\n }\n\n _llmType() {\n return \"xai\";\n }\n\n get lc_secrets(): { [key: string]: string } | undefined {\n return {\n apiKey: \"XAI_API_KEY\",\n };\n }\n\n lc_serializable = true;\n\n lc_namespace = [\"langchain\", \"chat_models\", \"xai\"];\n\n /**\n * Default search parameters for the Live Search API.\n */\n searchParameters?: XAISearchParameters;\n\n constructor(fields?: Partial<ChatXAIInput>) {\n const apiKey = fields?.apiKey || getEnvironmentVariable(\"XAI_API_KEY\");\n if (!apiKey) {\n throw new Error(\n `xAI API key not found. Please set the XAI_API_KEY environment variable or provide the key into \"apiKey\" field.`\n );\n }\n\n super({\n ...fields,\n model: fields?.model || \"grok-beta\",\n apiKey,\n configuration: {\n baseURL: fields?.baseURL ?? \"https://api.x.ai/v1\",\n },\n });\n\n this.searchParameters = fields?.searchParameters;\n }\n\n toJSON(): Serialized {\n const result = super.toJSON();\n\n if (\n \"kwargs\" in result &&\n typeof result.kwargs === \"object\" &&\n result.kwargs != null\n ) {\n delete result.kwargs.openai_api_key;\n delete result.kwargs.configuration;\n }\n\n return result;\n }\n\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams {\n const params = super.getLsParams(options);\n params.ls_provider = \"xai\";\n return params;\n }\n\n /**\n * Get the effective search parameters, merging defaults with call options.\n * @param options Call options that may contain search parameters\n * @returns Merged search parameters or undefined if none are configured\n */\n protected _getEffectiveSearchParameters(\n options?: this[\"ParsedCallOptions\"]\n ): XAISearchParameters | undefined {\n return mergeSearchParams(this.searchParameters, options?.searchParameters);\n }\n\n /**\n * Check if any built-in tools (like live_search) are in the tools list.\n * @param tools List of tools to check\n * @returns true if any built-in tools are present\n */\n protected _hasBuiltInTools(tools?: ChatXAIToolType[]): boolean {\n return tools?.some(isXAIBuiltInTool) ?? false;\n }\n\n /**\n * Formats tools to xAI/OpenAI format, preserving provider-specific definitions.\n *\n * @param tools The tools to format\n * @returns The formatted tools\n */\n formatStructuredToolToXAI(\n tools: ChatXAIToolType[]\n ): (OpenAIClient.ChatCompletionTool | XAIBuiltInTool)[] | undefined {\n if (!tools || !tools.length) {\n return undefined;\n }\n return tools.map((tool) => {\n // 1. Check for provider definition first (from xaiLiveSearch factory)\n if (isLangChainTool(tool) && tool.extras?.providerToolDefinition) {\n return tool.extras.providerToolDefinition as XAIBuiltInTool;\n }\n // 2. Check for built-in tools (legacy { type: \"live_search\" })\n if (isXAIBuiltInTool(tool)) {\n return tool;\n }\n // 3. Convert standard tools to OpenAI format\n return convertToOpenAITool(tool) as OpenAIClient.ChatCompletionTool;\n });\n }\n\n override bindTools(\n tools: ChatXAIToolType[],\n kwargs?: Partial<ChatXAICallOptions>\n ): Runnable<BaseLanguageModelInput, AIMessageChunk, ChatXAICallOptions> {\n return this.withConfig({\n tools: this.formatStructuredToolToXAI(tools),\n ...kwargs,\n } as Partial<ChatXAICallOptions>);\n }\n\n /** @internal */\n override invocationParams(\n options?: this[\"ParsedCallOptions\"],\n extra?: { streaming?: boolean }\n ): ChatXAICompletionsInvocationParams {\n const baseParams = super.invocationParams(options, extra);\n\n // Cast to xAI-specific params type\n const params: ChatXAICompletionsInvocationParams = { ...baseParams };\n\n // Check if live_search tool is being used\n // We also need to extract params from the tool definition if present\n const liveSearchTool = options?.tools?.find(isXAIBuiltInTool) as\n | XAILiveSearchTool\n | undefined;\n\n const mergedSearchParams = mergeSearchParams(\n this.searchParameters,\n options?.searchParameters,\n liveSearchTool\n );\n\n // Add search_parameters if needed\n if (mergedSearchParams) {\n params.search_parameters =\n buildSearchParametersPayload(mergedSearchParams);\n }\n\n return params;\n }\n\n async completionWithRetry(\n request: OpenAIClient.Chat.ChatCompletionCreateParamsStreaming,\n options?: OpenAICoreRequestOptions\n ): Promise<AsyncIterable<OpenAIClient.Chat.Completions.ChatCompletionChunk>>;\n\n async completionWithRetry(\n request: OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming,\n options?: OpenAICoreRequestOptions\n ): Promise<OpenAIClient.Chat.Completions.ChatCompletion>;\n\n /**\n * Calls the xAI API with retry logic in case of failures.\n * @param request The request to send to the xAI API.\n * @param options Optional configuration for the API call.\n * @returns The response from the xAI API.\n */\n async completionWithRetry(\n request:\n | OpenAIClient.Chat.ChatCompletionCreateParamsStreaming\n | OpenAIClient.Chat.ChatCompletionCreateParamsNonStreaming,\n options?: OpenAICoreRequestOptions\n ): Promise<\n | AsyncIterable<OpenAIClient.Chat.Completions.ChatCompletionChunk>\n | OpenAIClient.Chat.Completions.ChatCompletion\n > {\n delete request.frequency_penalty;\n delete request.presence_penalty;\n delete request.logit_bias;\n delete request.functions;\n\n const newRequestMessages = request.messages.map((msg) => {\n if (!msg.content) {\n return {\n ...msg,\n content: \"\",\n };\n }\n return msg;\n });\n\n let filteredTools: OpenAIClient.ChatCompletionTool[] | undefined;\n if (request.tools) {\n filteredTools = filterXAIBuiltInTools({\n tools: request.tools,\n excludedTypes: [XAI_LIVE_SEARCH_TOOL_TYPE],\n }) as OpenAIClient.ChatCompletionTool[] | undefined;\n }\n\n const newRequest = {\n ...request,\n messages: newRequestMessages,\n tools: filteredTools,\n };\n\n if (newRequest.stream === true) {\n return super.completionWithRetry(newRequest, options);\n }\n\n return super.completionWithRetry(newRequest, options);\n }\n\n protected override _convertCompletionsDeltaToBaseMessageChunk(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n delta: Record<string, any>,\n rawResponse: OpenAIClient.ChatCompletionChunk,\n defaultRole?:\n | \"function\"\n | \"user\"\n | \"system\"\n | \"developer\"\n | \"assistant\"\n | \"tool\"\n ): AIMessageChunk {\n const messageChunk = super._convertCompletionsDeltaToBaseMessageChunk(\n delta,\n rawResponse,\n defaultRole\n ) as AIMessageChunk;\n\n // Cast to xAI-specific types for proper typing\n const responseMetadata =\n messageChunk.response_metadata as XAIResponseMetadata;\n\n // Make concatenating chunks work without merge warning\n if (!rawResponse.choices[0]?.finish_reason) {\n delete responseMetadata.usage;\n delete messageChunk.usage_metadata;\n } else {\n messageChunk.usage_metadata = responseMetadata.usage;\n }\n return messageChunk;\n }\n\n protected override _convertCompletionsMessageToBaseMessage(\n message: OpenAIClient.ChatCompletionMessage & {\n reasoning_content?: string;\n },\n rawResponse: OpenAIClient.ChatCompletion\n ): AIMessageChunk {\n const langChainMessage = super._convertCompletionsMessageToBaseMessage(\n message,\n rawResponse\n ) as AIMessageChunk;\n\n // Cast additional_kwargs to xAI-specific type and add reasoning_content\n const additionalKwargs =\n langChainMessage.additional_kwargs as XAIAdditionalKwargs;\n additionalKwargs.reasoning_content = message.reasoning_content;\n\n return langChainMessage;\n }\n\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatXAI({ model: \"grok-beta\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 128000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile {\n return PROFILES[this.model] ?? {};\n }\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<false>\n ): Runnable<BaseLanguageModelInput, RunOutput>;\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<true>\n ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;\n\n override withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>,\n >(\n outputSchema:\n | InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>,\n config?: StructuredOutputMethodOptions<boolean>\n ):\n | Runnable<BaseLanguageModelInput, RunOutput>\n | Runnable<\n BaseLanguageModelInput,\n { raw: BaseMessage; parsed: RunOutput }\n > {\n const ensuredConfig = { ...config };\n if (ensuredConfig?.method === undefined) {\n ensuredConfig.method = \"functionCalling\";\n }\n return super.withStructuredOutput<RunOutput>(outputSchema, ensuredConfig);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAyDA,MAAM,0BAA0B,IAAI,IAAwC,CAC1E,yBACD;;;;;;;;AAkED,SAAgB,iBACdA,MACwB;AACxB,QACE,OAAO,SAAS,YAChB,SAAS,QACT,UAAU,QACV,OAAQ,KAA4B,SAAS,YAC7C,wBAAwB,IAAK,KAA0B,KAAK;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2dD,IAAa,UAAb,cAA6B,sBAA0C;CACrE,OAAO,UAAU;AACf,SAAO;CACR;CAED,WAAW;AACT,SAAO;CACR;CAED,IAAI,aAAoD;AACtD,SAAO,EACL,QAAQ,cACT;CACF;CAED,kBAAkB;CAElB,eAAe;EAAC;EAAa;EAAe;CAAM;;;;CAKlD;CAEA,YAAYC,QAAgC;EAC1C,MAAM,SAAS,QAAQ,UAAU,uBAAuB,cAAc;AACtE,MAAI,CAAC,OACH,OAAM,IAA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F"}
|
|
@@ -305,16 +305,16 @@ interface XAIResponsesFunctionTool {
|
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* Web search tool definition.
|
|
308
|
-
*
|
|
308
|
+
* Enables the model to search the web and browse pages for real-time information.
|
|
309
309
|
*/
|
|
310
310
|
interface XAIResponsesWebSearchTool {
|
|
311
311
|
type: "web_search";
|
|
312
|
-
/**
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
|
|
312
|
+
/** Domains to exclusively include in the search (max 5). */
|
|
313
|
+
allowed_domains?: string[];
|
|
314
|
+
/** Domains to exclude from the search (max 5). */
|
|
315
|
+
excluded_domains?: string[];
|
|
316
|
+
/** Whether to enable image understanding during search. */
|
|
317
|
+
enable_image_understanding?: boolean;
|
|
318
318
|
}
|
|
319
319
|
/**
|
|
320
320
|
* X search tool definition.
|
|
@@ -1074,6 +1074,21 @@ interface ChatXAIResponsesCallOptions extends BaseChatModelCallOptions {
|
|
|
1074
1074
|
* Reasoning configuration for reasoning models.
|
|
1075
1075
|
*/
|
|
1076
1076
|
reasoning?: XAIResponsesReasoning;
|
|
1077
|
+
/**
|
|
1078
|
+
* A list of tools the model may call.
|
|
1079
|
+
* Includes built-in tools (web_search, x_search, code_interpreter, file_search)
|
|
1080
|
+
* and custom function tools.
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```typescript
|
|
1084
|
+
* import { tools } from "@langchain/xai";
|
|
1085
|
+
*
|
|
1086
|
+
* const result = await llm.invoke("What's happening on X?", {
|
|
1087
|
+
* tools: [tools.xaiWebSearch(), tools.xaiXSearch()],
|
|
1088
|
+
* });
|
|
1089
|
+
* ```
|
|
1090
|
+
*/
|
|
1091
|
+
tools?: XAIResponsesTool[];
|
|
1077
1092
|
/**
|
|
1078
1093
|
* Controls which tool is called by the model.
|
|
1079
1094
|
*/
|
|
@@ -1138,6 +1153,21 @@ interface ChatXAIResponsesInput extends BaseChatModelParams {
|
|
|
1138
1153
|
* Default reasoning configuration.
|
|
1139
1154
|
*/
|
|
1140
1155
|
reasoning?: XAIResponsesReasoning;
|
|
1156
|
+
/**
|
|
1157
|
+
* Default tools to make available to the model.
|
|
1158
|
+
* Can be overridden per-request in call options.
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```typescript
|
|
1162
|
+
* import { ChatXAIResponses, tools } from "@langchain/xai";
|
|
1163
|
+
*
|
|
1164
|
+
* const llm = new ChatXAIResponses({
|
|
1165
|
+
* model: "grok-4-1-fast",
|
|
1166
|
+
* tools: [tools.xaiWebSearch(), tools.xaiCodeExecution()],
|
|
1167
|
+
* });
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
tools?: XAIResponsesTool[];
|
|
1141
1171
|
}
|
|
1142
1172
|
/**
|
|
1143
1173
|
* Invocation parameters for ChatXAIResponses (request params without input).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses-types.d.cts","names":["XAIResponsesInputTextItem","XAIResponsesInputImageItem","XAIResponsesInputFileItem","XAIResponsesInputContentItem","XAIResponsesFunctionToolCall","XAIResponsesWebSearchToolCall","XAIResponsesCodeInterpreterToolCall","XAIResponsesMcpToolCall","XAIResponsesToolCall","XAIResponsesLogprobToken","XAIResponsesLogprobContent","XAIResponsesLogprobs","XAIResponsesPreviousResponse","XAIResponsesFunctionToolOutput","XAIResponsesToolOutput","XAIResponsesMessageRole","XAIResponsesMessage","XAIResponsesInputItem","XAIResponsesInput","XAIResponsesReasoningEffort","XAIResponsesReasoningSummary","XAIResponsesReasoning","XAIResponsesSearchSourceX","XAIResponsesSearchSourceWeb","XAIResponsesSearchSourceRss","XAIResponsesSearchSource","XAIResponsesSearchMode","XAIResponsesSearchParameters","XAIResponsesTextFormatText","XAIResponsesTextFormatJsonObject","XAIResponsesTextFormatJsonSchema","Record","XAIResponsesTextFormat","XAIResponsesText","XAIResponsesFunctionToolFunction","XAIResponsesFunctionTool","XAIResponsesWebSearchTool","XAIResponsesXSearchTool","XAIResponsesFileSearchTool","XAIResponsesCodeInterpreterTool","XAIResponsesMcpTool","XAIResponsesTool","XAIResponsesToolChoiceString","XAIResponsesToolChoiceFunction","XAIResponsesToolChoice","XAIResponsesInclude","XAIResponsesCreateParams","XAIResponsesCreateParamsStreaming","XAIResponsesCreateParamsNonStreaming","XAIResponsesStatus","XAIResponsesObjectType","XAIResponsesOutputTextItem","XAIResponsesOutputContent","XAIResponsesOutputTextContent","XAIResponsesAnnotation","XAIResponsesOutputRefusalContent","XAIResponsesUrlCitationAnnotation","XAIResponsesFileCitationAnnotation","XAIResponsesOutputFunctionCall","XAIResponsesOutputWebSearchCall","XAIResponsesOutputFileSearchCall","XAIResponsesFileSearchResult","XAIResponsesOutputCodeInterpreterCall","XAIResponsesCodeInterpreterResult","XAIResponsesOutputMcpCall","XAIResponsesOutputReasoning","XAIResponsesReasoningSummaryItem","XAIResponsesOutputItem","XAIResponsesUsage","XAIResponsesIncompleteReason","XAIResponsesIncompleteDetails","XAIResponsesDebugOutput","XAIResponsesReasoningResponse","XAIResponse","XAIResponsesStreamEventBase","XAIResponsesStreamEventCreated","XAIResponsesStreamEventInProgress","XAIResponsesStreamEventCompleted","XAIResponsesStreamEventFailed","XAIResponsesStreamEventIncomplete","XAIResponsesStreamEventOutputItemAdded","XAIResponsesStreamEventOutputItemDone","XAIResponsesStreamEventContentPartAdded","XAIResponsesStreamEventContentPartDone","XAIResponsesStreamEventTextDelta","XAIResponsesStreamEventTextDone","XAIResponsesStreamEventFunctionCallArgumentsDelta","XAIResponsesStreamEventFunctionCallArgumentsDone","XAIResponsesStreamEventReasoningSummaryTextDelta","XAIResponsesStreamEventReasoningSummaryTextDone","XAIResponsesStreamEventError","XAIResponsesStreamEvent","BaseChatModelCallOptions","BaseChatModelParams","ChatXAIResponsesCallOptions","ChatXAIResponsesInput","ChatXAIResponsesInvocationParams","Omit"],"sources":["../../src/chat_models/responses-types.d.ts"],"sourcesContent":["/**\n * Text input content item.\n */\nexport interface XAIResponsesInputTextItem {\n type: \"input_text\";\n /** The text content. */\n text: string;\n}\n/**\n * Image input content item.\n * Note: Storing/fetching images is not fully supported.\n */\nexport interface XAIResponsesInputImageItem {\n type: \"input_image\";\n /** Public URL of the image. */\n image_url: string;\n /** Image detail level. */\n detail?: \"high\" | \"low\" | \"auto\";\n}\n/**\n * File input content item.\n */\nexport interface XAIResponsesInputFileItem {\n type: \"input_file\";\n /** File ID from the Files API. */\n file_id: string;\n}\n/**\n * Union type for all input content items.\n */\nexport type XAIResponsesInputContentItem = XAIResponsesInputTextItem | XAIResponsesInputImageItem | XAIResponsesInputFileItem;\n/**\n * Function tool call from a previous response.\n */\nexport interface XAIResponsesFunctionToolCall {\n type: \"function_call\";\n /** The ID of the tool call. */\n id: string;\n /** The ID of the tool call (alias). */\n call_id?: string;\n /** The name of the function. */\n name: string;\n /** The arguments to the function as a JSON string. */\n arguments: string;\n}\n/**\n * Web search tool call from a previous response.\n */\nexport interface XAIResponsesWebSearchToolCall {\n type: \"web_search_call\";\n /** The ID of the tool call. */\n id: string;\n /** The search status. */\n status?: \"in_progress\" | \"searching\" | \"completed\" | \"failed\";\n}\n/**\n * Code interpreter tool call from a previous response.\n */\nexport interface XAIResponsesCodeInterpreterToolCall {\n type: \"code_interpreter_call\";\n /** The ID of the tool call. */\n id: string;\n /** The code to execute. */\n code?: string;\n /** The status of the code interpreter. */\n status?: \"in_progress\" | \"interpreting\" | \"completed\" | \"failed\";\n}\n/**\n * MCP tool call from a previous response.\n */\nexport interface XAIResponsesMcpToolCall {\n type: \"mcp_call\";\n /** The ID of the tool call. */\n id: string;\n /** The MCP server URL. */\n server_url?: string;\n /** The MCP server label. */\n server_label?: string;\n}\n/**\n * Union type for all tool calls from previous responses.\n */\nexport type XAIResponsesToolCall = XAIResponsesFunctionToolCall | XAIResponsesWebSearchToolCall | XAIResponsesCodeInterpreterToolCall | XAIResponsesMcpToolCall;\n/**\n * Log probability information for a token.\n */\nexport interface XAIResponsesLogprobToken {\n /** The token string. */\n token: string;\n /** The log probability of the token. */\n logprob: number;\n /** The bytes representation of the token. */\n bytes?: number[];\n}\n/**\n * Log probability content item.\n */\nexport interface XAIResponsesLogprobContent {\n /** The token. */\n token: string;\n /** The log probability. */\n logprob: number;\n /** The bytes representation. */\n bytes?: number[];\n /** Top log probabilities at this position. */\n top_logprobs?: XAIResponsesLogprobToken[];\n}\n/**\n * Log probabilities from a previous response.\n */\nexport interface XAIResponsesLogprobs {\n /** Log probability content. */\n content?: XAIResponsesLogprobContent[];\n}\n/**\n * Previous response structure that can be included in the input array.\n * Used for multi-turn conversations with assistant outputs.\n */\nexport interface XAIResponsesPreviousResponse {\n /** The type identifier for previous response. */\n type: \"message\";\n /** The role for previous assistant responses. */\n role: \"assistant\";\n /** The text output from the previous response. */\n text?: string;\n /** Refusal message if the model refused to respond. */\n refusal?: string;\n /** Tool calls made in the previous response. */\n tool_calls?: XAIResponsesToolCall[];\n /** Log probabilities from the previous response. */\n logprobs?: XAIResponsesLogprobs;\n}\n/**\n * Function tool call output to provide results back to the model.\n */\nexport interface XAIResponsesFunctionToolOutput {\n type: \"function_call_output\";\n /** The ID of the tool call this output is for. */\n call_id: string;\n /** The output/result of the function call. */\n output: string;\n}\n/**\n * Union type for tool outputs that can be included in input.\n */\nexport type XAIResponsesToolOutput = XAIResponsesFunctionToolOutput;\n/**\n * Message role types.\n */\nexport type XAIResponsesMessageRole = \"user\" | \"assistant\" | \"system\" | \"developer\";\n/**\n * Message input to the model.\n */\nexport interface XAIResponsesMessage {\n /** The role of the message author. */\n role: XAIResponsesMessageRole;\n /** Text, image, or audio input. Can be a string or array of content items. */\n content: string | XAIResponsesInputContentItem[];\n /** Unique identifier for the end-user. Only for `user` messages. */\n name?: string;\n}\n/**\n * Union type for all items that can appear in the input array.\n * Includes messages, previous responses, and tool outputs.\n */\nexport type XAIResponsesInputItem = XAIResponsesMessage | XAIResponsesPreviousResponse | XAIResponsesToolOutput;\n/**\n * Input type - can be a string or array of input items.\n * The array can contain messages, previous responses, and tool outputs.\n */\nexport type XAIResponsesInput = string | XAIResponsesInputItem[];\n/**\n * Reasoning effort level.\n */\nexport type XAIResponsesReasoningEffort = \"low\" | \"medium\" | \"high\";\n/**\n * Reasoning summary style.\n */\nexport type XAIResponsesReasoningSummary = \"auto\" | \"concise\" | \"detailed\";\n/**\n * Reasoning configuration for reasoning models.\n */\nexport interface XAIResponsesReasoning {\n /** The effort level for reasoning. Defaults to `medium`. */\n effort?: XAIResponsesReasoningEffort;\n /** The summary style for reasoning output. */\n summary?: XAIResponsesReasoningSummary;\n}\n/**\n * X (Twitter) search source configuration.\n */\nexport interface XAIResponsesSearchSourceX {\n type: \"x\";\n /** X handles to include in search. */\n included_x_handles?: string[];\n /** X handles to exclude from search. */\n excluded_x_handles?: string[];\n /** Minimum favorite count for posts. */\n post_favorite_count?: number;\n /** Minimum view count for posts. */\n post_view_count?: number;\n}\n/**\n * Web search source configuration.\n */\nexport interface XAIResponsesSearchSourceWeb {\n type: \"web\";\n /** Whitelist of allowed websites (max 5). */\n allowed_websites?: string[];\n /** Blacklist of excluded websites (max 5). */\n excluded_websites?: string[];\n /** ISO alpha-2 country code. */\n country?: string;\n /** Whether to enable safe search. Defaults to `true`. */\n safe_search?: boolean;\n}\n/**\n * RSS/News search source configuration.\n */\nexport interface XAIResponsesSearchSourceRss {\n type: \"rss\";\n /** Links of RSS feeds. */\n links?: string[];\n}\n/**\n * Union type for all search sources.\n */\nexport type XAIResponsesSearchSource = XAIResponsesSearchSourceX | XAIResponsesSearchSourceWeb | XAIResponsesSearchSourceRss;\n/**\n * Search mode options.\n */\nexport type XAIResponsesSearchMode = \"off\" | \"on\" | \"auto\";\n/**\n * Search parameters configuration.\n * Takes precedence over `web_search_preview` tool.\n */\nexport interface XAIResponsesSearchParameters {\n /** Start date for search results (ISO-8601 YYYY-MM-DD). */\n from_date?: string;\n /** End date for search results (ISO-8601 YYYY-MM-DD). */\n to_date?: string;\n /** Maximum number of search results. Defaults to 15 (range: 1-30). */\n max_search_results?: number;\n /** Search mode. Defaults to `on`. */\n mode?: XAIResponsesSearchMode;\n /** Whether to return citations. Defaults to `true`. */\n return_citations?: boolean;\n /** List of search sources. If empty, searches web and X. */\n sources?: XAIResponsesSearchSource[];\n}\n/**\n * Plain text format.\n */\nexport interface XAIResponsesTextFormatText {\n type: \"text\";\n}\n/**\n * JSON object format.\n */\nexport interface XAIResponsesTextFormatJsonObject {\n type: \"json_object\";\n}\n/**\n * JSON schema format.\n */\nexport interface XAIResponsesTextFormatJsonSchema {\n type: \"json_schema\";\n /** JSON schema definition. */\n schema: Record<string, unknown>;\n /** Compatibility field for strict mode. */\n strict?: boolean;\n}\n/**\n * Union type for all text response formats.\n */\nexport type XAIResponsesTextFormat = XAIResponsesTextFormatText | XAIResponsesTextFormatJsonObject | XAIResponsesTextFormatJsonSchema;\n/**\n * Text response configuration.\n */\nexport interface XAIResponsesText {\n /** The format for text response. */\n format?: XAIResponsesTextFormat;\n}\n/**\n * Function tool parameters using JSON Schema.\n */\nexport interface XAIResponsesFunctionToolFunction {\n /** The name of the function. */\n name: string;\n /** A description of what the function does. */\n description?: string;\n /** The parameters the function accepts, described as a JSON Schema object. */\n parameters: Record<string, unknown>;\n}\n/**\n * Function tool definition.\n */\nexport interface XAIResponsesFunctionTool {\n type: \"function\";\n /** The function definition. */\n function: XAIResponsesFunctionToolFunction;\n}\n/**\n * Web search tool definition.\n * Compatibility fields (search_context_size, user_location, filters) are rejected if set.\n */\nexport interface XAIResponsesWebSearchTool {\n type: \"web_search\";\n /** @deprecated Rejected if set. */\n search_context_size?: never;\n /** @deprecated Rejected if set. */\n user_location?: never;\n /** @deprecated Rejected if set. */\n filters?: never;\n}\n/**\n * X search tool definition.\n */\nexport interface XAIResponsesXSearchTool {\n type: \"x_search\";\n /** X handles to allow in search. */\n allowed_x_handles?: string[];\n /** X handles to exclude from search. */\n excluded_x_handles?: string[];\n /** Whether to enable image understanding. */\n enable_image_understanding?: boolean;\n /** Whether to enable video understanding. */\n enable_video_understanding?: boolean;\n /** Start date for search (ISO-8601). */\n from_date?: string;\n /** End date for search (ISO-8601). */\n to_date?: string;\n}\n/**\n * File search tool definition.\n */\nexport interface XAIResponsesFileSearchTool {\n type: \"file_search\";\n /** List of vector store IDs to search. */\n vector_store_ids?: string[];\n}\n/**\n * Code interpreter tool definition.\n */\nexport interface XAIResponsesCodeInterpreterTool {\n type: \"code_interpreter\";\n}\n/**\n * MCP (Model Context Protocol) tool definition.\n */\nexport interface XAIResponsesMcpTool {\n type: \"mcp\";\n /** The URL of the MCP server. */\n server_url: string;\n /** The label for the MCP server. */\n server_label: string;\n}\n/**\n * Union type for all tool definitions.\n */\nexport type XAIResponsesTool = XAIResponsesFunctionTool | XAIResponsesWebSearchTool | XAIResponsesXSearchTool | XAIResponsesFileSearchTool | XAIResponsesCodeInterpreterTool | XAIResponsesMcpTool;\n/**\n * String tool choice options.\n */\nexport type XAIResponsesToolChoiceString = \"none\" | \"auto\" | \"required\";\n/**\n * Function tool choice object.\n */\nexport interface XAIResponsesToolChoiceFunction {\n type: \"function\";\n function: {\n /** The name of the function to call. */\n name: string;\n };\n}\n/**\n * Tool choice configuration.\n */\nexport type XAIResponsesToolChoice = XAIResponsesToolChoiceString | XAIResponsesToolChoiceFunction;\n/**\n * Additional output data to include in the response.\n */\nexport type XAIResponsesInclude = \"reasoning.encrypted_content\";\n/**\n * xAI Responses API request body parameters.\n */\nexport interface XAIResponsesCreateParams {\n /**\n * The input passed to the model.\n * Can be text (string) or an array of message objects.\n */\n input: XAIResponsesInput;\n /**\n * Model name for the model to use (e.g., from xAI console).\n */\n model?: string;\n /**\n * Whether to process the response asynchronously in the background.\n * Note: Unsupported.\n * @default false\n */\n background?: boolean;\n /**\n * What additional output data to include in the response.\n * Currently supported: `reasoning.encrypted_content`.\n */\n include?: XAIResponsesInclude[];\n /**\n * An alternate way to specify the system prompt.\n * Cannot be used with `previous_response_id`.\n */\n instructions?: string;\n /**\n * Whether to return log probabilities of the output tokens.\n * @default false\n */\n logprobs?: boolean;\n /**\n * Max number of tokens that can be generated.\n * Includes both output and reasoning tokens.\n */\n max_output_tokens?: number;\n /**\n * Metadata for the request.\n * Note: Not supported. Maintained for compatibility.\n */\n metadata?: Record<string, unknown>;\n /**\n * Whether to allow the model to run parallel tool calls.\n * @default true\n */\n parallel_tool_calls?: boolean;\n /**\n * The ID of the previous response from the model.\n * Use this to create multi-turn conversations.\n */\n previous_response_id?: string;\n /**\n * Reasoning configuration.\n * Only for reasoning models.\n */\n reasoning?: XAIResponsesReasoning;\n /**\n * Set parameters for searched data.\n * Takes precedence over `web_search_preview` tool.\n */\n search_parameters?: XAIResponsesSearchParameters;\n /**\n * Service tier for the request.\n * Note: Not supported. Maintained for compatibility.\n */\n service_tier?: string;\n /**\n * Whether to store the input message(s) and response.\n * @default true\n */\n store?: boolean;\n /**\n * If set, partial message deltas will be sent as server-sent events.\n * @default false\n */\n stream?: boolean;\n /**\n * Sampling temperature between 0 and 2.\n * Higher values make output more random, lower values more deterministic.\n * @default 1\n */\n temperature?: number;\n /**\n * Settings for customizing a text response.\n */\n text?: XAIResponsesText;\n /**\n * Controls which tool is called by the model.\n */\n tool_choice?: XAIResponsesToolChoice;\n /**\n * A list of tools the model may call.\n * Maximum of 128 tools.\n */\n tools?: XAIResponsesTool[];\n /**\n * Number of most likely tokens to return at each token position.\n * Range: 0-8. Requires `logprobs` to be `true`.\n */\n top_logprobs?: number;\n /**\n * Nucleus sampling probability mass.\n * The model considers results of tokens with top_p probability mass.\n * @default 1\n */\n top_p?: number;\n /**\n * Truncation strategy.\n * Note: Not supported. Maintained for compatibility.\n */\n truncation?: string;\n /**\n * Unique identifier representing your end-user.\n * Used for monitoring and abuse detection.\n */\n user?: string;\n}\n/**\n * Streaming variant of the request params.\n */\nexport interface XAIResponsesCreateParamsStreaming extends XAIResponsesCreateParams {\n stream: true;\n}\n/**\n * Non-streaming variant of the request params.\n */\nexport interface XAIResponsesCreateParamsNonStreaming extends XAIResponsesCreateParams {\n stream?: false;\n}\n/**\n * Response status values.\n */\nexport type XAIResponsesStatus = \"completed\" | \"in_progress\" | \"incomplete\";\n/**\n * Response object type literal.\n */\nexport type XAIResponsesObjectType = \"response\";\n/**\n * Text output item in the response.\n */\nexport interface XAIResponsesOutputTextItem {\n type: \"message\";\n /** The role of the message (always assistant for outputs). */\n role: \"assistant\";\n /** The text content of the message. */\n content: XAIResponsesOutputContent[];\n /** The ID of this output item. */\n id?: string;\n /** The status of this output item. */\n status?: XAIResponsesStatus;\n}\n/**\n * Text content in an output message.\n */\nexport interface XAIResponsesOutputTextContent {\n type: \"output_text\";\n /** The text content. */\n text: string;\n /** Annotations on the text (e.g., citations). */\n annotations?: XAIResponsesAnnotation[];\n}\n/**\n * Refusal content in an output message.\n */\nexport interface XAIResponsesOutputRefusalContent {\n type: \"refusal\";\n /** The refusal message. */\n refusal: string;\n}\n/**\n * Union type for output content items.\n */\nexport type XAIResponsesOutputContent = XAIResponsesOutputTextContent | XAIResponsesOutputRefusalContent;\n/**\n * Citation annotation for web search results.\n */\nexport interface XAIResponsesUrlCitationAnnotation {\n type: \"url_citation\";\n /** Start index in the text. */\n start_index: number;\n /** End index in the text. */\n end_index: number;\n /** The URL being cited. */\n url: string;\n /** The title of the cited page. */\n title?: string;\n}\n/**\n * File citation annotation.\n */\nexport interface XAIResponsesFileCitationAnnotation {\n type: \"file_citation\";\n /** Start index in the text. */\n start_index: number;\n /** End index in the text. */\n end_index: number;\n /** The file ID being cited. */\n file_id: string;\n /** The filename. */\n filename?: string;\n}\n/**\n * Union type for all annotation types.\n */\nexport type XAIResponsesAnnotation = XAIResponsesUrlCitationAnnotation | XAIResponsesFileCitationAnnotation;\n/**\n * Function call output item.\n */\nexport interface XAIResponsesOutputFunctionCall {\n type: \"function_call\";\n /** The ID of the function call. */\n id: string;\n /** The ID of the function call (alias). */\n call_id?: string;\n /** The name of the function being called. */\n name: string;\n /** The arguments to the function as a JSON string. */\n arguments: string;\n /** The status of the function call. */\n status?: XAIResponsesStatus;\n}\n/**\n * Web search call output item.\n */\nexport interface XAIResponsesOutputWebSearchCall {\n type: \"web_search_call\";\n /** The ID of the web search call. */\n id: string;\n /** The status of the web search. */\n status?: \"in_progress\" | \"searching\" | \"completed\" | \"failed\";\n}\n/**\n * File search call output item.\n */\nexport interface XAIResponsesOutputFileSearchCall {\n type: \"file_search_call\";\n /** The ID of the file search call. */\n id: string;\n /** The status of the file search. */\n status?: \"in_progress\" | \"searching\" | \"completed\" | \"failed\";\n /** The search queries used. */\n queries?: string[];\n /** The search results. */\n results?: XAIResponsesFileSearchResult[];\n}\n/**\n * File search result item.\n */\nexport interface XAIResponsesFileSearchResult {\n /** The file ID. */\n file_id: string;\n /** The filename. */\n filename?: string;\n /** The score/relevance of the result. */\n score?: number;\n /** The matched text content. */\n text?: string;\n}\n/**\n * Code interpreter call output item.\n */\nexport interface XAIResponsesOutputCodeInterpreterCall {\n type: \"code_interpreter_call\";\n /** The ID of the code interpreter call. */\n id: string;\n /** The code being executed. */\n code?: string;\n /** The status of the code interpreter. */\n status?: \"in_progress\" | \"interpreting\" | \"completed\" | \"failed\";\n /** The results of the code execution. */\n results?: XAIResponsesCodeInterpreterResult[];\n}\n/**\n * Code interpreter result item.\n */\nexport interface XAIResponsesCodeInterpreterResult {\n type: \"logs\" | \"image\";\n /** The log output (for type \"logs\"). */\n logs?: string;\n /** The image data (for type \"image\"). */\n image?: {\n /** The base64-encoded image data. */\n data?: string;\n /** The MIME type of the image. */\n media_type?: string;\n };\n}\n/**\n * MCP call output item.\n */\nexport interface XAIResponsesOutputMcpCall {\n type: \"mcp_call\";\n /** The ID of the MCP call. */\n id: string;\n /** The MCP server URL. */\n server_url?: string;\n /** The MCP server label. */\n server_label?: string;\n /** The status of the MCP call. */\n status?: \"in_progress\" | \"completed\" | \"failed\";\n}\n/**\n * Reasoning output item.\n */\nexport interface XAIResponsesOutputReasoning {\n type: \"reasoning\";\n /** The ID of the reasoning item. */\n id?: string;\n /** Summary of the reasoning. */\n summary?: XAIResponsesReasoningSummaryItem[];\n /** Encrypted reasoning content (if included). */\n encrypted_content?: string;\n}\n/**\n * Reasoning summary item.\n */\nexport interface XAIResponsesReasoningSummaryItem {\n type: \"summary_text\";\n /** The summary text. */\n text: string;\n}\n/**\n * Union type for all response output items.\n */\nexport type XAIResponsesOutputItem = XAIResponsesOutputTextItem | XAIResponsesOutputFunctionCall | XAIResponsesOutputWebSearchCall | XAIResponsesOutputFileSearchCall | XAIResponsesOutputCodeInterpreterCall | XAIResponsesOutputMcpCall | XAIResponsesOutputReasoning;\n/**\n * Token usage information for the response.\n */\nexport interface XAIResponsesUsage {\n /** Number of tokens in the input/prompt. */\n input_tokens: number;\n /** Number of tokens in the output/completion. */\n output_tokens: number;\n /** Total number of tokens used. */\n total_tokens: number;\n /** Detailed breakdown of input tokens. */\n input_tokens_details?: {\n /** Cached tokens from previous requests. */\n cached_tokens?: number;\n };\n /** Detailed breakdown of output tokens. */\n output_tokens_details?: {\n /** Tokens used for reasoning. */\n reasoning_tokens?: number;\n };\n}\n/**\n * Reason for incomplete response.\n */\nexport type XAIResponsesIncompleteReason = \"max_output_tokens\" | \"content_filter\" | \"turn_limit\" | \"tool_use_limit\";\n/**\n * Details about why a response is incomplete.\n */\nexport interface XAIResponsesIncompleteDetails {\n /** The reason the response is incomplete. */\n reason?: XAIResponsesIncompleteReason;\n}\n/**\n * Debug output information (when available).\n */\nexport interface XAIResponsesDebugOutput {\n /** Debug model information. */\n model_info?: Record<string, unknown>;\n /** Additional debug data. */\n [key: string]: unknown;\n}\n/**\n * Reasoning configuration echoed in the response.\n */\nexport interface XAIResponsesReasoningResponse {\n /** The effort level used for reasoning. */\n effort?: XAIResponsesReasoningEffort;\n /** The summary style used. */\n summary?: XAIResponsesReasoningSummary;\n}\n/**\n * xAI Responses API response body.\n */\nexport interface XAIResponse {\n /**\n * Unique ID of the response.\n */\n id: string;\n /**\n * The object type of this resource. Always set to `response`.\n */\n object: XAIResponsesObjectType;\n /**\n * The Unix timestamp (in seconds) for the response creation time.\n */\n created_at: number;\n /**\n * Model name used to generate the response.\n */\n model: string;\n /**\n * Status of the response.\n */\n status: XAIResponsesStatus;\n /**\n * The response generated by the model.\n */\n output: XAIResponsesOutputItem[];\n /**\n * Whether to allow the model to run parallel tool calls.\n */\n parallel_tool_calls?: boolean;\n /**\n * Whether to store the input message(s) and response.\n * @default true\n */\n store?: boolean;\n /**\n * Settings for customizing a text response.\n */\n text?: XAIResponsesText;\n /**\n * Controls which tool is called by the model.\n */\n tool_choice?: XAIResponsesToolChoice;\n /**\n * A list of tools the model may call.\n * Maximum of 128 tools.\n */\n tools?: XAIResponsesTool[];\n /**\n * Whether to process the response asynchronously in the background.\n * Note: Unsupported.\n * @default false\n */\n background?: boolean | null;\n /**\n * Debug output information (when available).\n */\n debug_output?: XAIResponsesDebugOutput | null;\n /**\n * Details about why the response is incomplete (if status is \"incomplete\").\n */\n incomplete_details?: XAIResponsesIncompleteDetails | null;\n /**\n * Max number of tokens that can be generated.\n * Includes both output and reasoning tokens.\n */\n max_output_tokens?: number | null;\n /**\n * Only included for compatibility.\n */\n metadata?: Record<string, unknown> | null;\n /**\n * The ID of the previous response from the model.\n */\n previous_response_id?: string | null;\n /**\n * Reasoning configuration used for the response.\n */\n reasoning?: XAIResponsesReasoningResponse | null;\n /**\n * Sampling temperature used (between 0 and 2).\n * @default 1\n */\n temperature?: number | null;\n /**\n * Nucleus sampling probability mass used.\n * @default 1\n */\n top_p?: number | null;\n /**\n * Token usage information.\n */\n usage?: XAIResponsesUsage | null;\n /**\n * Unique identifier representing your end-user.\n * Used for monitoring and abuse detection.\n */\n user?: string | null;\n}\n/**\n * Base streaming event structure.\n */\nexport interface XAIResponsesStreamEventBase {\n /** The type of the streaming event. */\n type: string;\n}\n/**\n * Response created event.\n */\nexport interface XAIResponsesStreamEventCreated extends XAIResponsesStreamEventBase {\n type: \"response.created\";\n /** The response object. */\n response: XAIResponse;\n}\n/**\n * Response in progress event.\n */\nexport interface XAIResponsesStreamEventInProgress extends XAIResponsesStreamEventBase {\n type: \"response.in_progress\";\n /** The response object. */\n response: XAIResponse;\n}\n/**\n * Response completed event.\n */\nexport interface XAIResponsesStreamEventCompleted extends XAIResponsesStreamEventBase {\n type: \"response.completed\";\n /** The completed response object. */\n response: XAIResponse;\n}\n/**\n * Response failed event.\n */\nexport interface XAIResponsesStreamEventFailed extends XAIResponsesStreamEventBase {\n type: \"response.failed\";\n /** The failed response object. */\n response: XAIResponse;\n /** Error information. */\n error?: {\n /** Error code. */\n code?: string;\n /** Error message. */\n message?: string;\n };\n}\n/**\n * Response incomplete event.\n */\nexport interface XAIResponsesStreamEventIncomplete extends XAIResponsesStreamEventBase {\n type: \"response.incomplete\";\n /** The incomplete response object. */\n response: XAIResponse;\n}\n/**\n * Output item added event.\n */\nexport interface XAIResponsesStreamEventOutputItemAdded extends XAIResponsesStreamEventBase {\n type: \"response.output_item.added\";\n /** The index of the output item. */\n output_index: number;\n /** The output item that was added. */\n item: XAIResponsesOutputItem;\n}\n/**\n * Output item done event.\n */\nexport interface XAIResponsesStreamEventOutputItemDone extends XAIResponsesStreamEventBase {\n type: \"response.output_item.done\";\n /** The index of the output item. */\n output_index: number;\n /** The completed output item. */\n item: XAIResponsesOutputItem;\n}\n/**\n * Content part added event.\n */\nexport interface XAIResponsesStreamEventContentPartAdded extends XAIResponsesStreamEventBase {\n type: \"response.content_part.added\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The content part that was added. */\n part: XAIResponsesOutputContent;\n}\n/**\n * Content part done event.\n */\nexport interface XAIResponsesStreamEventContentPartDone extends XAIResponsesStreamEventBase {\n type: \"response.content_part.done\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The completed content part. */\n part: XAIResponsesOutputContent;\n}\n/**\n * Text delta event (streaming text).\n */\nexport interface XAIResponsesStreamEventTextDelta extends XAIResponsesStreamEventBase {\n type: \"response.output_text.delta\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The text delta. */\n delta: string;\n}\n/**\n * Text done event.\n */\nexport interface XAIResponsesStreamEventTextDone extends XAIResponsesStreamEventBase {\n type: \"response.output_text.done\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The complete text. */\n text: string;\n}\n/**\n * Function call arguments delta event.\n */\nexport interface XAIResponsesStreamEventFunctionCallArgumentsDelta extends XAIResponsesStreamEventBase {\n type: \"response.function_call_arguments.delta\";\n /** The index of the output item. */\n output_index: number;\n /** The ID of the function call. */\n call_id: string;\n /** The arguments delta. */\n delta: string;\n}\n/**\n * Function call arguments done event.\n */\nexport interface XAIResponsesStreamEventFunctionCallArgumentsDone extends XAIResponsesStreamEventBase {\n type: \"response.function_call_arguments.done\";\n /** The index of the output item. */\n output_index: number;\n /** The ID of the function call. */\n call_id: string;\n /** The complete arguments. */\n arguments: string;\n}\n/**\n * Reasoning summary text delta event.\n */\nexport interface XAIResponsesStreamEventReasoningSummaryTextDelta extends XAIResponsesStreamEventBase {\n type: \"response.reasoning_summary_text.delta\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the summary part. */\n summary_index: number;\n /** The text delta. */\n delta: string;\n}\n/**\n * Reasoning summary text done event.\n */\nexport interface XAIResponsesStreamEventReasoningSummaryTextDone extends XAIResponsesStreamEventBase {\n type: \"response.reasoning_summary_text.done\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the summary part. */\n summary_index: number;\n /** The complete text. */\n text: string;\n}\n/**\n * Error event.\n */\nexport interface XAIResponsesStreamEventError extends XAIResponsesStreamEventBase {\n type: \"error\";\n /** Error code. */\n code?: string;\n /** Error message. */\n message?: string;\n /** Error parameter. */\n param?: string;\n}\n/**\n * Union type for all streaming events.\n */\nexport type XAIResponsesStreamEvent = XAIResponsesStreamEventCreated | XAIResponsesStreamEventInProgress | XAIResponsesStreamEventCompleted | XAIResponsesStreamEventFailed | XAIResponsesStreamEventIncomplete | XAIResponsesStreamEventOutputItemAdded | XAIResponsesStreamEventOutputItemDone | XAIResponsesStreamEventContentPartAdded | XAIResponsesStreamEventContentPartDone | XAIResponsesStreamEventTextDelta | XAIResponsesStreamEventTextDone | XAIResponsesStreamEventFunctionCallArgumentsDelta | XAIResponsesStreamEventFunctionCallArgumentsDone | XAIResponsesStreamEventReasoningSummaryTextDelta | XAIResponsesStreamEventReasoningSummaryTextDone | XAIResponsesStreamEventError;\nimport type { BaseChatModelCallOptions, BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\n/**\n * Call options for ChatXAIResponses.\n */\nexport interface ChatXAIResponsesCallOptions extends BaseChatModelCallOptions {\n /**\n * Configuration options for a text response from the model.\n */\n text?: XAIResponsesText;\n /**\n * Specify additional output data to include in the model response.\n */\n include?: XAIResponsesInclude[];\n /**\n * The unique ID of the previous response to the model.\n * Use this to create multi-turn conversations.\n */\n previous_response_id?: string;\n /**\n * Search parameters for xAI's search capabilities.\n */\n search_parameters?: XAIResponsesSearchParameters;\n /**\n * Reasoning configuration for reasoning models.\n */\n reasoning?: XAIResponsesReasoning;\n /**\n * Controls which tool is called by the model.\n */\n tool_choice?: XAIResponsesToolChoice;\n /**\n * Whether to allow the model to run parallel tool calls.\n */\n parallel_tool_calls?: boolean;\n}\n/**\n * Input configuration for ChatXAIResponses constructor.\n */\nexport interface ChatXAIResponsesInput extends BaseChatModelParams {\n /**\n * The xAI API key to use for requests.\n * @default process.env.XAI_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n * @default \"grok-3\"\n */\n model?: string;\n /**\n * Whether to stream responses.\n * @default false\n */\n streaming?: boolean;\n /**\n * Sampling temperature between 0 and 2.\n * @default 1\n */\n temperature?: number;\n /**\n * Nucleus sampling probability mass.\n * @default 1\n */\n topP?: number;\n /**\n * Maximum number of tokens to generate.\n */\n maxOutputTokens?: number;\n /**\n * Whether to store the input messages and response.\n * @default true\n */\n store?: boolean;\n /**\n * A unique identifier representing your end-user.\n */\n user?: string;\n /**\n * The base URL for the xAI API.\n * @default \"https://api.x.ai/v1\"\n */\n baseURL?: string;\n /**\n * Default search parameters for xAI's search capabilities.\n */\n searchParameters?: XAIResponsesSearchParameters;\n /**\n * Default reasoning configuration.\n */\n reasoning?: XAIResponsesReasoning;\n}\n/**\n * Invocation parameters for ChatXAIResponses (request params without input).\n */\nexport type ChatXAIResponsesInvocationParams = Omit<XAIResponsesCreateParams, \"input\">;\n//# sourceMappingURL=responses-types.d.ts.map"],"mappings":";;;;;;AAGiBA,UAAAA,yBAAAA,CAAyB;EASzBC,IAAAA,EAAAA,YAAAA;EAUAC;EAQLC,IAAAA,EAAAA,MAAAA;;;;AAAiH;AAI7H;AAciBE,UApCAJ,0BAAAA,CAoC6B;EAU7BK,IAAAA,EAAAA,aAAAA;EAYAC;EAYLC,SAAAA,EAAAA,MAAAA;EAAuBJ;EAA+BC,MAAAA,CAAAA,EAAAA,MAAAA,GAAAA,KAAAA,GAAAA,MAAAA;;;AAA6F;AAI/J;AAWiBK,UA3EAR,yBAAAA,CA2E0B;EAa1BS,IAAAA,EAAAA,YAAAA;EAQAC;EAiBAC,OAAAA,EAAAA,MAAAA;AAUjB;AAIA;AAIA;AAYA;AAAoCG,KAvIxBb,4BAAAA,GAA+BH,yBAuIPgB,GAvImCf,0BAuInCe,GAvIgEd,yBAuIhEc;;;AAA2E;AAKnGE,UAxIKd,4BAAAA,CAwIwBa;EAI7BE,IAAAA,EAAAA,eAAAA;EAIAC;EAIKC,EAAAA,EAAAA,MAAAA;EASAC;EAcAC,OAAAA,CAAAA,EAAAA,MAAAA;EAcAC;EAQLC,IAAAA,EAAAA,MAAAA;EAA2BH;EAA4BC,SAAAA,EAAAA,MAAAA;;AAAyD;AAI5H;AAKA;AAiBiBK,UA7MAvB,6BAAAA,CA6M0B;EAM1BwB,IAAAA,EAAAA,iBAAAA;EAMAC;EAULE,EAAAA,EAAAA,MAAAA;EAAyBJ;EAA6BC,MAAAA,C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gCAAAA,SAAyCV;;;;;;;;;;;;UAYzCW,+BAAAA,SAAwCX;;;;;;;;;;;;UAYxCY,iDAAAA,SAA0DZ;;;;;;;;;;;;UAY1Da,gDAAAA,SAAyDb;;;;;;;;;;;;UAYzDc,gDAAAA,SAAyDd;;;;;;;;;;;;UAYzDe,+CAAAA,SAAwDf;;;;;;;;;;;;UAYxDgB,4BAAAA,SAAqChB;;;;;;;;;;;;KAY1CiB,uBAAAA,GAA0BhB,iCAAiCC,oCAAoCC,mCAAmCC,gCAAgCC,oCAAoCC,yCAAyCC,wCAAwCC,0CAA0CC,yCAAyCC,mCAAmCC,kCAAkCC,oDAAoDC,mDAAmDC,mDAAmDC,kDAAkDC;;;;UAKtnBI,2BAAAA,SAAoCF;;;;SAI1C3D;;;;YAIGY;;;;;;;;;sBASUlB;;;;cAIRN;;;;gBAIEuB;;;;;;;;;UASDmD,qBAAAA,SAA8BF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA+CxBlE;;;;cAIPN;;;;;KAKJ2E,gCAAAA,GAAmCC,KAAKnD"}
|
|
1
|
+
{"version":3,"file":"responses-types.d.cts","names":["XAIResponsesInputTextItem","XAIResponsesInputImageItem","XAIResponsesInputFileItem","XAIResponsesInputContentItem","XAIResponsesFunctionToolCall","XAIResponsesWebSearchToolCall","XAIResponsesCodeInterpreterToolCall","XAIResponsesMcpToolCall","XAIResponsesToolCall","XAIResponsesLogprobToken","XAIResponsesLogprobContent","XAIResponsesLogprobs","XAIResponsesPreviousResponse","XAIResponsesFunctionToolOutput","XAIResponsesToolOutput","XAIResponsesMessageRole","XAIResponsesMessage","XAIResponsesInputItem","XAIResponsesInput","XAIResponsesReasoningEffort","XAIResponsesReasoningSummary","XAIResponsesReasoning","XAIResponsesSearchSourceX","XAIResponsesSearchSourceWeb","XAIResponsesSearchSourceRss","XAIResponsesSearchSource","XAIResponsesSearchMode","XAIResponsesSearchParameters","XAIResponsesTextFormatText","XAIResponsesTextFormatJsonObject","XAIResponsesTextFormatJsonSchema","Record","XAIResponsesTextFormat","XAIResponsesText","XAIResponsesFunctionToolFunction","XAIResponsesFunctionTool","XAIResponsesWebSearchTool","XAIResponsesXSearchTool","XAIResponsesFileSearchTool","XAIResponsesCodeInterpreterTool","XAIResponsesMcpTool","XAIResponsesTool","XAIResponsesToolChoiceString","XAIResponsesToolChoiceFunction","XAIResponsesToolChoice","XAIResponsesInclude","XAIResponsesCreateParams","XAIResponsesCreateParamsStreaming","XAIResponsesCreateParamsNonStreaming","XAIResponsesStatus","XAIResponsesObjectType","XAIResponsesOutputTextItem","XAIResponsesOutputContent","XAIResponsesOutputTextContent","XAIResponsesAnnotation","XAIResponsesOutputRefusalContent","XAIResponsesUrlCitationAnnotation","XAIResponsesFileCitationAnnotation","XAIResponsesOutputFunctionCall","XAIResponsesOutputWebSearchCall","XAIResponsesOutputFileSearchCall","XAIResponsesFileSearchResult","XAIResponsesOutputCodeInterpreterCall","XAIResponsesCodeInterpreterResult","XAIResponsesOutputMcpCall","XAIResponsesOutputReasoning","XAIResponsesReasoningSummaryItem","XAIResponsesOutputItem","XAIResponsesUsage","XAIResponsesIncompleteReason","XAIResponsesIncompleteDetails","XAIResponsesDebugOutput","XAIResponsesReasoningResponse","XAIResponse","XAIResponsesStreamEventBase","XAIResponsesStreamEventCreated","XAIResponsesStreamEventInProgress","XAIResponsesStreamEventCompleted","XAIResponsesStreamEventFailed","XAIResponsesStreamEventIncomplete","XAIResponsesStreamEventOutputItemAdded","XAIResponsesStreamEventOutputItemDone","XAIResponsesStreamEventContentPartAdded","XAIResponsesStreamEventContentPartDone","XAIResponsesStreamEventTextDelta","XAIResponsesStreamEventTextDone","XAIResponsesStreamEventFunctionCallArgumentsDelta","XAIResponsesStreamEventFunctionCallArgumentsDone","XAIResponsesStreamEventReasoningSummaryTextDelta","XAIResponsesStreamEventReasoningSummaryTextDone","XAIResponsesStreamEventError","XAIResponsesStreamEvent","BaseChatModelCallOptions","BaseChatModelParams","ChatXAIResponsesCallOptions","ChatXAIResponsesInput","ChatXAIResponsesInvocationParams","Omit"],"sources":["../../src/chat_models/responses-types.d.ts"],"sourcesContent":["/**\n * Text input content item.\n */\nexport interface XAIResponsesInputTextItem {\n type: \"input_text\";\n /** The text content. */\n text: string;\n}\n/**\n * Image input content item.\n * Note: Storing/fetching images is not fully supported.\n */\nexport interface XAIResponsesInputImageItem {\n type: \"input_image\";\n /** Public URL of the image. */\n image_url: string;\n /** Image detail level. */\n detail?: \"high\" | \"low\" | \"auto\";\n}\n/**\n * File input content item.\n */\nexport interface XAIResponsesInputFileItem {\n type: \"input_file\";\n /** File ID from the Files API. */\n file_id: string;\n}\n/**\n * Union type for all input content items.\n */\nexport type XAIResponsesInputContentItem = XAIResponsesInputTextItem | XAIResponsesInputImageItem | XAIResponsesInputFileItem;\n/**\n * Function tool call from a previous response.\n */\nexport interface XAIResponsesFunctionToolCall {\n type: \"function_call\";\n /** The ID of the tool call. */\n id: string;\n /** The ID of the tool call (alias). */\n call_id?: string;\n /** The name of the function. */\n name: string;\n /** The arguments to the function as a JSON string. */\n arguments: string;\n}\n/**\n * Web search tool call from a previous response.\n */\nexport interface XAIResponsesWebSearchToolCall {\n type: \"web_search_call\";\n /** The ID of the tool call. */\n id: string;\n /** The search status. */\n status?: \"in_progress\" | \"searching\" | \"completed\" | \"failed\";\n}\n/**\n * Code interpreter tool call from a previous response.\n */\nexport interface XAIResponsesCodeInterpreterToolCall {\n type: \"code_interpreter_call\";\n /** The ID of the tool call. */\n id: string;\n /** The code to execute. */\n code?: string;\n /** The status of the code interpreter. */\n status?: \"in_progress\" | \"interpreting\" | \"completed\" | \"failed\";\n}\n/**\n * MCP tool call from a previous response.\n */\nexport interface XAIResponsesMcpToolCall {\n type: \"mcp_call\";\n /** The ID of the tool call. */\n id: string;\n /** The MCP server URL. */\n server_url?: string;\n /** The MCP server label. */\n server_label?: string;\n}\n/**\n * Union type for all tool calls from previous responses.\n */\nexport type XAIResponsesToolCall = XAIResponsesFunctionToolCall | XAIResponsesWebSearchToolCall | XAIResponsesCodeInterpreterToolCall | XAIResponsesMcpToolCall;\n/**\n * Log probability information for a token.\n */\nexport interface XAIResponsesLogprobToken {\n /** The token string. */\n token: string;\n /** The log probability of the token. */\n logprob: number;\n /** The bytes representation of the token. */\n bytes?: number[];\n}\n/**\n * Log probability content item.\n */\nexport interface XAIResponsesLogprobContent {\n /** The token. */\n token: string;\n /** The log probability. */\n logprob: number;\n /** The bytes representation. */\n bytes?: number[];\n /** Top log probabilities at this position. */\n top_logprobs?: XAIResponsesLogprobToken[];\n}\n/**\n * Log probabilities from a previous response.\n */\nexport interface XAIResponsesLogprobs {\n /** Log probability content. */\n content?: XAIResponsesLogprobContent[];\n}\n/**\n * Previous response structure that can be included in the input array.\n * Used for multi-turn conversations with assistant outputs.\n */\nexport interface XAIResponsesPreviousResponse {\n /** The type identifier for previous response. */\n type: \"message\";\n /** The role for previous assistant responses. */\n role: \"assistant\";\n /** The text output from the previous response. */\n text?: string;\n /** Refusal message if the model refused to respond. */\n refusal?: string;\n /** Tool calls made in the previous response. */\n tool_calls?: XAIResponsesToolCall[];\n /** Log probabilities from the previous response. */\n logprobs?: XAIResponsesLogprobs;\n}\n/**\n * Function tool call output to provide results back to the model.\n */\nexport interface XAIResponsesFunctionToolOutput {\n type: \"function_call_output\";\n /** The ID of the tool call this output is for. */\n call_id: string;\n /** The output/result of the function call. */\n output: string;\n}\n/**\n * Union type for tool outputs that can be included in input.\n */\nexport type XAIResponsesToolOutput = XAIResponsesFunctionToolOutput;\n/**\n * Message role types.\n */\nexport type XAIResponsesMessageRole = \"user\" | \"assistant\" | \"system\" | \"developer\";\n/**\n * Message input to the model.\n */\nexport interface XAIResponsesMessage {\n /** The role of the message author. */\n role: XAIResponsesMessageRole;\n /** Text, image, or audio input. Can be a string or array of content items. */\n content: string | XAIResponsesInputContentItem[];\n /** Unique identifier for the end-user. Only for `user` messages. */\n name?: string;\n}\n/**\n * Union type for all items that can appear in the input array.\n * Includes messages, previous responses, and tool outputs.\n */\nexport type XAIResponsesInputItem = XAIResponsesMessage | XAIResponsesPreviousResponse | XAIResponsesToolOutput;\n/**\n * Input type - can be a string or array of input items.\n * The array can contain messages, previous responses, and tool outputs.\n */\nexport type XAIResponsesInput = string | XAIResponsesInputItem[];\n/**\n * Reasoning effort level.\n */\nexport type XAIResponsesReasoningEffort = \"low\" | \"medium\" | \"high\";\n/**\n * Reasoning summary style.\n */\nexport type XAIResponsesReasoningSummary = \"auto\" | \"concise\" | \"detailed\";\n/**\n * Reasoning configuration for reasoning models.\n */\nexport interface XAIResponsesReasoning {\n /** The effort level for reasoning. Defaults to `medium`. */\n effort?: XAIResponsesReasoningEffort;\n /** The summary style for reasoning output. */\n summary?: XAIResponsesReasoningSummary;\n}\n/**\n * X (Twitter) search source configuration.\n */\nexport interface XAIResponsesSearchSourceX {\n type: \"x\";\n /** X handles to include in search. */\n included_x_handles?: string[];\n /** X handles to exclude from search. */\n excluded_x_handles?: string[];\n /** Minimum favorite count for posts. */\n post_favorite_count?: number;\n /** Minimum view count for posts. */\n post_view_count?: number;\n}\n/**\n * Web search source configuration.\n */\nexport interface XAIResponsesSearchSourceWeb {\n type: \"web\";\n /** Whitelist of allowed websites (max 5). */\n allowed_websites?: string[];\n /** Blacklist of excluded websites (max 5). */\n excluded_websites?: string[];\n /** ISO alpha-2 country code. */\n country?: string;\n /** Whether to enable safe search. Defaults to `true`. */\n safe_search?: boolean;\n}\n/**\n * RSS/News search source configuration.\n */\nexport interface XAIResponsesSearchSourceRss {\n type: \"rss\";\n /** Links of RSS feeds. */\n links?: string[];\n}\n/**\n * Union type for all search sources.\n */\nexport type XAIResponsesSearchSource = XAIResponsesSearchSourceX | XAIResponsesSearchSourceWeb | XAIResponsesSearchSourceRss;\n/**\n * Search mode options.\n */\nexport type XAIResponsesSearchMode = \"off\" | \"on\" | \"auto\";\n/**\n * Search parameters configuration.\n * Takes precedence over `web_search_preview` tool.\n */\nexport interface XAIResponsesSearchParameters {\n /** Start date for search results (ISO-8601 YYYY-MM-DD). */\n from_date?: string;\n /** End date for search results (ISO-8601 YYYY-MM-DD). */\n to_date?: string;\n /** Maximum number of search results. Defaults to 15 (range: 1-30). */\n max_search_results?: number;\n /** Search mode. Defaults to `on`. */\n mode?: XAIResponsesSearchMode;\n /** Whether to return citations. Defaults to `true`. */\n return_citations?: boolean;\n /** List of search sources. If empty, searches web and X. */\n sources?: XAIResponsesSearchSource[];\n}\n/**\n * Plain text format.\n */\nexport interface XAIResponsesTextFormatText {\n type: \"text\";\n}\n/**\n * JSON object format.\n */\nexport interface XAIResponsesTextFormatJsonObject {\n type: \"json_object\";\n}\n/**\n * JSON schema format.\n */\nexport interface XAIResponsesTextFormatJsonSchema {\n type: \"json_schema\";\n /** JSON schema definition. */\n schema: Record<string, unknown>;\n /** Compatibility field for strict mode. */\n strict?: boolean;\n}\n/**\n * Union type for all text response formats.\n */\nexport type XAIResponsesTextFormat = XAIResponsesTextFormatText | XAIResponsesTextFormatJsonObject | XAIResponsesTextFormatJsonSchema;\n/**\n * Text response configuration.\n */\nexport interface XAIResponsesText {\n /** The format for text response. */\n format?: XAIResponsesTextFormat;\n}\n/**\n * Function tool parameters using JSON Schema.\n */\nexport interface XAIResponsesFunctionToolFunction {\n /** The name of the function. */\n name: string;\n /** A description of what the function does. */\n description?: string;\n /** The parameters the function accepts, described as a JSON Schema object. */\n parameters: Record<string, unknown>;\n}\n/**\n * Function tool definition.\n */\nexport interface XAIResponsesFunctionTool {\n type: \"function\";\n /** The function definition. */\n function: XAIResponsesFunctionToolFunction;\n}\n/**\n * Web search tool definition.\n * Enables the model to search the web and browse pages for real-time information.\n */\nexport interface XAIResponsesWebSearchTool {\n type: \"web_search\";\n /** Domains to exclusively include in the search (max 5). */\n allowed_domains?: string[];\n /** Domains to exclude from the search (max 5). */\n excluded_domains?: string[];\n /** Whether to enable image understanding during search. */\n enable_image_understanding?: boolean;\n}\n/**\n * X search tool definition.\n */\nexport interface XAIResponsesXSearchTool {\n type: \"x_search\";\n /** X handles to allow in search. */\n allowed_x_handles?: string[];\n /** X handles to exclude from search. */\n excluded_x_handles?: string[];\n /** Whether to enable image understanding. */\n enable_image_understanding?: boolean;\n /** Whether to enable video understanding. */\n enable_video_understanding?: boolean;\n /** Start date for search (ISO-8601). */\n from_date?: string;\n /** End date for search (ISO-8601). */\n to_date?: string;\n}\n/**\n * File search tool definition.\n */\nexport interface XAIResponsesFileSearchTool {\n type: \"file_search\";\n /** List of vector store IDs to search. */\n vector_store_ids?: string[];\n}\n/**\n * Code interpreter tool definition.\n */\nexport interface XAIResponsesCodeInterpreterTool {\n type: \"code_interpreter\";\n}\n/**\n * MCP (Model Context Protocol) tool definition.\n */\nexport interface XAIResponsesMcpTool {\n type: \"mcp\";\n /** The URL of the MCP server. */\n server_url: string;\n /** The label for the MCP server. */\n server_label: string;\n}\n/**\n * Union type for all tool definitions.\n */\nexport type XAIResponsesTool = XAIResponsesFunctionTool | XAIResponsesWebSearchTool | XAIResponsesXSearchTool | XAIResponsesFileSearchTool | XAIResponsesCodeInterpreterTool | XAIResponsesMcpTool;\n/**\n * String tool choice options.\n */\nexport type XAIResponsesToolChoiceString = \"none\" | \"auto\" | \"required\";\n/**\n * Function tool choice object.\n */\nexport interface XAIResponsesToolChoiceFunction {\n type: \"function\";\n function: {\n /** The name of the function to call. */\n name: string;\n };\n}\n/**\n * Tool choice configuration.\n */\nexport type XAIResponsesToolChoice = XAIResponsesToolChoiceString | XAIResponsesToolChoiceFunction;\n/**\n * Additional output data to include in the response.\n */\nexport type XAIResponsesInclude = \"reasoning.encrypted_content\";\n/**\n * xAI Responses API request body parameters.\n */\nexport interface XAIResponsesCreateParams {\n /**\n * The input passed to the model.\n * Can be text (string) or an array of message objects.\n */\n input: XAIResponsesInput;\n /**\n * Model name for the model to use (e.g., from xAI console).\n */\n model?: string;\n /**\n * Whether to process the response asynchronously in the background.\n * Note: Unsupported.\n * @default false\n */\n background?: boolean;\n /**\n * What additional output data to include in the response.\n * Currently supported: `reasoning.encrypted_content`.\n */\n include?: XAIResponsesInclude[];\n /**\n * An alternate way to specify the system prompt.\n * Cannot be used with `previous_response_id`.\n */\n instructions?: string;\n /**\n * Whether to return log probabilities of the output tokens.\n * @default false\n */\n logprobs?: boolean;\n /**\n * Max number of tokens that can be generated.\n * Includes both output and reasoning tokens.\n */\n max_output_tokens?: number;\n /**\n * Metadata for the request.\n * Note: Not supported. Maintained for compatibility.\n */\n metadata?: Record<string, unknown>;\n /**\n * Whether to allow the model to run parallel tool calls.\n * @default true\n */\n parallel_tool_calls?: boolean;\n /**\n * The ID of the previous response from the model.\n * Use this to create multi-turn conversations.\n */\n previous_response_id?: string;\n /**\n * Reasoning configuration.\n * Only for reasoning models.\n */\n reasoning?: XAIResponsesReasoning;\n /**\n * Set parameters for searched data.\n * Takes precedence over `web_search_preview` tool.\n */\n search_parameters?: XAIResponsesSearchParameters;\n /**\n * Service tier for the request.\n * Note: Not supported. Maintained for compatibility.\n */\n service_tier?: string;\n /**\n * Whether to store the input message(s) and response.\n * @default true\n */\n store?: boolean;\n /**\n * If set, partial message deltas will be sent as server-sent events.\n * @default false\n */\n stream?: boolean;\n /**\n * Sampling temperature between 0 and 2.\n * Higher values make output more random, lower values more deterministic.\n * @default 1\n */\n temperature?: number;\n /**\n * Settings for customizing a text response.\n */\n text?: XAIResponsesText;\n /**\n * Controls which tool is called by the model.\n */\n tool_choice?: XAIResponsesToolChoice;\n /**\n * A list of tools the model may call.\n * Maximum of 128 tools.\n */\n tools?: XAIResponsesTool[];\n /**\n * Number of most likely tokens to return at each token position.\n * Range: 0-8. Requires `logprobs` to be `true`.\n */\n top_logprobs?: number;\n /**\n * Nucleus sampling probability mass.\n * The model considers results of tokens with top_p probability mass.\n * @default 1\n */\n top_p?: number;\n /**\n * Truncation strategy.\n * Note: Not supported. Maintained for compatibility.\n */\n truncation?: string;\n /**\n * Unique identifier representing your end-user.\n * Used for monitoring and abuse detection.\n */\n user?: string;\n}\n/**\n * Streaming variant of the request params.\n */\nexport interface XAIResponsesCreateParamsStreaming extends XAIResponsesCreateParams {\n stream: true;\n}\n/**\n * Non-streaming variant of the request params.\n */\nexport interface XAIResponsesCreateParamsNonStreaming extends XAIResponsesCreateParams {\n stream?: false;\n}\n/**\n * Response status values.\n */\nexport type XAIResponsesStatus = \"completed\" | \"in_progress\" | \"incomplete\";\n/**\n * Response object type literal.\n */\nexport type XAIResponsesObjectType = \"response\";\n/**\n * Text output item in the response.\n */\nexport interface XAIResponsesOutputTextItem {\n type: \"message\";\n /** The role of the message (always assistant for outputs). */\n role: \"assistant\";\n /** The text content of the message. */\n content: XAIResponsesOutputContent[];\n /** The ID of this output item. */\n id?: string;\n /** The status of this output item. */\n status?: XAIResponsesStatus;\n}\n/**\n * Text content in an output message.\n */\nexport interface XAIResponsesOutputTextContent {\n type: \"output_text\";\n /** The text content. */\n text: string;\n /** Annotations on the text (e.g., citations). */\n annotations?: XAIResponsesAnnotation[];\n}\n/**\n * Refusal content in an output message.\n */\nexport interface XAIResponsesOutputRefusalContent {\n type: \"refusal\";\n /** The refusal message. */\n refusal: string;\n}\n/**\n * Union type for output content items.\n */\nexport type XAIResponsesOutputContent = XAIResponsesOutputTextContent | XAIResponsesOutputRefusalContent;\n/**\n * Citation annotation for web search results.\n */\nexport interface XAIResponsesUrlCitationAnnotation {\n type: \"url_citation\";\n /** Start index in the text. */\n start_index: number;\n /** End index in the text. */\n end_index: number;\n /** The URL being cited. */\n url: string;\n /** The title of the cited page. */\n title?: string;\n}\n/**\n * File citation annotation.\n */\nexport interface XAIResponsesFileCitationAnnotation {\n type: \"file_citation\";\n /** Start index in the text. */\n start_index: number;\n /** End index in the text. */\n end_index: number;\n /** The file ID being cited. */\n file_id: string;\n /** The filename. */\n filename?: string;\n}\n/**\n * Union type for all annotation types.\n */\nexport type XAIResponsesAnnotation = XAIResponsesUrlCitationAnnotation | XAIResponsesFileCitationAnnotation;\n/**\n * Function call output item.\n */\nexport interface XAIResponsesOutputFunctionCall {\n type: \"function_call\";\n /** The ID of the function call. */\n id: string;\n /** The ID of the function call (alias). */\n call_id?: string;\n /** The name of the function being called. */\n name: string;\n /** The arguments to the function as a JSON string. */\n arguments: string;\n /** The status of the function call. */\n status?: XAIResponsesStatus;\n}\n/**\n * Web search call output item.\n */\nexport interface XAIResponsesOutputWebSearchCall {\n type: \"web_search_call\";\n /** The ID of the web search call. */\n id: string;\n /** The status of the web search. */\n status?: \"in_progress\" | \"searching\" | \"completed\" | \"failed\";\n}\n/**\n * File search call output item.\n */\nexport interface XAIResponsesOutputFileSearchCall {\n type: \"file_search_call\";\n /** The ID of the file search call. */\n id: string;\n /** The status of the file search. */\n status?: \"in_progress\" | \"searching\" | \"completed\" | \"failed\";\n /** The search queries used. */\n queries?: string[];\n /** The search results. */\n results?: XAIResponsesFileSearchResult[];\n}\n/**\n * File search result item.\n */\nexport interface XAIResponsesFileSearchResult {\n /** The file ID. */\n file_id: string;\n /** The filename. */\n filename?: string;\n /** The score/relevance of the result. */\n score?: number;\n /** The matched text content. */\n text?: string;\n}\n/**\n * Code interpreter call output item.\n */\nexport interface XAIResponsesOutputCodeInterpreterCall {\n type: \"code_interpreter_call\";\n /** The ID of the code interpreter call. */\n id: string;\n /** The code being executed. */\n code?: string;\n /** The status of the code interpreter. */\n status?: \"in_progress\" | \"interpreting\" | \"completed\" | \"failed\";\n /** The results of the code execution. */\n results?: XAIResponsesCodeInterpreterResult[];\n}\n/**\n * Code interpreter result item.\n */\nexport interface XAIResponsesCodeInterpreterResult {\n type: \"logs\" | \"image\";\n /** The log output (for type \"logs\"). */\n logs?: string;\n /** The image data (for type \"image\"). */\n image?: {\n /** The base64-encoded image data. */\n data?: string;\n /** The MIME type of the image. */\n media_type?: string;\n };\n}\n/**\n * MCP call output item.\n */\nexport interface XAIResponsesOutputMcpCall {\n type: \"mcp_call\";\n /** The ID of the MCP call. */\n id: string;\n /** The MCP server URL. */\n server_url?: string;\n /** The MCP server label. */\n server_label?: string;\n /** The status of the MCP call. */\n status?: \"in_progress\" | \"completed\" | \"failed\";\n}\n/**\n * Reasoning output item.\n */\nexport interface XAIResponsesOutputReasoning {\n type: \"reasoning\";\n /** The ID of the reasoning item. */\n id?: string;\n /** Summary of the reasoning. */\n summary?: XAIResponsesReasoningSummaryItem[];\n /** Encrypted reasoning content (if included). */\n encrypted_content?: string;\n}\n/**\n * Reasoning summary item.\n */\nexport interface XAIResponsesReasoningSummaryItem {\n type: \"summary_text\";\n /** The summary text. */\n text: string;\n}\n/**\n * Union type for all response output items.\n */\nexport type XAIResponsesOutputItem = XAIResponsesOutputTextItem | XAIResponsesOutputFunctionCall | XAIResponsesOutputWebSearchCall | XAIResponsesOutputFileSearchCall | XAIResponsesOutputCodeInterpreterCall | XAIResponsesOutputMcpCall | XAIResponsesOutputReasoning;\n/**\n * Token usage information for the response.\n */\nexport interface XAIResponsesUsage {\n /** Number of tokens in the input/prompt. */\n input_tokens: number;\n /** Number of tokens in the output/completion. */\n output_tokens: number;\n /** Total number of tokens used. */\n total_tokens: number;\n /** Detailed breakdown of input tokens. */\n input_tokens_details?: {\n /** Cached tokens from previous requests. */\n cached_tokens?: number;\n };\n /** Detailed breakdown of output tokens. */\n output_tokens_details?: {\n /** Tokens used for reasoning. */\n reasoning_tokens?: number;\n };\n}\n/**\n * Reason for incomplete response.\n */\nexport type XAIResponsesIncompleteReason = \"max_output_tokens\" | \"content_filter\" | \"turn_limit\" | \"tool_use_limit\";\n/**\n * Details about why a response is incomplete.\n */\nexport interface XAIResponsesIncompleteDetails {\n /** The reason the response is incomplete. */\n reason?: XAIResponsesIncompleteReason;\n}\n/**\n * Debug output information (when available).\n */\nexport interface XAIResponsesDebugOutput {\n /** Debug model information. */\n model_info?: Record<string, unknown>;\n /** Additional debug data. */\n [key: string]: unknown;\n}\n/**\n * Reasoning configuration echoed in the response.\n */\nexport interface XAIResponsesReasoningResponse {\n /** The effort level used for reasoning. */\n effort?: XAIResponsesReasoningEffort;\n /** The summary style used. */\n summary?: XAIResponsesReasoningSummary;\n}\n/**\n * xAI Responses API response body.\n */\nexport interface XAIResponse {\n /**\n * Unique ID of the response.\n */\n id: string;\n /**\n * The object type of this resource. Always set to `response`.\n */\n object: XAIResponsesObjectType;\n /**\n * The Unix timestamp (in seconds) for the response creation time.\n */\n created_at: number;\n /**\n * Model name used to generate the response.\n */\n model: string;\n /**\n * Status of the response.\n */\n status: XAIResponsesStatus;\n /**\n * The response generated by the model.\n */\n output: XAIResponsesOutputItem[];\n /**\n * Whether to allow the model to run parallel tool calls.\n */\n parallel_tool_calls?: boolean;\n /**\n * Whether to store the input message(s) and response.\n * @default true\n */\n store?: boolean;\n /**\n * Settings for customizing a text response.\n */\n text?: XAIResponsesText;\n /**\n * Controls which tool is called by the model.\n */\n tool_choice?: XAIResponsesToolChoice;\n /**\n * A list of tools the model may call.\n * Maximum of 128 tools.\n */\n tools?: XAIResponsesTool[];\n /**\n * Whether to process the response asynchronously in the background.\n * Note: Unsupported.\n * @default false\n */\n background?: boolean | null;\n /**\n * Debug output information (when available).\n */\n debug_output?: XAIResponsesDebugOutput | null;\n /**\n * Details about why the response is incomplete (if status is \"incomplete\").\n */\n incomplete_details?: XAIResponsesIncompleteDetails | null;\n /**\n * Max number of tokens that can be generated.\n * Includes both output and reasoning tokens.\n */\n max_output_tokens?: number | null;\n /**\n * Only included for compatibility.\n */\n metadata?: Record<string, unknown> | null;\n /**\n * The ID of the previous response from the model.\n */\n previous_response_id?: string | null;\n /**\n * Reasoning configuration used for the response.\n */\n reasoning?: XAIResponsesReasoningResponse | null;\n /**\n * Sampling temperature used (between 0 and 2).\n * @default 1\n */\n temperature?: number | null;\n /**\n * Nucleus sampling probability mass used.\n * @default 1\n */\n top_p?: number | null;\n /**\n * Token usage information.\n */\n usage?: XAIResponsesUsage | null;\n /**\n * Unique identifier representing your end-user.\n * Used for monitoring and abuse detection.\n */\n user?: string | null;\n}\n/**\n * Base streaming event structure.\n */\nexport interface XAIResponsesStreamEventBase {\n /** The type of the streaming event. */\n type: string;\n}\n/**\n * Response created event.\n */\nexport interface XAIResponsesStreamEventCreated extends XAIResponsesStreamEventBase {\n type: \"response.created\";\n /** The response object. */\n response: XAIResponse;\n}\n/**\n * Response in progress event.\n */\nexport interface XAIResponsesStreamEventInProgress extends XAIResponsesStreamEventBase {\n type: \"response.in_progress\";\n /** The response object. */\n response: XAIResponse;\n}\n/**\n * Response completed event.\n */\nexport interface XAIResponsesStreamEventCompleted extends XAIResponsesStreamEventBase {\n type: \"response.completed\";\n /** The completed response object. */\n response: XAIResponse;\n}\n/**\n * Response failed event.\n */\nexport interface XAIResponsesStreamEventFailed extends XAIResponsesStreamEventBase {\n type: \"response.failed\";\n /** The failed response object. */\n response: XAIResponse;\n /** Error information. */\n error?: {\n /** Error code. */\n code?: string;\n /** Error message. */\n message?: string;\n };\n}\n/**\n * Response incomplete event.\n */\nexport interface XAIResponsesStreamEventIncomplete extends XAIResponsesStreamEventBase {\n type: \"response.incomplete\";\n /** The incomplete response object. */\n response: XAIResponse;\n}\n/**\n * Output item added event.\n */\nexport interface XAIResponsesStreamEventOutputItemAdded extends XAIResponsesStreamEventBase {\n type: \"response.output_item.added\";\n /** The index of the output item. */\n output_index: number;\n /** The output item that was added. */\n item: XAIResponsesOutputItem;\n}\n/**\n * Output item done event.\n */\nexport interface XAIResponsesStreamEventOutputItemDone extends XAIResponsesStreamEventBase {\n type: \"response.output_item.done\";\n /** The index of the output item. */\n output_index: number;\n /** The completed output item. */\n item: XAIResponsesOutputItem;\n}\n/**\n * Content part added event.\n */\nexport interface XAIResponsesStreamEventContentPartAdded extends XAIResponsesStreamEventBase {\n type: \"response.content_part.added\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The content part that was added. */\n part: XAIResponsesOutputContent;\n}\n/**\n * Content part done event.\n */\nexport interface XAIResponsesStreamEventContentPartDone extends XAIResponsesStreamEventBase {\n type: \"response.content_part.done\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The completed content part. */\n part: XAIResponsesOutputContent;\n}\n/**\n * Text delta event (streaming text).\n */\nexport interface XAIResponsesStreamEventTextDelta extends XAIResponsesStreamEventBase {\n type: \"response.output_text.delta\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The text delta. */\n delta: string;\n}\n/**\n * Text done event.\n */\nexport interface XAIResponsesStreamEventTextDone extends XAIResponsesStreamEventBase {\n type: \"response.output_text.done\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the content part. */\n content_index: number;\n /** The complete text. */\n text: string;\n}\n/**\n * Function call arguments delta event.\n */\nexport interface XAIResponsesStreamEventFunctionCallArgumentsDelta extends XAIResponsesStreamEventBase {\n type: \"response.function_call_arguments.delta\";\n /** The index of the output item. */\n output_index: number;\n /** The ID of the function call. */\n call_id: string;\n /** The arguments delta. */\n delta: string;\n}\n/**\n * Function call arguments done event.\n */\nexport interface XAIResponsesStreamEventFunctionCallArgumentsDone extends XAIResponsesStreamEventBase {\n type: \"response.function_call_arguments.done\";\n /** The index of the output item. */\n output_index: number;\n /** The ID of the function call. */\n call_id: string;\n /** The complete arguments. */\n arguments: string;\n}\n/**\n * Reasoning summary text delta event.\n */\nexport interface XAIResponsesStreamEventReasoningSummaryTextDelta extends XAIResponsesStreamEventBase {\n type: \"response.reasoning_summary_text.delta\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the summary part. */\n summary_index: number;\n /** The text delta. */\n delta: string;\n}\n/**\n * Reasoning summary text done event.\n */\nexport interface XAIResponsesStreamEventReasoningSummaryTextDone extends XAIResponsesStreamEventBase {\n type: \"response.reasoning_summary_text.done\";\n /** The index of the output item. */\n output_index: number;\n /** The index of the summary part. */\n summary_index: number;\n /** The complete text. */\n text: string;\n}\n/**\n * Error event.\n */\nexport interface XAIResponsesStreamEventError extends XAIResponsesStreamEventBase {\n type: \"error\";\n /** Error code. */\n code?: string;\n /** Error message. */\n message?: string;\n /** Error parameter. */\n param?: string;\n}\n/**\n * Union type for all streaming events.\n */\nexport type XAIResponsesStreamEvent = XAIResponsesStreamEventCreated | XAIResponsesStreamEventInProgress | XAIResponsesStreamEventCompleted | XAIResponsesStreamEventFailed | XAIResponsesStreamEventIncomplete | XAIResponsesStreamEventOutputItemAdded | XAIResponsesStreamEventOutputItemDone | XAIResponsesStreamEventContentPartAdded | XAIResponsesStreamEventContentPartDone | XAIResponsesStreamEventTextDelta | XAIResponsesStreamEventTextDone | XAIResponsesStreamEventFunctionCallArgumentsDelta | XAIResponsesStreamEventFunctionCallArgumentsDone | XAIResponsesStreamEventReasoningSummaryTextDelta | XAIResponsesStreamEventReasoningSummaryTextDone | XAIResponsesStreamEventError;\nimport type { BaseChatModelCallOptions, BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\n/**\n * Call options for ChatXAIResponses.\n */\nexport interface ChatXAIResponsesCallOptions extends BaseChatModelCallOptions {\n /**\n * Configuration options for a text response from the model.\n */\n text?: XAIResponsesText;\n /**\n * Specify additional output data to include in the model response.\n */\n include?: XAIResponsesInclude[];\n /**\n * The unique ID of the previous response to the model.\n * Use this to create multi-turn conversations.\n */\n previous_response_id?: string;\n /**\n * Search parameters for xAI's search capabilities.\n */\n search_parameters?: XAIResponsesSearchParameters;\n /**\n * Reasoning configuration for reasoning models.\n */\n reasoning?: XAIResponsesReasoning;\n /**\n * A list of tools the model may call.\n * Includes built-in tools (web_search, x_search, code_interpreter, file_search)\n * and custom function tools.\n *\n * @example\n * ```typescript\n * import { tools } from \"@langchain/xai\";\n *\n * const result = await llm.invoke(\"What's happening on X?\", {\n * tools: [tools.xaiWebSearch(), tools.xaiXSearch()],\n * });\n * ```\n */\n tools?: XAIResponsesTool[];\n /**\n * Controls which tool is called by the model.\n */\n tool_choice?: XAIResponsesToolChoice;\n /**\n * Whether to allow the model to run parallel tool calls.\n */\n parallel_tool_calls?: boolean;\n}\n/**\n * Input configuration for ChatXAIResponses constructor.\n */\nexport interface ChatXAIResponsesInput extends BaseChatModelParams {\n /**\n * The xAI API key to use for requests.\n * @default process.env.XAI_API_KEY\n */\n apiKey?: string;\n /**\n * The name of the model to use.\n * @default \"grok-3\"\n */\n model?: string;\n /**\n * Whether to stream responses.\n * @default false\n */\n streaming?: boolean;\n /**\n * Sampling temperature between 0 and 2.\n * @default 1\n */\n temperature?: number;\n /**\n * Nucleus sampling probability mass.\n * @default 1\n */\n topP?: number;\n /**\n * Maximum number of tokens to generate.\n */\n maxOutputTokens?: number;\n /**\n * Whether to store the input messages and response.\n * @default true\n */\n store?: boolean;\n /**\n * A unique identifier representing your end-user.\n */\n user?: string;\n /**\n * The base URL for the xAI API.\n * @default \"https://api.x.ai/v1\"\n */\n baseURL?: string;\n /**\n * Default search parameters for xAI's search capabilities.\n */\n searchParameters?: XAIResponsesSearchParameters;\n /**\n * Default reasoning configuration.\n */\n reasoning?: XAIResponsesReasoning;\n /**\n * Default tools to make available to the model.\n * Can be overridden per-request in call options.\n *\n * @example\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n * model: \"grok-4-1-fast\",\n * tools: [tools.xaiWebSearch(), tools.xaiCodeExecution()],\n * });\n * ```\n */\n tools?: XAIResponsesTool[];\n}\n/**\n * Invocation parameters for ChatXAIResponses (request params without input).\n */\nexport type ChatXAIResponsesInvocationParams = Omit<XAIResponsesCreateParams, \"input\">;\n//# sourceMappingURL=responses-types.d.ts.map"],"mappings":";;;;;;AAGiBA,UAAAA,yBAAAA,CAAyB;EASzBC,IAAAA,EAAAA,YAAAA;EAUAC;EAQLC,IAAAA,EAAAA,MAAAA;;;;AAAiH;AAI7H;AAciBE,UApCAJ,0BAAAA,CAoC6B;EAU7BK,IAAAA,EAAAA,aAAAA;EAYAC;EAYLC,SAAAA,EAAAA,MAAAA;EAAuBJ;EAA+BC,MAAAA,CAAAA,EAAAA,MAAAA,GAAAA,KAAAA,GAAAA,MAAAA;;;AAA6F;AAI/J;AAWiBK,UA3EAR,yBAAAA,CA2E0B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AIPN;;;;;;;;;;;;;;;UAeJoB;;;;;KAKAuD,gCAAAA,GAAmCC,KAAKnD"}
|
|
@@ -305,16 +305,16 @@ interface XAIResponsesFunctionTool {
|
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* Web search tool definition.
|
|
308
|
-
*
|
|
308
|
+
* Enables the model to search the web and browse pages for real-time information.
|
|
309
309
|
*/
|
|
310
310
|
interface XAIResponsesWebSearchTool {
|
|
311
311
|
type: "web_search";
|
|
312
|
-
/**
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
|
|
312
|
+
/** Domains to exclusively include in the search (max 5). */
|
|
313
|
+
allowed_domains?: string[];
|
|
314
|
+
/** Domains to exclude from the search (max 5). */
|
|
315
|
+
excluded_domains?: string[];
|
|
316
|
+
/** Whether to enable image understanding during search. */
|
|
317
|
+
enable_image_understanding?: boolean;
|
|
318
318
|
}
|
|
319
319
|
/**
|
|
320
320
|
* X search tool definition.
|
|
@@ -1074,6 +1074,21 @@ interface ChatXAIResponsesCallOptions extends BaseChatModelCallOptions {
|
|
|
1074
1074
|
* Reasoning configuration for reasoning models.
|
|
1075
1075
|
*/
|
|
1076
1076
|
reasoning?: XAIResponsesReasoning;
|
|
1077
|
+
/**
|
|
1078
|
+
* A list of tools the model may call.
|
|
1079
|
+
* Includes built-in tools (web_search, x_search, code_interpreter, file_search)
|
|
1080
|
+
* and custom function tools.
|
|
1081
|
+
*
|
|
1082
|
+
* @example
|
|
1083
|
+
* ```typescript
|
|
1084
|
+
* import { tools } from "@langchain/xai";
|
|
1085
|
+
*
|
|
1086
|
+
* const result = await llm.invoke("What's happening on X?", {
|
|
1087
|
+
* tools: [tools.xaiWebSearch(), tools.xaiXSearch()],
|
|
1088
|
+
* });
|
|
1089
|
+
* ```
|
|
1090
|
+
*/
|
|
1091
|
+
tools?: XAIResponsesTool[];
|
|
1077
1092
|
/**
|
|
1078
1093
|
* Controls which tool is called by the model.
|
|
1079
1094
|
*/
|
|
@@ -1138,6 +1153,21 @@ interface ChatXAIResponsesInput extends BaseChatModelParams {
|
|
|
1138
1153
|
* Default reasoning configuration.
|
|
1139
1154
|
*/
|
|
1140
1155
|
reasoning?: XAIResponsesReasoning;
|
|
1156
|
+
/**
|
|
1157
|
+
* Default tools to make available to the model.
|
|
1158
|
+
* Can be overridden per-request in call options.
|
|
1159
|
+
*
|
|
1160
|
+
* @example
|
|
1161
|
+
* ```typescript
|
|
1162
|
+
* import { ChatXAIResponses, tools } from "@langchain/xai";
|
|
1163
|
+
*
|
|
1164
|
+
* const llm = new ChatXAIResponses({
|
|
1165
|
+
* model: "grok-4-1-fast",
|
|
1166
|
+
* tools: [tools.xaiWebSearch(), tools.xaiCodeExecution()],
|
|
1167
|
+
* });
|
|
1168
|
+
* ```
|
|
1169
|
+
*/
|
|
1170
|
+
tools?: XAIResponsesTool[];
|
|
1141
1171
|
}
|
|
1142
1172
|
/**
|
|
1143
1173
|
* Invocation parameters for ChatXAIResponses (request params without input).
|