@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.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV3, LanguageModelV3, ImageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
3
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
+ import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
4
+ import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4, FilesV4 } from '@ai-sdk/provider';
5
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 & {});
6
+ type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-0309-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | (string & {});
7
7
  declare const xaiLanguageModelChatOptions: z.ZodObject<{
8
8
  reasoningEffort: z.ZodOptional<z.ZodEnum<{
9
9
  low: "low";
@@ -58,7 +58,7 @@ declare const xaiErrorDataSchema: z.ZodObject<{
58
58
  }, z.core.$strip>;
59
59
  type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
60
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 & {});
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' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-0309-reasoning' | 'grok-4.20-multi-agent-0309' | (string & {});
62
62
  /**
63
63
  * @see https://docs.x.ai/docs/api-reference#create-new-response
64
64
  */
@@ -68,6 +68,11 @@ declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
68
68
  high: "high";
69
69
  medium: "medium";
70
70
  }>>;
71
+ reasoningSummary: z.ZodOptional<z.ZodEnum<{
72
+ auto: "auto";
73
+ concise: "concise";
74
+ detailed: "detailed";
75
+ }>>;
71
76
  logprobs: z.ZodOptional<z.ZodBoolean>;
72
77
  topLogprobs: z.ZodOptional<z.ZodNumber>;
73
78
  store: z.ZodOptional<z.ZodBoolean>;
@@ -97,24 +102,94 @@ type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
97
102
 
98
103
  type XaiVideoModelId = 'grok-imagine-video' | (string & {});
99
104
 
100
- type XaiVideoModelOptions = {
105
+ declare const resolutionSchema: z.ZodEnum<{
106
+ "480p": "480p";
107
+ "720p": "720p";
108
+ }>;
109
+ type XaiVideoResolution = z.infer<typeof resolutionSchema>;
110
+ interface XaiVideoSharedOptions {
101
111
  pollIntervalMs?: number | null;
102
112
  pollTimeoutMs?: number | null;
103
- resolution?: '480p' | '720p' | null;
104
- videoUrl?: string | null;
105
- [key: string]: unknown;
106
- };
113
+ resolution?: XaiVideoResolution | null;
114
+ }
115
+ interface XaiVideoEditModeOptions extends XaiVideoSharedOptions {
116
+ /**
117
+ * Select edit-video mode explicitly for best autocomplete and narrowing.
118
+ */
119
+ mode: 'edit-video';
120
+ /** Source video URL to edit. */
121
+ videoUrl: string;
122
+ }
123
+ interface XaiVideoExtendModeOptions extends XaiVideoSharedOptions {
124
+ /**
125
+ * Select extend-video mode explicitly for best autocomplete and narrowing.
126
+ */
127
+ mode: 'extend-video';
128
+ /** Source video URL to extend from its last frame. */
129
+ videoUrl: string;
130
+ }
131
+ interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
132
+ /**
133
+ * Select reference-to-video mode explicitly for best autocomplete and narrowing.
134
+ */
135
+ mode: 'reference-to-video';
136
+ /** Reference image URLs (1-7) for R2V generation. */
137
+ referenceImageUrls: string[];
138
+ }
139
+ interface XaiVideoGenerationOptions extends XaiVideoSharedOptions {
140
+ mode?: undefined;
141
+ videoUrl?: undefined;
142
+ referenceImageUrls?: undefined;
143
+ }
144
+ interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
145
+ /**
146
+ * Legacy backward-compatible shape: omitting `mode` while providing
147
+ * `videoUrl` behaves like edit-video.
148
+ */
149
+ mode?: undefined;
150
+ videoUrl: string;
151
+ }
152
+ interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions {
153
+ /**
154
+ * Legacy backward-compatible shape: omitting `mode` while providing
155
+ * `referenceImageUrls` behaves like reference-to-video.
156
+ */
157
+ mode?: undefined;
158
+ referenceImageUrls: string[];
159
+ }
160
+ /**
161
+ * Provider options for xAI video generation.
162
+ *
163
+ * Use the `mode` option to select the operation:
164
+ *
165
+ * - `'edit-video'` + `videoUrl` -- video editing (`POST /v1/videos/edits`)
166
+ * - `'extend-video'` + `videoUrl` -- video extension (`POST /v1/videos/extensions`)
167
+ * - `'reference-to-video'` + `referenceImageUrls` -- R2V generation (`POST /v1/videos/generations`)
168
+ * - no `mode` -- standard generation from text prompts or image input
169
+ *
170
+ * Runtime remains backward compatible with legacy auto-detected provider
171
+ * options, but the public TypeScript type is intentionally explicit so editors
172
+ * can suggest valid modes and flag invalid field combinations.
173
+ */
174
+ type XaiVideoModelOptions = XaiVideoGenerationOptions | XaiVideoEditModeOptions | XaiVideoExtendModeOptions | XaiVideoReferenceToVideoOptions | XaiLegacyEditVideoOptions | XaiLegacyReferenceToVideoOptions;
107
175
 
108
- type XaiImageModelId = 'grok-2-image' | 'grok-2-image-1212' | 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
176
+ declare const xaiFilesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
177
+ [x: string]: unknown;
178
+ teamId?: string | undefined;
179
+ filePath?: string | undefined;
180
+ }>;
181
+ type XaiFilesOptions = InferSchema<typeof xaiFilesOptionsSchema>;
182
+
183
+ type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
109
184
 
110
185
  declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
111
186
  output: string;
112
187
  error?: string | undefined;
113
- }, object>;
188
+ }, object, {}>;
114
189
  declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
115
190
  output: string;
116
191
  error?: string | undefined;
117
- }>;
192
+ }, {}>;
118
193
 
119
194
  declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
120
195
  name: string;
@@ -127,32 +202,32 @@ declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
127
202
  allowedTools?: string[];
128
203
  headers?: Record<string, string>;
129
204
  authorization?: string;
130
- }>;
205
+ }, {}>;
131
206
  declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
132
207
  name: string;
133
208
  arguments: string;
134
209
  result: unknown;
135
- }>;
210
+ }, {}>;
136
211
 
137
212
  declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
138
213
  description: string;
139
214
  objects?: string[] | undefined;
140
- }, object>;
215
+ }, object, {}>;
141
216
  declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
142
217
  description: string;
143
218
  objects?: string[] | undefined;
144
- }>;
219
+ }, {}>;
145
220
 
146
221
  declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
147
222
  description: string;
148
223
  transcript?: string | undefined;
149
224
  duration?: number | undefined;
150
- }, object>;
225
+ }, object, {}>;
151
226
  declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
152
227
  description: string;
153
228
  transcript?: string | undefined;
154
229
  duration?: number | undefined;
155
- }>;
230
+ }, {}>;
156
231
 
157
232
  declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
158
233
  query: string;
@@ -165,7 +240,7 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
165
240
  allowedDomains?: string[];
166
241
  excludedDomains?: string[];
167
242
  enableImageUnderstanding?: boolean;
168
- }>;
243
+ }, {}>;
169
244
  declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
170
245
  query: string;
171
246
  sources: Array<{
@@ -173,7 +248,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
173
248
  url: string;
174
249
  snippet: string;
175
250
  }>;
176
- }>;
251
+ }, {}>;
177
252
 
178
253
  declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
179
254
  query: string;
@@ -190,7 +265,7 @@ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWith
190
265
  toDate?: string;
191
266
  enableImageUnderstanding?: boolean;
192
267
  enableVideoUnderstanding?: boolean;
193
- }>;
268
+ }, {}>;
194
269
  declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
195
270
  query: string;
196
271
  posts: Array<{
@@ -199,16 +274,16 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
199
274
  url: string;
200
275
  likes: number;
201
276
  }>;
202
- }>;
277
+ }, {}>;
203
278
 
204
279
  declare const xaiTools: {
205
280
  codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
206
281
  output: string;
207
282
  error?: string | undefined;
208
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
283
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
209
284
  output: string;
210
285
  error?: string | undefined;
211
- }>;
286
+ }, {}>;
212
287
  fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
213
288
  queries: string[];
214
289
  results: null | {
@@ -220,7 +295,7 @@ declare const xaiTools: {
220
295
  }, {
221
296
  vectorStoreIds: string[];
222
297
  maxNumResults?: number;
223
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
298
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
224
299
  queries: string[];
225
300
  results: null | {
226
301
  fileId: string;
@@ -228,7 +303,7 @@ declare const xaiTools: {
228
303
  score: number;
229
304
  text: string;
230
305
  }[];
231
- }>;
306
+ }, {}>;
232
307
  mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
233
308
  name: string;
234
309
  arguments: string;
@@ -240,27 +315,27 @@ declare const xaiTools: {
240
315
  allowedTools?: string[];
241
316
  headers?: Record<string, string>;
242
317
  authorization?: string;
243
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
318
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
244
319
  name: string;
245
320
  arguments: string;
246
321
  result: unknown;
247
- }>;
322
+ }, {}>;
248
323
  viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
