@ai-sdk/xai 4.0.0-beta.4 → 4.0.0-beta.6
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 +12 -0
- package/dist/index.d.mts +5 -8
- package/dist/index.d.ts +5 -8
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +8 -335
- package/package.json +2 -2
- package/src/xai-chat-options.ts +0 -6
- package/src/xai-image-settings.ts +0 -2
- package/src/xai-provider.ts +6 -9
package/docs/01-xai.mdx
CHANGED
|
@@ -79,7 +79,7 @@ first argument is the model id, e.g. `grok-3`.
|
|
|
79
79
|
const model = xai('grok-3');
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
By default, `xai(modelId)` uses the
|
|
82
|
+
By default, `xai(modelId)` uses the Responses API. To use the [Chat Completions API](https://docs.x.ai/docs/api-reference#chat-completions) (legacy), use `xai.chat(modelId)`.
|
|
83
83
|
|
|
84
84
|
### Example
|
|
85
85
|
|
|
@@ -99,47 +99,9 @@ xAI language models can also be used in the `streamText` function
|
|
|
99
99
|
and support structured data generation with [`Output`](/docs/reference/ai-sdk-core/output)
|
|
100
100
|
(see [AI SDK Core](/docs/ai-sdk-core)).
|
|
101
101
|
|
|
102
|
-
### Provider Options
|
|
103
|
-
|
|
104
|
-
xAI chat models support additional provider options that are not part of
|
|
105
|
-
the [standard call settings](/docs/ai-sdk-core/settings). You can pass them in the `providerOptions` argument:
|
|
106
|
-
|
|
107
|
-
```ts
|
|
108
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
109
|
-
|
|
110
|
-
const model = xai('grok-3-mini');
|
|
111
|
-
|
|
112
|
-
await generateText({
|
|
113
|
-
model,
|
|
114
|
-
providerOptions: {
|
|
115
|
-
xai: {
|
|
116
|
-
reasoningEffort: 'high',
|
|
117
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
The following optional provider options are available for xAI chat models:
|
|
123
|
-
|
|
124
|
-
- **reasoningEffort** _'low' | 'high'_
|
|
125
|
-
|
|
126
|
-
Reasoning effort for reasoning models.
|
|
127
|
-
|
|
128
|
-
- **logprobs** _boolean_
|
|
129
|
-
|
|
130
|
-
Return log probabilities for output tokens.
|
|
131
|
-
|
|
132
|
-
- **topLogprobs** _number_
|
|
133
|
-
|
|
134
|
-
Number of most likely tokens to return per token position (0-8). When set, `logprobs` is automatically enabled.
|
|
135
|
-
|
|
136
|
-
- **parallel_function_calling** _boolean_
|
|
137
|
-
|
|
138
|
-
Whether to enable parallel function calling during tool use. When true, the model can call multiple functions in parallel. When false, the model will call functions sequentially. Defaults to `true`.
|
|
139
|
-
|
|
140
102
|
## Responses API (Agentic Tools)
|
|
141
103
|
|
|
142
|
-
|
|
104
|
+
The xAI Responses API is the default when using `xai(modelId)`. You can also use `xai.responses(modelId)` explicitly. This enables the model to autonomously orchestrate tool calls and research on xAI's servers.
|
|
143
105
|
|
|
144
106
|
```ts
|
|
145
107
|
const model = xai.responses('grok-4-fast-non-reasoning');
|
|
@@ -164,7 +126,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
164
126
|
import { generateText } from 'ai';
|
|
165
127
|
|
|
166
128
|
const { text } = await generateText({
|
|
167
|
-
model: xai.responses('grok-
|
|
129
|
+
model: xai.responses('grok-3'),
|
|
168
130
|
messages: [
|
|
169
131
|
{
|
|
170
132
|
role: 'user',
|
|
@@ -479,291 +441,6 @@ The following provider options are available:
|
|
|
479
441
|
tools with client-side function tools in the same request.
|
|
480
442
|
</Note>
|
|
481
443
|
|
|
482
|
-
## Live Search
|
|
483
|
-
|
|
484
|
-
xAI models support Live Search functionality, allowing them to query real-time data from various sources and include it in responses with citations.
|
|
485
|
-
|
|
486
|
-
### Basic Search
|
|
487
|
-
|
|
488
|
-
To enable search, specify `searchParameters` with a search mode:
|
|
489
|
-
|
|
490
|
-
```ts
|
|
491
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
492
|
-
import { generateText } from 'ai';
|
|
493
|
-
|
|
494
|
-
const { text, sources } = await generateText({
|
|
495
|
-
model: xai('grok-3-latest'),
|
|
496
|
-
prompt: 'What are the latest developments in AI?',
|
|
497
|
-
providerOptions: {
|
|
498
|
-
xai: {
|
|
499
|
-
searchParameters: {
|
|
500
|
-
mode: 'auto', // 'auto', 'on', or 'off'
|
|
501
|
-
returnCitations: true,
|
|
502
|
-
maxSearchResults: 5,
|
|
503
|
-
},
|
|
504
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
505
|
-
},
|
|
506
|
-
});
|
|
507
|
-
|
|
508
|
-
console.log(text);
|
|
509
|
-
console.log('Sources:', sources);
|
|
510
|
-
```
|
|
511
|
-
|
|
512
|
-
### Search Parameters
|
|
513
|
-
|
|
514
|
-
The following search parameters are available:
|
|
515
|
-
|
|
516
|
-
- **mode** _'auto' | 'on' | 'off'_
|
|
517
|
-
|
|
518
|
-
Search mode preference:
|
|
519
|
-
|
|
520
|
-
- `'auto'` (default): Model decides whether to search
|
|
521
|
-
- `'on'`: Always enables search
|
|
522
|
-
- `'off'`: Disables search completely
|
|
523
|
-
|
|
524
|
-
- **returnCitations** _boolean_
|
|
525
|
-
|
|
526
|
-
Whether to return citations in the response. Defaults to `true`.
|
|
527
|
-
|
|
528
|
-
- **fromDate** _string_
|
|
529
|
-
|
|
530
|
-
Start date for search data in ISO8601 format (`YYYY-MM-DD`).
|
|
531
|
-
|
|
532
|
-
- **toDate** _string_
|
|
533
|
-
|
|
534
|
-
End date for search data in ISO8601 format (`YYYY-MM-DD`).
|
|
535
|
-
|
|
536
|
-
- **maxSearchResults** _number_
|
|
537
|
-
|
|
538
|
-
Maximum number of search results to consider. Defaults to 20, max 50.
|
|
539
|
-
|
|
540
|
-
- **sources** _Array<SearchSource>_
|
|
541
|
-
|
|
542
|
-
Data sources to search from. Defaults to `["web", "x"]` if not specified.
|
|
543
|
-
|
|
544
|
-
### Search Sources
|
|
545
|
-
|
|
546
|
-
You can specify different types of data sources for search:
|
|
547
|
-
|
|
548
|
-
#### Web Search
|
|
549
|
-
|
|
550
|
-
```ts
|
|
551
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
552
|
-
|
|
553
|
-
const result = await generateText({
|
|
554
|
-
model: xai('grok-3-latest'),
|
|
555
|
-
prompt: 'Best ski resorts in Switzerland',
|
|
556
|
-
providerOptions: {
|
|
557
|
-
xai: {
|
|
558
|
-
searchParameters: {
|
|
559
|
-
mode: 'on',
|
|
560
|
-
sources: [
|
|
561
|
-
{
|
|
562
|
-
type: 'web',
|
|
563
|
-
country: 'CH', // ISO alpha-2 country code
|
|
564
|
-
allowedWebsites: ['ski.com', 'snow-forecast.com'],
|
|
565
|
-
safeSearch: true,
|
|
566
|
-
},
|
|
567
|
-
],
|
|
568
|
-
},
|
|
569
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
570
|
-
},
|
|
571
|
-
});
|
|
572
|
-
```
|
|
573
|
-
|
|
574
|
-
#### Web source parameters
|
|
575
|
-
|
|
576
|
-
- **country** _string_: ISO alpha-2 country code
|
|
577
|
-
- **allowedWebsites** _string[]_: Max 5 allowed websites
|
|
578
|
-
- **excludedWebsites** _string[]_: Max 5 excluded websites
|
|
579
|
-
- **safeSearch** _boolean_: Enable safe search (default: true)
|
|
580
|
-
|
|
581
|
-
#### X (Twitter) Search
|
|
582
|
-
|
|
583
|
-
```ts
|
|
584
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
585
|
-
|
|
586
|
-
const result = await generateText({
|
|
587
|
-
model: xai('grok-3-latest'),
|
|
588
|
-
prompt: 'Latest updates on Grok AI',
|
|
589
|
-
providerOptions: {
|
|
590
|
-
xai: {
|
|
591
|
-
searchParameters: {
|
|
592
|
-
mode: 'on',
|
|
593
|
-
sources: [
|
|
594
|
-
{
|
|
595
|
-
type: 'x',
|
|
596
|
-
includedXHandles: ['grok', 'xai'],
|
|
597
|
-
excludedXHandles: ['openai'],
|
|
598
|
-
postFavoriteCount: 10,
|
|
599
|
-
postViewCount: 100,
|
|
600
|
-
},
|
|
601
|
-
],
|
|
602
|
-
},
|
|
603
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
604
|
-
},
|
|
605
|
-
});
|
|
606
|
-
```
|
|
607
|
-
|
|
608
|
-
#### X source parameters
|
|
609
|
-
|
|
610
|
-
- **includedXHandles** _string[]_: Array of X handles to search (without @ symbol)
|
|
611
|
-
- **excludedXHandles** _string[]_: Array of X handles to exclude from search (without @ symbol)
|
|
612
|
-
- **postFavoriteCount** _number_: Minimum favorite count of the X posts to consider.
|
|
613
|
-
- **postViewCount** _number_: Minimum view count of the X posts to consider.
|
|
614
|
-
|
|
615
|
-
#### News Search
|
|
616
|
-
|
|
617
|
-
```ts
|
|
618
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
619
|
-
|
|
620
|
-
const result = await generateText({
|
|
621
|
-
model: xai('grok-3-latest'),
|
|
622
|
-
prompt: 'Recent tech industry news',
|
|
623
|
-
providerOptions: {
|
|
624
|
-
xai: {
|
|
625
|
-
searchParameters: {
|
|
626
|
-
mode: 'on',
|
|
627
|
-
sources: [
|
|
628
|
-
{
|
|
629
|
-
type: 'news',
|
|
630
|
-
country: 'US',
|
|
631
|
-
excludedWebsites: ['tabloid.com'],
|
|
632
|
-
safeSearch: true,
|
|
633
|
-
},
|
|
634
|
-
],
|
|
635
|
-
},
|
|
636
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
637
|
-
},
|
|
638
|
-
});
|
|
639
|
-
```
|
|
640
|
-
|
|
641
|
-
#### News source parameters
|
|
642
|
-
|
|
643
|
-
- **country** _string_: ISO alpha-2 country code
|
|
644
|
-
- **excludedWebsites** _string[]_: Max 5 excluded websites
|
|
645
|
-
- **safeSearch** _boolean_: Enable safe search (default: true)
|
|
646
|
-
|
|
647
|
-
#### RSS Feed Search
|
|
648
|
-
|
|
649
|
-
```ts
|
|
650
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
651
|
-
|
|
652
|
-
const result = await generateText({
|
|
653
|
-
model: xai('grok-3-latest'),
|
|
654
|
-
prompt: 'Latest status updates',
|
|
655
|
-
providerOptions: {
|
|
656
|
-
xai: {
|
|
657
|
-
searchParameters: {
|
|
658
|
-
mode: 'on',
|
|
659
|
-
sources: [
|
|
660
|
-
{
|
|
661
|
-
type: 'rss',
|
|
662
|
-
links: ['https://status.x.ai/feed.xml'],
|
|
663
|
-
},
|
|
664
|
-
],
|
|
665
|
-
},
|
|
666
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
667
|
-
},
|
|
668
|
-
});
|
|
669
|
-
```
|
|
670
|
-
|
|
671
|
-
#### RSS source parameters
|
|
672
|
-
|
|
673
|
-
- **links** _string[]_: Array of RSS feed URLs (max 1 currently supported)
|
|
674
|
-
|
|
675
|
-
### Multiple Sources
|
|
676
|
-
|
|
677
|
-
You can combine multiple data sources in a single search:
|
|
678
|
-
|
|
679
|
-
```ts
|
|
680
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
681
|
-
|
|
682
|
-
const result = await generateText({
|
|
683
|
-
model: xai('grok-3-latest'),
|
|
684
|
-
prompt: 'Comprehensive overview of recent AI breakthroughs',
|
|
685
|
-
providerOptions: {
|
|
686
|
-
xai: {
|
|
687
|
-
searchParameters: {
|
|
688
|
-
mode: 'on',
|
|
689
|
-
returnCitations: true,
|
|
690
|
-
maxSearchResults: 15,
|
|
691
|
-
sources: [
|
|
692
|
-
{
|
|
693
|
-
type: 'web',
|
|
694
|
-
allowedWebsites: ['arxiv.org', 'openai.com'],
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
type: 'news',
|
|
698
|
-
country: 'US',
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
type: 'x',
|
|
702
|
-
includedXHandles: ['openai', 'deepmind'],
|
|
703
|
-
},
|
|
704
|
-
],
|
|
705
|
-
},
|
|
706
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
707
|
-
},
|
|
708
|
-
});
|
|
709
|
-
```
|
|
710
|
-
|
|
711
|
-
### Sources and Citations
|
|
712
|
-
|
|
713
|
-
When search is enabled with `returnCitations: true`, the response includes sources that were used to generate the answer:
|
|
714
|
-
|
|
715
|
-
```ts
|
|
716
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
717
|
-
|
|
718
|
-
const { text, sources } = await generateText({
|
|
719
|
-
model: xai('grok-3-latest'),
|
|
720
|
-
prompt: 'What are the latest developments in AI?',
|
|
721
|
-
providerOptions: {
|
|
722
|
-
xai: {
|
|
723
|
-
searchParameters: {
|
|
724
|
-
mode: 'auto',
|
|
725
|
-
returnCitations: true,
|
|
726
|
-
},
|
|
727
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
728
|
-
},
|
|
729
|
-
});
|
|
730
|
-
|
|
731
|
-
// Access the sources used
|
|
732
|
-
for (const source of sources) {
|
|
733
|
-
if (source.sourceType === 'url') {
|
|
734
|
-
console.log('Source:', source.url);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
```
|
|
738
|
-
|
|
739
|
-
### Streaming with Search
|
|
740
|
-
|
|
741
|
-
Live Search works with streaming responses. Citations are included when the stream completes:
|
|
742
|
-
|
|
743
|
-
```ts
|
|
744
|
-
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
745
|
-
import { streamText } from 'ai';
|
|
746
|
-
|
|
747
|
-
const result = streamText({
|
|
748
|
-
model: xai('grok-3-latest'),
|
|
749
|
-
prompt: 'What has happened in tech recently?',
|
|
750
|
-
providerOptions: {
|
|
751
|
-
xai: {
|
|
752
|
-
searchParameters: {
|
|
753
|
-
mode: 'auto',
|
|
754
|
-
returnCitations: true,
|
|
755
|
-
},
|
|
756
|
-
} satisfies XaiLanguageModelChatOptions,
|
|
757
|
-
},
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
for await (const textPart of result.textStream) {
|
|
761
|
-
process.stdout.write(textPart);
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
console.log('Sources:', await result.sources);
|
|
765
|
-
```
|
|
766
|
-
|
|
767
444
|
## Model Capabilities
|
|
768
445
|
|
|
769
446
|
| Model | Image Input | Object Generation | Tool Usage | Tool Streaming | Reasoning |
|
|
@@ -781,9 +458,6 @@ console.log('Sources:', await result.sources);
|
|
|
781
458
|
| `grok-3-latest` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
|
|
782
459
|
| `grok-3-mini` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
783
460
|
| `grok-3-mini-latest` | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
784
|
-
| `grok-2-vision` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
|
|
785
|
-
| `grok-2-vision-latest` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
|
|
786
|
-
| `grok-2-vision-1212` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
|
|
787
461
|
|
|
788
462
|
<Note>
|
|
789
463
|
The table above lists popular models. Please see the [xAI
|
|
@@ -800,7 +474,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
800
474
|
import { generateImage } from 'ai';
|
|
801
475
|
|
|
802
476
|
const { image } = await generateImage({
|
|
803
|
-
model: xai.image('grok-
|
|
477
|
+
model: xai.image('grok-imagine-image'),
|
|
804
478
|
prompt: 'A futuristic cityscape at sunset',
|
|
805
479
|
});
|
|
806
480
|
```
|
|
@@ -813,7 +487,7 @@ const { image } = await generateImage({
|
|
|
813
487
|
|
|
814
488
|
### Image Editing
|
|
815
489
|
|
|
816
|
-
xAI supports image editing through the `grok-
|
|
490
|
+
xAI supports image editing through the `grok-imagine-image` model. Pass input images via `prompt.images` to transform or edit existing images.
|
|
817
491
|
|
|
818
492
|
<Note>
|
|
819
493
|
xAI image editing does not support masks. Editing is prompt-driven - describe
|
|
@@ -832,7 +506,7 @@ import { readFileSync } from 'fs';
|
|
|
832
506
|
const imageBuffer = readFileSync('./input-image.png');
|
|
833
507
|
|
|
834
508
|
const { images } = await generateImage({
|
|
835
|
-
model: xai.image('grok-
|
|
509
|
+
model: xai.image('grok-imagine-image'),
|
|
836
510
|
prompt: {
|
|
837
511
|
text: 'Turn the cat into a golden retriever dog',
|
|
838
512
|
images: [imageBuffer],
|
|
@@ -869,7 +543,7 @@ Apply artistic styles to an image:
|
|
|
869
543
|
const imageBuffer = readFileSync('./input-image.png');
|
|
870
544
|
|
|
871
545
|
const { images } = await generateImage({
|
|
872
|
-
model: xai.image('grok-
|
|
546
|
+
model: xai.image('grok-imagine-image'),
|
|
873
547
|
prompt: {
|
|
874
548
|
text: 'Transform this into a watercolor painting style',
|
|
875
549
|
images: [imageBuffer],
|
|
@@ -892,7 +566,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
892
566
|
import { generateImage } from 'ai';
|
|
893
567
|
|
|
894
568
|
const { images } = await generateImage({
|
|
895
|
-
model: xai.image('grok-
|
|
569
|
+
model: xai.image('grok-imagine-image'),
|
|
896
570
|
prompt: 'A futuristic cityscape at sunset',
|
|
897
571
|
aspectRatio: '16:9',
|
|
898
572
|
n: 2,
|
|
@@ -903,7 +577,6 @@ const { images } = await generateImage({
|
|
|
903
577
|
|
|
904
578
|
| Model | Aspect Ratios | Image Editing |
|
|
905
579
|
| -------------------- | ----------------------------------------------------------------------------------------------------------- | ------------------- |
|
|
906
|
-
| `grok-2-image` | `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `2:1`, `1:2`, `19.5:9`, `9:19.5`, `20:9`, `9:20`, `auto` | <Check size={18} /> |
|
|
907
580
|
| `grok-imagine-image` | `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `2:1`, `1:2`, `19.5:9`, `9:19.5`, `20:9`, `9:20`, `auto` | <Check size={18} /> |
|
|
908
581
|
|
|
909
582
|
## Video Models
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/provider": "4.0.0-beta.0",
|
|
33
32
|
"@ai-sdk/openai-compatible": "3.0.0-beta.2",
|
|
33
|
+
"@ai-sdk/provider": "4.0.0-beta.0",
|
|
34
34
|
"@ai-sdk/provider-utils": "5.0.0-beta.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
package/src/xai-chat-options.ts
CHANGED
|
@@ -14,12 +14,6 @@ export type XaiChatModelId =
|
|
|
14
14
|
| 'grok-3-latest'
|
|
15
15
|
| 'grok-3-mini'
|
|
16
16
|
| 'grok-3-mini-latest'
|
|
17
|
-
| 'grok-2-vision-1212'
|
|
18
|
-
| 'grok-2-vision'
|
|
19
|
-
| 'grok-2-vision-latest'
|
|
20
|
-
| 'grok-2-image-1212'
|
|
21
|
-
| 'grok-2-image'
|
|
22
|
-
| 'grok-2-image-latest'
|
|
23
17
|
| (string & {});
|
|
24
18
|
|
|
25
19
|
// search source schemas
|
package/src/xai-provider.ts
CHANGED
|
@@ -24,15 +24,12 @@ import { XaiVideoModel } from './xai-video-model';
|
|
|
24
24
|
import { XaiVideoModelId } from './xai-video-settings';
|
|
25
25
|
|
|
26
26
|
export interface XaiProvider extends ProviderV3 {
|
|
27
|
-
|
|
28
|
-
* Creates an Xai chat model for text generation.
|
|
29
|
-
*/
|
|
30
|
-
(modelId: XaiChatModelId): LanguageModelV3;
|
|
27
|
+
(modelId: XaiResponsesModelId): LanguageModelV3;
|
|
31
28
|
|
|
32
29
|
/**
|
|
33
30
|
* Creates an Xai language model for text generation.
|
|
34
31
|
*/
|
|
35
|
-
languageModel(modelId:
|
|
32
|
+
languageModel(modelId: XaiResponsesModelId): LanguageModelV3;
|
|
36
33
|
|
|
37
34
|
/**
|
|
38
35
|
* Creates an Xai chat model for text generation.
|
|
@@ -40,7 +37,7 @@ export interface XaiProvider extends ProviderV3 {
|
|
|
40
37
|
chat: (modelId: XaiChatModelId) => LanguageModelV3;
|
|
41
38
|
|
|
42
39
|
/**
|
|
43
|
-
* Creates an Xai responses model for
|
|
40
|
+
* Creates an Xai responses model for text generation.
|
|
44
41
|
*/
|
|
45
42
|
responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
|
|
46
43
|
|
|
@@ -153,11 +150,11 @@ export function createXai(options: XaiProviderSettings = {}): XaiProvider {
|
|
|
153
150
|
});
|
|
154
151
|
};
|
|
155
152
|
|
|
156
|
-
const provider = (modelId:
|
|
157
|
-
|
|
153
|
+
const provider = (modelId: XaiResponsesModelId) =>
|
|
154
|
+
createResponsesLanguageModel(modelId);
|
|
158
155
|
|
|
159
156
|
provider.specificationVersion = 'v3' as const;
|
|
160
|
-
provider.languageModel =
|
|
157
|
+
provider.languageModel = createResponsesLanguageModel;
|
|
161
158
|
provider.chat = createChatLanguageModel;
|
|
162
159
|
provider.responses = createResponsesLanguageModel;
|
|
163
160
|
provider.embeddingModel = (modelId: string) => {
|