@ai-sdk/xai 4.0.0-beta.4 → 4.0.0-beta.41

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/dist/index.d.mts DELETED
@@ -1,375 +0,0 @@
1
- import { z } from 'zod/v4';
2
- import { ProviderV3, LanguageModelV3, ImageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
3
- import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
- import { FetchFunction } from '@ai-sdk/provider-utils';
5
-
6
- type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | (string & {});
7
- declare const xaiLanguageModelChatOptions: z.ZodObject<{
8
- reasoningEffort: z.ZodOptional<z.ZodEnum<{
9
- low: "low";
10
- high: "high";
11
- }>>;
12
- logprobs: z.ZodOptional<z.ZodBoolean>;
13
- topLogprobs: z.ZodOptional<z.ZodNumber>;
14
- parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
15
- searchParameters: z.ZodOptional<z.ZodObject<{
16
- mode: z.ZodEnum<{
17
- off: "off";
18
- auto: "auto";
19
- on: "on";
20
- }>;
21
- returnCitations: z.ZodOptional<z.ZodBoolean>;
22
- fromDate: z.ZodOptional<z.ZodString>;
23
- toDate: z.ZodOptional<z.ZodString>;
24
- maxSearchResults: z.ZodOptional<z.ZodNumber>;
25
- sources: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
26
- type: z.ZodLiteral<"web">;
27
- country: z.ZodOptional<z.ZodString>;
28
- excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
- allowedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
30
- safeSearch: z.ZodOptional<z.ZodBoolean>;
31
- }, z.core.$strip>, z.ZodObject<{
32
- type: z.ZodLiteral<"x">;
33
- excludedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
- includedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
35
- postFavoriteCount: z.ZodOptional<z.ZodNumber>;
36
- postViewCount: z.ZodOptional<z.ZodNumber>;
37
- xHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
38
- }, z.core.$strip>, z.ZodObject<{
39
- type: z.ZodLiteral<"news">;
40
- country: z.ZodOptional<z.ZodString>;
41
- excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
42
- safeSearch: z.ZodOptional<z.ZodBoolean>;
43
- }, z.core.$strip>, z.ZodObject<{
44
- type: z.ZodLiteral<"rss">;
45
- links: z.ZodArray<z.ZodString>;
46
- }, z.core.$strip>]>>>;
47
- }, z.core.$strip>>;
48
- }, z.core.$strip>;
49
- type XaiLanguageModelChatOptions = z.infer<typeof xaiLanguageModelChatOptions>;
50
-
51
- declare const xaiErrorDataSchema: z.ZodObject<{
52
- error: z.ZodObject<{
53
- message: z.ZodString;
54
- type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
55
- param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
56
- code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
57
- }, z.core.$strip>;
58
- }, z.core.$strip>;
59
- type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
60
-
61
- type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | (string & {});
62
- /**
63
- * @see https://docs.x.ai/docs/api-reference#create-new-response
64
- */
65
- declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
66
- reasoningEffort: z.ZodOptional<z.ZodEnum<{
67
- low: "low";
68
- high: "high";
69
- medium: "medium";
70
- }>>;
71
- logprobs: z.ZodOptional<z.ZodBoolean>;
72
- topLogprobs: z.ZodOptional<z.ZodNumber>;
73
- store: z.ZodOptional<z.ZodBoolean>;
74
- previousResponseId: z.ZodOptional<z.ZodString>;
75
- include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
76
- "file_search_call.results": "file_search_call.results";
77
- }>>>>;
78
- }, z.core.$strip>;
79
- type XaiLanguageModelResponsesOptions = z.infer<typeof xaiLanguageModelResponsesOptions>;
80
-
81
- declare const xaiImageModelOptions: z.ZodObject<{
82
- aspect_ratio: z.ZodOptional<z.ZodString>;
83
- output_format: z.ZodOptional<z.ZodString>;
84
- sync_mode: z.ZodOptional<z.ZodBoolean>;
85
- resolution: z.ZodOptional<z.ZodEnum<{
86
- "1k": "1k";
87
- "2k": "2k";
88
- }>>;
89
- quality: z.ZodOptional<z.ZodEnum<{
90
- low: "low";
91
- high: "high";
92
- medium: "medium";
93
- }>>;
94
- user: z.ZodOptional<z.ZodString>;
95
- }, z.core.$strip>;
96
- type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
97
-
98
- type XaiVideoModelId = 'grok-imagine-video' | (string & {});
99
-
100
- type XaiVideoModelOptions = {
101
- pollIntervalMs?: number | null;
102
- pollTimeoutMs?: number | null;
103
- resolution?: '480p' | '720p' | null;
104
- videoUrl?: string | null;
105
- [key: string]: unknown;
106
- };
107
-
108
- type XaiImageModelId = 'grok-2-image' | 'grok-2-image-1212' | 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
109
-
110
- declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
111
- output: string;
112
- error?: string | undefined;
113
- }, object>;
114
- declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
115
- output: string;
116
- error?: string | undefined;
117
- }>;
118
-
119
- declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
120
- name: string;
121
- arguments: string;
122
- result: unknown;
123
- }, {
124
- serverUrl: string;
125
- serverLabel?: string;
126
- serverDescription?: string;
127
- allowedTools?: string[];
128
- headers?: Record<string, string>;
129
- authorization?: string;
130
- }>;
131
- declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
132
- name: string;
133
- arguments: string;
134
- result: unknown;
135
- }>;
136
-
137
- declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
138
- description: string;
139
- objects?: string[] | undefined;
140
- }, object>;
141
- declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
142
- description: string;
143
- objects?: string[] | undefined;
144
- }>;
145
-
146
- declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
147
- description: string;
148
- transcript?: string | undefined;
149
- duration?: number | undefined;
150
- }, object>;
151
- declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
152
- description: string;
153
- transcript?: string | undefined;
154
- duration?: number | undefined;
155
- }>;
156
-
157
- declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
158
- query: string;
159
- sources: Array<{
160
- title: string;
161
- url: string;
162
- snippet: string;
163
- }>;
164
- }, {
165
- allowedDomains?: string[];
166
- excludedDomains?: string[];
167
- enableImageUnderstanding?: boolean;
168
- }>;
169
- declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
170
- query: string;
171
- sources: Array<{
172
- title: string;
173
- url: string;
174
- snippet: string;
175
- }>;
176
- }>;
177
-
178
- declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
179
- query: string;
180
- posts: Array<{
181
- author: string;
182
- text: string;
183
- url: string;
184
- likes: number;
185
- }>;
186
- }, {
187
- allowedXHandles?: string[];
188
- excludedXHandles?: string[];
189
- fromDate?: string;
190
- toDate?: string;
191
- enableImageUnderstanding?: boolean;
192
- enableVideoUnderstanding?: boolean;
193
- }>;
194
- declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
195
- query: string;
196
- posts: Array<{
197
- author: string;
198
- text: string;
199
- url: string;
200
- likes: number;
201
- }>;
202
- }>;
203
-
204
- declare const xaiTools: {
205
- codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
206
- output: string;
207
- error?: string | undefined;
208
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
209
- output: string;
210
- error?: string | undefined;
211
- }>;
212
- fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
213
- queries: string[];
214
- results: null | {
215
- fileId: string;
216
- filename: string;
217
- score: number;
218
- text: string;
219
- }[];
220
- }, {
221
- vectorStoreIds: string[];
222
- maxNumResults?: number;
223
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
224
- queries: string[];
225
- results: null | {
226
- fileId: string;
227
- filename: string;
228
- score: number;
229
- text: string;
230
- }[];
231
- }>;
232
- mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
233
- name: string;
234
- arguments: string;
235
- result: unknown;
236
- }, {
237
- serverUrl: string;
238
- serverLabel?: string;
239
- serverDescription?: string;
240
- allowedTools?: string[];
241
- headers?: Record<string, string>;
242
- authorization?: string;
243
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
244
- name: string;
245
- arguments: string;
246
- result: unknown;
247
- }>;
248
- viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
249
- description: string;
250
- objects?: string[] | undefined;
251
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
252
- description: string;
253
- objects?: string[] | undefined;
254
- }>;
255
- viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
256
- description: string;
257
- transcript?: string | undefined;
258
- duration?: number | undefined;
259
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
260
- description: string;
261
- transcript?: string | undefined;
262
- duration?: number | undefined;
263
- }>;
264
- webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
265
- query: string;
266
- sources: Array<{
267
- title: string;
268
- url: string;
269
- snippet: string;
270
- }>;
271
- }, {
272
- allowedDomains?: string[];
273
- excludedDomains?: string[];
274
- enableImageUnderstanding?: boolean;
275
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
276
- query: string;
277
- sources: Array<{
278
- title: string;
279
- url: string;
280
- snippet: string;
281
- }>;
282
- }>;
283
- xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
284
- query: string;
285
- posts: Array<{
286
- author: string;
287
- text: string;
288
- url: string;
289
- likes: number;
290
- }>;
291
- }, {
292
- allowedXHandles?: string[];
293
- excludedXHandles?: string[];
294
- fromDate?: string;
295
- toDate?: string;
296
- enableImageUnderstanding?: boolean;
297
- enableVideoUnderstanding?: boolean;
298
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
299
- query: string;
300
- posts: Array<{
301
- author: string;
302
- text: string;
303
- url: string;
304
- likes: number;
305
- }>;
306
- }>;
307
- };
308
-
309
- interface XaiProvider extends ProviderV3 {
310
- /**
311
- * Creates an Xai chat model for text generation.
312
- */
313
- (modelId: XaiChatModelId): LanguageModelV3;
314
- /**
315
- * Creates an Xai language model for text generation.
316
- */
317
- languageModel(modelId: XaiChatModelId): LanguageModelV3;
318
- /**
319
- * Creates an Xai chat model for text generation.
320
- */
321
- chat: (modelId: XaiChatModelId) => LanguageModelV3;
322
- /**
323
- * Creates an Xai responses model for agentic tool calling.
324
- */
325
- responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
326
- /**
327
- * Creates an Xai image model for image generation.
328
- */
329
- image(modelId: XaiImageModelId): ImageModelV3;
330
- /**
331
- * Creates an Xai image model for image generation.
332
- */
333
- imageModel(modelId: XaiImageModelId): ImageModelV3;
334
- /**
335
- * Creates an Xai video model for video generation.
336
- */
337
- video(modelId: XaiVideoModelId): Experimental_VideoModelV3;
338
- /**
339
- * Creates an Xai video model for video generation.
340
- */
341
- videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV3;
342
- /**
343
- * Server-side agentic tools for use with the responses API.
344
- */
345
- tools: typeof xaiTools;
346
- /**
347
- * @deprecated Use `embeddingModel` instead.
348
- */
349
- textEmbeddingModel(modelId: string): never;
350
- }
351
- interface XaiProviderSettings {
352
- /**
353
- * Base URL for the xAI API calls.
354
- */
355
- baseURL?: string;
356
- /**
357
- * API key for authenticating requests.
358
- */
359
- apiKey?: string;
360
- /**
361
- * Custom headers to include in the requests.
362
- */
363
- headers?: Record<string, string>;
364
- /**
365
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
366
- * or to provide a custom fetch implementation for e.g. testing.
367
- */
368
- fetch?: FetchFunction;
369
- }
370
- declare function createXai(options?: XaiProviderSettings): XaiProvider;
371
- declare const xai: XaiProvider;
372
-
373
- declare const VERSION: string;
374
-
375
- export { VERSION, type XaiErrorData, type XaiImageModelOptions, type XaiImageModelOptions as XaiImageProviderOptions, type XaiLanguageModelChatOptions, type XaiLanguageModelResponsesOptions, type XaiProvider, type XaiLanguageModelChatOptions as XaiProviderOptions, type XaiProviderSettings, type XaiLanguageModelResponsesOptions as XaiResponsesProviderOptions, type XaiVideoModelId, type XaiVideoModelOptions, type XaiVideoModelOptions as XaiVideoProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };