@ai-sdk/xai 3.0.52 → 3.0.53

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/docs/01-xai.mdx CHANGED
@@ -104,6 +104,8 @@ xAI chat models support additional provider options that are not part of
104
104
  the [standard call settings](/docs/ai-sdk-core/settings). You can pass them in the `providerOptions` argument:
105
105
 
106
106
  ```ts
107
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
108
+
107
109
  const model = xai('grok-3-mini');
108
110
 
109
111
  await generateText({
@@ -111,7 +113,7 @@ await generateText({
111
113
  providerOptions: {
112
114
  xai: {
113
115
  reasoningEffort: 'high',
114
- },
116
+ } satisfies XaiLanguageModelChatOptions,
115
117
  },
116
118
  });
117
119
  ```
@@ -342,7 +344,7 @@ const { text } = await generateText({
342
344
  The file search tool enables searching through documents stored in xAI vector stores (collections):
343
345
 
344
346
  ```ts
345
- import { xai } from '@ai-sdk/xai';
347
+ import { xai, type XaiLanguageModelResponsesOptions } from '@ai-sdk/xai';
346
348
  import { streamText } from 'ai';
347
349
 
348
350
  const result = streamText({
@@ -357,7 +359,7 @@ const result = streamText({
357
359
  providerOptions: {
358
360
  xai: {
359
361
  include: ['file_search_call.results'],
360
- },
362
+ } satisfies XaiLanguageModelResponsesOptions,
361
363
  },
362
364
  });
363
365
  ```
@@ -423,7 +425,7 @@ for await (const part of fullStream) {
423
425
  The Responses API supports the following provider options:
424
426
 
425
427
  ```ts
426
- import { xai } from '@ai-sdk/xai';
428
+ import { xai, type XaiLanguageModelResponsesOptions } from '@ai-sdk/xai';
427
429
  import { generateText } from 'ai';
428
430
 
429
431
  const result = await generateText({
@@ -431,7 +433,7 @@ const result = await generateText({
431
433
  providerOptions: {
432
434
  xai: {
433
435
  reasoningEffort: 'high',
434
- },
436
+ } satisfies XaiLanguageModelResponsesOptions,
435
437
  },
436
438
  // ...
437
439
  });
@@ -469,7 +471,7 @@ xAI models support Live Search functionality, allowing them to query real-time d
469
471
  To enable search, specify `searchParameters` with a search mode:
470
472
 
471
473
  ```ts
472
- import { xai } from '@ai-sdk/xai';
474
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
473
475
  import { generateText } from 'ai';
474
476
 
475
477
  const { text, sources } = await generateText({
@@ -482,7 +484,7 @@ const { text, sources } = await generateText({
482
484
  returnCitations: true,
483
485
  maxSearchResults: 5,
484
486
  },
485
- },
487
+ } satisfies XaiLanguageModelChatOptions,
486
488
  },
487
489
  });
488
490
 
@@ -529,6 +531,8 @@ You can specify different types of data sources for search:
529
531
  #### Web Search
530
532
 
531
533
  ```ts
534
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
535
+
532
536
  const result = await generateText({
533
537
  model: xai('grok-3-latest'),
534
538
  prompt: 'Best ski resorts in Switzerland',
@@ -545,7 +549,7 @@ const result = await generateText({
545
549
  },
546
550
  ],
547
551
  },
548
- },
552
+ } satisfies XaiLanguageModelChatOptions,
549
553
  },
550
554
  });
551
555
  ```
@@ -560,6 +564,8 @@ const result = await generateText({
560
564
  #### X (Twitter) Search
561
565
 
562
566
  ```ts
567
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
568
+
563
569
  const result = await generateText({
564
570
  model: xai('grok-3-latest'),
565
571
  prompt: 'Latest updates on Grok AI',
@@ -577,7 +583,7 @@ const result = await generateText({
577
583
  },
578
584
  ],
579
585
  },
580
- },
586
+ } satisfies XaiLanguageModelChatOptions,
581
587
  },
582
588
  });
583
589
  ```
@@ -592,6 +598,8 @@ const result = await generateText({
592
598
  #### News Search
593
599
 
594
600
  ```ts
601
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
602
+
595
603
  const result = await generateText({
596
604
  model: xai('grok-3-latest'),
597
605
  prompt: 'Recent tech industry news',
@@ -608,7 +616,7 @@ const result = await generateText({
608
616
  },
609
617
  ],
610
618
  },
611
- },
619
+ } satisfies XaiLanguageModelChatOptions,
612
620
  },
613
621
  });
614
622
  ```
@@ -622,6 +630,8 @@ const result = await generateText({
622
630
  #### RSS Feed Search
623
631
 
624
632
  ```ts
633
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
634
+
625
635
  const result = await generateText({
626
636
  model: xai('grok-3-latest'),
627
637
  prompt: 'Latest status updates',
@@ -636,7 +646,7 @@ const result = await generateText({
636
646
  },
637
647
  ],
638
648
  },
639
- },
649
+ } satisfies XaiLanguageModelChatOptions,
640
650
  },
641
651
  });
642
652
  ```
@@ -650,6 +660,8 @@ const result = await generateText({
650
660
  You can combine multiple data sources in a single search:
651
661
 
652
662
  ```ts
663
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
664
+
653
665
  const result = await generateText({
654
666
  model: xai('grok-3-latest'),
655
667
  prompt: 'Comprehensive overview of recent AI breakthroughs',
@@ -674,7 +686,7 @@ const result = await generateText({
674
686
  },
675
687
  ],
676
688
  },
677
- },
689
+ } satisfies XaiLanguageModelChatOptions,
678
690
  },
679
691
  });
680
692
  ```
@@ -684,6 +696,8 @@ const result = await generateText({
684
696
  When search is enabled with `returnCitations: true`, the response includes sources that were used to generate the answer:
685
697
 
686
698
  ```ts
699
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
700
+
687
701
  const { text, sources } = await generateText({
688
702
  model: xai('grok-3-latest'),
689
703
  prompt: 'What are the latest developments in AI?',
@@ -693,7 +707,7 @@ const { text, sources } = await generateText({
693
707
  mode: 'auto',
694
708
  returnCitations: true,
695
709
  },
696
- },
710
+ } satisfies XaiLanguageModelChatOptions,
697
711
  },
698
712
  });
699
713
 
@@ -710,6 +724,7 @@ for (const source of sources) {
710
724
  Live Search works with streaming responses. Citations are included when the stream completes:
711
725
 
712
726
  ```ts
727
+ import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
713
728
  import { streamText } from 'ai';
714
729
 
715
730
  const result = streamText({
@@ -721,7 +736,7 @@ const result = streamText({
721
736
  mode: 'auto',
722
737
  returnCitations: true,
723
738
  },
724
- },
739
+ } satisfies XaiLanguageModelChatOptions,
725
740
  },
726
741
  });
727
742
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/xai",
3
- "version": "3.0.52",
3
+ "version": "3.0.53",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -29,9 +29,9 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "2.0.28",
33
32
  "@ai-sdk/provider": "3.0.8",
34
- "@ai-sdk/provider-utils": "4.0.14"
33
+ "@ai-sdk/provider-utils": "4.0.14",
34
+ "@ai-sdk/openai-compatible": "2.0.29"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
package/src/index.ts CHANGED
@@ -1,7 +1,19 @@
1
- export type { XaiProviderOptions } from './xai-chat-options';
1
+ export type {
2
+ XaiLanguageModelChatOptions,
3
+ /** @deprecated Use `XaiLanguageModelChatOptions` instead. */
4
+ XaiLanguageModelChatOptions as XaiProviderOptions,
5
+ } from './xai-chat-options';
2
6
  export type { XaiErrorData } from './xai-error';
3
- export type { XaiImageProviderOptions } from './xai-image-options';
4
- export type { XaiResponsesProviderOptions } from './responses/xai-responses-options';
7
+ export type {
8
+ XaiLanguageModelResponsesOptions,
9
+ /** @deprecated Use `XaiLanguageModelResponsesOptions` instead. */
10
+ XaiLanguageModelResponsesOptions as XaiResponsesProviderOptions,
11
+ } from './responses/xai-responses-options';
12
+ export type {
13
+ XaiImageModelOptions,
14
+ /** @deprecated Use `XaiImageModelOptions` instead. */
15
+ XaiImageModelOptions as XaiImageProviderOptions,
16
+ } from './xai-image-options';
5
17
  export { createXai, xai } from './xai-provider';
6
18
  export type { XaiProvider, XaiProviderSettings } from './xai-provider';
7
19
  export {
@@ -31,7 +31,7 @@ import {
31
31
  } from './xai-responses-api';
32
32
  import {
33
33
  XaiResponsesModelId,
34
- xaiResponsesProviderOptions,
34
+ xaiLanguageModelResponsesOptions,
35
35
  } from './xai-responses-options';
36
36
  import { prepareResponsesTools } from './xai-responses-prepare-tools';
37
37
 
@@ -81,7 +81,7 @@ export class XaiResponsesLanguageModel implements LanguageModelV3 {
81
81
  (await parseProviderOptions({
82
82
  provider: 'xai',
83
83
  providerOptions,
84
- schema: xaiResponsesProviderOptions,
84
+ schema: xaiLanguageModelResponsesOptions,
85
85
  })) ?? {};
86
86
 
87
87
  if (stopSequences != null) {
@@ -11,7 +11,7 @@ export type XaiResponsesModelId =
11
11
  /**
12
12
  * @see https://docs.x.ai/docs/api-reference#create-new-response
13
13
  */
14
- export const xaiResponsesProviderOptions = z.object({
14
+ export const xaiLanguageModelResponsesOptions = z.object({
15
15
  /**
16
16
  * Constrains how hard a reasoning model thinks before responding.
17
17
  * Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
@@ -33,6 +33,6 @@ export const xaiResponsesProviderOptions = z.object({
33
33
  include: z.array(z.enum(['file_search_call.results'])).nullish(),
34
34
  });
35
35
 
36
- export type XaiResponsesProviderOptions = z.infer<
37
- typeof xaiResponsesProviderOptions
36
+ export type XaiLanguageModelResponsesOptions = z.infer<
37
+ typeof xaiLanguageModelResponsesOptions
38
38
  >;
@@ -26,7 +26,10 @@ import { convertToXaiChatMessages } from './convert-to-xai-chat-messages';
26
26
  import { convertXaiChatUsage } from './convert-xai-chat-usage';
27
27
  import { getResponseMetadata } from './get-response-metadata';
28
28
  import { mapXaiFinishReason } from './map-xai-finish-reason';
29
- import { XaiChatModelId, xaiProviderOptions } from './xai-chat-options';
29
+ import {
30
+ XaiChatModelId,
31
+ xaiLanguageModelChatOptions,
32
+ } from './xai-chat-options';
30
33
  import { xaiFailedResponseHandler } from './xai-error';
31
34
  import { prepareTools } from './xai-prepare-tools';
32
35
 
@@ -80,7 +83,7 @@ export class XaiChatLanguageModel implements LanguageModelV3 {
80
83
  (await parseProviderOptions({
81
84
  provider: 'xai',
82
85
  providerOptions,
83
- schema: xaiProviderOptions,
86
+ schema: xaiLanguageModelChatOptions,
84
87
  })) ?? {};
85
88
 
86
89
  // check for unsupported parameters
@@ -72,7 +72,7 @@ const searchSourceSchema = z.discriminatedUnion('type', [
72
72
  ]);
73
73
 
74
74
  // xai-specific provider options
75
- export const xaiProviderOptions = z.object({
75
+ export const xaiLanguageModelChatOptions = z.object({
76
76
  reasoningEffort: z.enum(['low', 'high']).optional(),
77
77
 
78
78
  /**
@@ -127,4 +127,6 @@ export const xaiProviderOptions = z.object({
127
127
  .optional(),
128
128
  });
129
129
 
130
- export type XaiProviderOptions = z.infer<typeof xaiProviderOptions>;
130
+ export type XaiLanguageModelChatOptions = z.infer<
131
+ typeof xaiLanguageModelChatOptions
132
+ >;
@@ -12,7 +12,7 @@ import {
12
12
  } from '@ai-sdk/provider-utils';
13
13
  import { z } from 'zod/v4';
14
14
  import { xaiFailedResponseHandler } from './xai-error';
15
- import { xaiImageProviderOptions } from './xai-image-options';
15
+ import { xaiImageModelOptions } from './xai-image-options';
16
16
  import { XaiImageModelId } from './xai-image-settings';
17
17
 
18
18
  interface XaiImageModelConfig {
@@ -80,7 +80,7 @@ export class XaiImageModel implements ImageModelV3 {
80
80
  const xaiOptions = await parseProviderOptions({
81
81
  provider: 'xai',
82
82
  providerOptions,
83
- schema: xaiImageProviderOptions,
83
+ schema: xaiImageModelOptions,
84
84
  });
85
85
 
86
86
  const hasFiles = files != null && files.length > 0;
@@ -1,9 +1,9 @@
1
1
  import { z } from 'zod/v4';
2
2
 
3
- export const xaiImageProviderOptions = z.object({
3
+ export const xaiImageModelOptions = z.object({
4
4
  aspect_ratio: z.string().optional(),
5
5
  output_format: z.string().optional(),
6
6
  sync_mode: z.boolean().optional(),
7
7
  });
8
8
 
9
- export type XaiImageProviderOptions = z.infer<typeof xaiImageProviderOptions>;
9
+ export type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;