249
324
  description: string;
250
325
  objects?: string[] | undefined;
251
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
326
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
252
327
  description: string;
253
328
  objects?: string[] | undefined;
254
- }>;
329
+ }, {}>;
255
330
  viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
256
331
  description: string;
257
332
  transcript?: string | undefined;
258
333
  duration?: number | undefined;
259
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
334
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
260
335
  description: string;
261
336
  transcript?: string | undefined;
262
337
  duration?: number | undefined;
263
- }>;
338
+ }, {}>;
264
339
  webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
265
340
  query: string;
266
341
  sources: Array<{
@@ -272,14 +347,14 @@ declare const xaiTools: {
272
347
  allowedDomains?: string[];
273
348
  excludedDomains?: string[];
274
349
  enableImageUnderstanding?: boolean;
275
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
350
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
276
351
  query: string;
277
352
  sources: Array<{
278
353
  title: string;
279
354
  url: string;
280
355
  snippet: string;
281
356
  }>;
282
- }>;
357
+ }, {}>;
283
358
  xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
284
359
  query: string;
285
360
  posts: Array<{
@@ -295,7 +370,7 @@ declare const xaiTools: {
295
370
  toDate?: string;
296
371
  enableImageUnderstanding?: boolean;
297
372
  enableVideoUnderstanding?: boolean;
298
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
373
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
299
374
  query: string;
300
375
  posts: Array<{
301
376
  author: string;
@@ -303,42 +378,43 @@ declare const xaiTools: {
303
378
  url: string;
304
379
  likes: number;
305
380
  }>;
306
- }>;
381
+ }, {}>;
307
382
  };
308
383
 
309
- interface XaiProvider extends ProviderV3 {
310
- /**
311
- * Creates an Xai chat model for text generation.
312
- */
313
- (modelId: XaiChatModelId): LanguageModelV3;
384
+ interface XaiProvider extends ProviderV4 {
385
+ (modelId: XaiResponsesModelId): LanguageModelV4;
314
386
  /**
315
387
  * Creates an Xai language model for text generation.
316
388
  */
317
- languageModel(modelId: XaiChatModelId): LanguageModelV3;
389
+ languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
318
390
  /**
319
391
  * Creates an Xai chat model for text generation.
320
392
  */
321
- chat: (modelId: XaiChatModelId) => LanguageModelV3;
393
+ chat: (modelId: XaiChatModelId) => LanguageModelV4;
322
394
  /**
323
- * Creates an Xai responses model for agentic tool calling.
395
+ * Creates an Xai responses model for text generation.
324
396
  */
325
- responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
397
+ responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
326
398
  /**
327
399
  * Creates an Xai image model for image generation.
328
400
  */
329
- image(modelId: XaiImageModelId): ImageModelV3;
401
+ image(modelId: XaiImageModelId): ImageModelV4;
330
402
  /**
331
403
  * Creates an Xai image model for image generation.
332
404
  */
333
- imageModel(modelId: XaiImageModelId): ImageModelV3;
405
+ imageModel(modelId: XaiImageModelId): ImageModelV4;
334
406
  /**
335
407
  * Creates an Xai video model for video generation.
336
408
  */
337
- video(modelId: XaiVideoModelId): Experimental_VideoModelV3;
409
+ video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
338
410
  /**
339
411
  * Creates an Xai video model for video generation.
340
412
  */
341
- videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV3;
413
+ videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
414
+ /**
415
+ * Returns the xAI files interface for uploading files.
416
+ */
417
+ files(): FilesV4;
342
418
  /**
343
419
  * Server-side agentic tools for use with the responses API.
344
420
  */
@@ -372,4 +448,4 @@ declare const xai: XaiProvider;
372
448
 
373
449
  declare const VERSION: string;
374
450
 
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 };
451
+ export { VERSION, type XaiErrorData, type XaiFilesOptions, 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 };