@ai-sdk/xai 4.0.0-beta.3 → 4.0.0-beta.30
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 +221 -8
- package/README.md +2 -0
- package/dist/index.d.mts +132 -50
- package/dist/index.d.ts +132 -50
- package/dist/index.js +421 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +433 -88
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +173 -381
- package/package.json +4 -6
- package/src/convert-to-xai-chat-messages.ts +22 -6
- package/src/convert-xai-chat-usage.ts +2 -2
- package/src/files/xai-files-api.ts +16 -0
- package/src/files/xai-files-options.ts +15 -0
- package/src/files/xai-files.ts +93 -0
- package/src/index.ts +1 -0
- package/src/map-xai-finish-reason.ts +2 -2
- package/src/responses/convert-to-xai-responses-input.ts +21 -7
- package/src/responses/convert-xai-responses-usage.ts +2 -2
- package/src/responses/map-xai-responses-finish-reason.ts +3 -2
- package/src/responses/xai-responses-api.ts +31 -1
- package/src/responses/xai-responses-language-model.ts +104 -32
- package/src/responses/xai-responses-options.ts +4 -0
- package/src/responses/xai-responses-prepare-tools.ts +6 -6
- package/src/xai-chat-language-model.ts +41 -22
- package/src/xai-chat-options.ts +3 -6
- package/src/xai-chat-prompt.ts +2 -1
- package/src/xai-image-model.ts +35 -12
- package/src/xai-image-options.ts +2 -0
- package/src/xai-image-settings.ts +0 -2
- package/src/xai-prepare-tools.ts +6 -6
- package/src/xai-provider.ts +34 -21
- package/src/xai-video-model.ts +127 -20
- package/src/xai-video-options.ts +136 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,218 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e5bdc8d: fix (provider/xai): handle mid-stream error chunks
|
|
8
|
+
|
|
9
|
+
## 4.0.0-beta.29
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 813851f: fix (provider/xai): add response.incomplete and response.failed streaming event handling
|
|
14
|
+
|
|
15
|
+
## 4.0.0-beta.28
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [34bd95d]
|
|
20
|
+
- Updated dependencies [008271d]
|
|
21
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
22
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.19
|
|
23
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
24
|
+
|
|
25
|
+
## 4.0.0-beta.27
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [b0c2869]
|
|
30
|
+
- Updated dependencies [7e26e81]
|
|
31
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
32
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.18
|
|
33
|
+
|
|
34
|
+
## 4.0.0-beta.26
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [816ff67]
|
|
39
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.17
|
|
40
|
+
|
|
41
|
+
## 4.0.0-beta.25
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [46d1149]
|
|
46
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
47
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.16
|
|
48
|
+
|
|
49
|
+
## 4.0.0-beta.24
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [6fd51c0]
|
|
54
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
55
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
56
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.15
|
|
57
|
+
|
|
58
|
+
## 4.0.0-beta.23
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
|
|
63
|
+
- Updated dependencies [c29a26f]
|
|
64
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.14
|
|
65
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
66
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
67
|
+
|
|
68
|
+
## 4.0.0-beta.22
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- f51c95e: feat(provider/xai): add video extension and reference-to-video (R2V) support
|
|
73
|
+
|
|
74
|
+
## 4.0.0-beta.21
|
|
75
|
+
|
|
76
|
+
### Patch Changes
|
|
77
|
+
|
|
78
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
79
|
+
- Updated dependencies [38fc777]
|
|
80
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.13
|
|
81
|
+
|
|
82
|
+
## 4.0.0-beta.20
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- Updated dependencies [2e17091]
|
|
87
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
88
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.12
|
|
89
|
+
|
|
90
|
+
## 4.0.0-beta.19
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Updated dependencies [986c6fd]
|
|
95
|
+
- Updated dependencies [493295c]
|
|
96
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
97
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.11
|
|
98
|
+
|
|
99
|
+
## 4.0.0-beta.18
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- 9f20868: fix(provider/xai): correct finish reason for tool calls
|
|
104
|
+
|
|
105
|
+
## 4.0.0-beta.17
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [1f509d4]
|
|
110
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
111
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
112
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.10
|
|
113
|
+
|
|
114
|
+
## 4.0.0-beta.16
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- 4f91b5d: chore(provider/xai): update Grok 4.20 model IDs to their non-beta versions
|
|
119
|
+
|
|
120
|
+
## 4.0.0-beta.15
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
125
|
+
- Updated dependencies [74d520f]
|
|
126
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.9
|
|
127
|
+
|
|
128
|
+
## 4.0.0-beta.14
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- Updated dependencies [3887c70]
|
|
133
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
134
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
135
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.8
|
|
136
|
+
|
|
137
|
+
## 4.0.0-beta.13
|
|
138
|
+
|
|
139
|
+
### Major Changes
|
|
140
|
+
|
|
141
|
+
- 776b617: feat(provider): adding new 'custom' content type
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- Updated dependencies [776b617]
|
|
146
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
147
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
148
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.7
|
|
149
|
+
|
|
150
|
+
## 4.0.0-beta.12
|
|
151
|
+
|
|
152
|
+
### Patch Changes
|
|
153
|
+
|
|
154
|
+
- d20829e: feat(provider/xai): add moderation error, and costInUsdTicks to video model
|
|
155
|
+
- Updated dependencies [61753c3]
|
|
156
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
157
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.6
|
|
158
|
+
|
|
159
|
+
## 4.0.0-beta.11
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- f7d4f01: feat(provider): add support for `reasoning-file` type for files that are part of reasoning
|
|
164
|
+
- Updated dependencies [f7d4f01]
|
|
165
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
166
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
167
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.5
|
|
168
|
+
|
|
169
|
+
## 4.0.0-beta.10
|
|
170
|
+
|
|
171
|
+
### Patch Changes
|
|
172
|
+
|
|
173
|
+
- Updated dependencies [5c2a5a2]
|
|
174
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
175
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.4
|
|
176
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
177
|
+
|
|
178
|
+
## 4.0.0-beta.9
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- Updated dependencies [8f3e1da]
|
|
183
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.3
|
|
184
|
+
|
|
185
|
+
## 4.0.0-beta.8
|
|
186
|
+
|
|
187
|
+
### Patch Changes
|
|
188
|
+
|
|
189
|
+
- 4799fa5: chore(provider/xai): update provider to use v4 types
|
|
190
|
+
|
|
191
|
+
## 4.0.0-beta.7
|
|
192
|
+
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- 0f11f10: add reasoningSummary to responses API provider options
|
|
196
|
+
- 12115e9: fix reasoning text extraction from content in responses doGenerate
|
|
197
|
+
|
|
198
|
+
## 4.0.0-beta.6
|
|
199
|
+
|
|
200
|
+
### Major Changes
|
|
201
|
+
|
|
202
|
+
- f62681f: feat(provider/xai): make responses api the default
|
|
203
|
+
|
|
204
|
+
## 4.0.0-beta.5
|
|
205
|
+
|
|
206
|
+
### Patch Changes
|
|
207
|
+
|
|
208
|
+
- aa5a583: chore(provider/xai): remove obsolete Grok 2 models now that they are shut down in their API
|
|
209
|
+
|
|
210
|
+
## 4.0.0-beta.4
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- 25f1837: feat(xai): add b64_json response format, usage cost tracking, and quality/user parameters for image models
|
|
215
|
+
|
|
3
216
|
## 4.0.0-beta.3
|
|
4
217
|
|
|
5
218
|
### Patch Changes
|
|
@@ -530,13 +743,13 @@
|
|
|
530
743
|
Before
|
|
531
744
|
|
|
532
745
|
```ts
|
|
533
|
-
model.textEmbeddingModel(
|
|
746
|
+
model.textEmbeddingModel("my-model-id");
|
|
534
747
|
```
|
|
535
748
|
|
|
536
749
|
After
|
|
537
750
|
|
|
538
751
|
```ts
|
|
539
|
-
model.embeddingModel(
|
|
752
|
+
model.embeddingModel("my-model-id");
|
|
540
753
|
```
|
|
541
754
|
|
|
542
755
|
- 2625a04: feat(openai); update spec for mcp approval
|
|
@@ -794,13 +1007,13 @@
|
|
|
794
1007
|
Before
|
|
795
1008
|
|
|
796
1009
|
```ts
|
|
797
|
-
model.textEmbeddingModel(
|
|
1010
|
+
model.textEmbeddingModel("my-model-id");
|
|
798
1011
|
```
|
|
799
1012
|
|
|
800
1013
|
After
|
|
801
1014
|
|
|
802
1015
|
```ts
|
|
803
|
-
model.embeddingModel(
|
|
1016
|
+
model.embeddingModel("my-model-id");
|
|
804
1017
|
```
|
|
805
1018
|
|
|
806
1019
|
- 8514146: add grok-4-1 model IDs
|
|
@@ -1343,7 +1556,7 @@
|
|
|
1343
1556
|
|
|
1344
1557
|
```js
|
|
1345
1558
|
await generateImage({
|
|
1346
|
-
model: luma.image(
|
|
1559
|
+
model: luma.image("photon-flash-1", {
|
|
1347
1560
|
maxImagesPerCall: 5,
|
|
1348
1561
|
pollIntervalMillis: 500,
|
|
1349
1562
|
}),
|
|
@@ -1356,7 +1569,7 @@
|
|
|
1356
1569
|
|
|
1357
1570
|
```js
|
|
1358
1571
|
await generateImage({
|
|
1359
|
-
model: luma.image(
|
|
1572
|
+
model: luma.image("photon-flash-1"),
|
|
1360
1573
|
prompt,
|
|
1361
1574
|
n: 10,
|
|
1362
1575
|
maxImagesPerCall: 5,
|
|
@@ -1672,7 +1885,7 @@
|
|
|
1672
1885
|
|
|
1673
1886
|
```js
|
|
1674
1887
|
await generateImage({
|
|
1675
|
-
model: luma.image(
|
|
1888
|
+
model: luma.image("photon-flash-1", {
|
|
1676
1889
|
maxImagesPerCall: 5,
|
|
1677
1890
|
pollIntervalMillis: 500,
|
|
1678
1891
|
}),
|
|
@@ -1685,7 +1898,7 @@
|
|
|
1685
1898
|
|
|
1686
1899
|
```js
|
|
1687
1900
|
await generateImage({
|
|
1688
|
-
model: luma.image(
|
|
1901
|
+
model: luma.image("photon-flash-1"),
|
|
1689
1902
|
prompt,
|
|
1690
1903
|
n: 10,
|
|
1691
1904
|
maxImagesPerCall: 5,
|
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
The **[xAI Grok provider](https://ai-sdk.dev/providers/ai-sdk-providers/xai)** for the [AI SDK](https://ai-sdk.dev/docs)
|
|
4
4
|
contains language model support for the xAI chat and completion APIs.
|
|
5
5
|
|
|
6
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access xAI (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
7
|
+
|
|
6
8
|
## Setup
|
|
7
9
|
|
|
8
10
|
The xAI Grok provider is available in the `@ai-sdk/xai` module. You can install it with
|
package/dist/index.d.mts
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-
|
|
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>;
|
|
@@ -86,29 +91,105 @@ declare const xaiImageModelOptions: z.ZodObject<{
|
|
|
86
91
|
"1k": "1k";
|
|
87
92
|
"2k": "2k";
|
|
88
93
|
}>>;
|
|
94
|
+
quality: z.ZodOptional<z.ZodEnum<{
|
|
95
|
+
low: "low";
|
|
96
|
+
high: "high";
|
|
97
|
+
medium: "medium";
|
|
98
|
+
}>>;
|
|
99
|
+
user: z.ZodOptional<z.ZodString>;
|
|
89
100
|
}, z.core.$strip>;
|
|
90
101
|
type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
91
102
|
|
|
92
103
|
type XaiVideoModelId = 'grok-imagine-video' | (string & {});
|
|
93
104
|
|
|
94
|
-
|
|
105
|
+
declare const resolutionSchema: z.ZodEnum<{
|
|
106
|
+
"480p": "480p";
|
|
107
|
+
"720p": "720p";
|
|
108
|
+
}>;
|
|
109
|
+
type XaiVideoResolution = z.infer<typeof resolutionSchema>;
|
|
110
|
+
interface XaiVideoSharedOptions {
|
|
95
111
|
pollIntervalMs?: number | null;
|
|
96
112
|
pollTimeoutMs?: number | null;
|
|
97
|
-
resolution?:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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;
|
|
175
|
+
|
|
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>;
|
|
101
182
|
|
|
102
|
-
type XaiImageModelId = 'grok-
|
|
183
|
+
type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
|
|
103
184
|
|
|
104
185
|
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
105
186
|
output: string;
|
|
106
187
|
error?: string | undefined;
|
|
107
|
-
}, object>;
|
|
188
|
+
}, object, {}>;
|
|
108
189
|
declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
109
190
|
output: string;
|
|
110
191
|
error?: string | undefined;
|
|
111
|
-
}>;
|
|
192
|
+
}, {}>;
|
|
112
193
|
|
|
113
194
|
declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
114
195
|
name: string;
|
|
@@ -121,32 +202,32 @@ declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
121
202
|
allowedTools?: string[];
|
|
122
203
|
headers?: Record<string, string>;
|
|
123
204
|
authorization?: string;
|
|
124
|
-
}>;
|
|
205
|
+
}, {}>;
|
|
125
206
|
declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
126
207
|
name: string;
|
|
127
208
|
arguments: string;
|
|
128
209
|
result: unknown;
|
|
129
|
-
}>;
|
|
210
|
+
}, {}>;
|
|
130
211
|
|
|
131
212
|
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
132
213
|
description: string;
|
|
133
214
|
objects?: string[] | undefined;
|
|
134
|
-
}, object>;
|
|
215
|
+
}, object, {}>;
|
|
135
216
|
declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
136
217
|
description: string;
|
|
137
218
|
objects?: string[] | undefined;
|
|
138
|
-
}>;
|
|
219
|
+
}, {}>;
|
|
139
220
|
|
|
140
221
|
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
141
222
|
description: string;
|
|
142
223
|
transcript?: string | undefined;
|
|
143
224
|
duration?: number | undefined;
|
|
144
|
-
}, object>;
|
|
225
|
+
}, object, {}>;
|
|
145
226
|
declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
146
227
|
description: string;
|
|
147
228
|
transcript?: string | undefined;
|
|
148
229
|
duration?: number | undefined;
|
|
149
|
-
}>;
|
|
230
|
+
}, {}>;
|
|
150
231
|
|
|
151
232
|
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
152
233
|
query: string;
|
|
@@ -159,7 +240,7 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
159
240
|
allowedDomains?: string[];
|
|
160
241
|
excludedDomains?: string[];
|
|
161
242
|
enableImageUnderstanding?: boolean;
|
|
162
|
-
}>;
|
|
243
|
+
}, {}>;
|
|
163
244
|
declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
164
245
|
query: string;
|
|
165
246
|
sources: Array<{
|
|
@@ -167,7 +248,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
|
|
|
167
248
|
url: string;
|
|
168
249
|
snippet: string;
|
|
169
250
|
}>;
|
|
170
|
-
}>;
|
|
251
|
+
}, {}>;
|
|
171
252
|
|
|
172
253
|
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
173
254
|
query: string;
|
|
@@ -184,7 +265,7 @@ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWith
|
|
|
184
265
|
toDate?: string;
|
|
185
266
|
enableImageUnderstanding?: boolean;
|
|
186
267
|
enableVideoUnderstanding?: boolean;
|
|
187
|
-
}>;
|
|
268
|
+
}, {}>;
|
|
188
269
|
declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
189
270
|
query: string;
|
|
190
271
|
posts: Array<{
|
|
@@ -193,16 +274,16 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
|
|
|
193
274
|
url: string;
|
|
194
275
|
likes: number;
|
|
195
276
|
}>;
|
|
196
|
-
}>;
|
|
277
|
+
}, {}>;
|
|
197
278
|
|
|
198
279
|
declare const xaiTools: {
|
|
199
280
|
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
200
281
|
output: string;
|
|
201
282
|
error?: string | undefined;
|
|
202
|
-
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
283
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
203
284
|
output: string;
|
|
204
285
|
error?: string | undefined;
|
|
205
|
-
}>;
|
|
286
|
+
}, {}>;
|
|
206
287
|
fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
207
288
|
queries: string[];
|
|
208
289
|
results: null | {
|
|
@@ -214,7 +295,7 @@ declare const xaiTools: {
|
|
|
214
295
|
}, {
|
|
215
296
|
vectorStoreIds: string[];
|
|
216
297
|
maxNumResults?: number;
|
|
217
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
298
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
218
299
|
queries: string[];
|
|
219
300
|
results: null | {
|
|
220
301
|
fileId: string;
|
|
@@ -222,7 +303,7 @@ declare const xaiTools: {
|
|
|
222
303
|
score: number;
|
|
223
304
|
text: string;
|
|
224
305
|
}[];
|
|
225
|
-
}>;
|
|
306
|
+
}, {}>;
|
|
226
307
|
mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
227
308
|
name: string;
|
|
228
309
|
arguments: string;
|
|
@@ -234,27 +315,27 @@ declare const xaiTools: {
|
|
|
234
315
|
allowedTools?: string[];
|
|
235
316
|
headers?: Record<string, string>;
|
|
236
317
|
authorization?: string;
|
|
237
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
318
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
238
319
|
name: string;
|
|
239
320
|
arguments: string;
|
|
240
321
|
result: unknown;
|
|
241
|
-
}>;
|
|
322
|
+
}, {}>;
|
|
242
323
|
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
243
324
|
description: string;
|
|
244
325
|
objects?: string[] | undefined;
|
|
245
|
-
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
326
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
246
327
|
description: string;
|
|
247
328
|
objects?: string[] | undefined;
|
|
248
|
-
}>;
|
|
329
|
+
}, {}>;
|
|
249
330
|
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
250
331
|
description: string;
|
|
251
332
|
transcript?: string | undefined;
|
|
252
333
|
duration?: number | undefined;
|
|
253
|
-
}, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
334
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
254
335
|
description: string;
|
|
255
336
|
transcript?: string | undefined;
|
|
256
337
|
duration?: number | undefined;
|
|
257
|
-
}>;
|
|
338
|
+
}, {}>;
|
|
258
339
|
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
259
340
|
query: string;
|
|
260
341
|
sources: Array<{
|
|
@@ -266,14 +347,14 @@ declare const xaiTools: {
|
|
|
266
347
|
allowedDomains?: string[];
|
|
267
348
|
excludedDomains?: string[];
|
|
268
349
|
enableImageUnderstanding?: boolean;
|
|
269
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
350
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
270
351
|
query: string;
|
|
271
352
|
sources: Array<{
|
|
272
353
|
title: string;
|
|
273
354
|
url: string;
|
|
274
355
|
snippet: string;
|
|
275
356
|
}>;
|
|
276
|
-
}>;
|
|
357
|
+
}, {}>;
|
|
277
358
|
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
278
359
|
query: string;
|
|
279
360
|
posts: Array<{
|
|
@@ -289,7 +370,7 @@ declare const xaiTools: {
|
|
|
289
370
|
toDate?: string;
|
|
290
371
|
enableImageUnderstanding?: boolean;
|
|
291
372
|
enableVideoUnderstanding?: boolean;
|
|
292
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
373
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
293
374
|
query: string;
|
|
294
375
|
posts: Array<{
|
|
295
376
|
author: string;
|
|
@@ -297,42 +378,43 @@ declare const xaiTools: {
|
|
|
297
378
|
url: string;
|
|
298
379
|
likes: number;
|
|
299
380
|
}>;
|
|
300
|
-
}>;
|
|
381
|
+
}, {}>;
|
|
301
382
|
};
|
|
302
383
|
|
|
303
|
-
interface XaiProvider extends
|
|
304
|
-
|
|
305
|
-
* Creates an Xai chat model for text generation.
|
|
306
|
-
*/
|
|
307
|
-
(modelId: XaiChatModelId): LanguageModelV3;
|
|
384
|
+
interface XaiProvider extends ProviderV4 {
|
|
385
|
+
(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
308
386
|
/**
|
|
309
387
|
* Creates an Xai language model for text generation.
|
|
310
388
|
*/
|
|
311
|
-
languageModel(modelId:
|
|
389
|
+
languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
312
390
|
/**
|
|
313
391
|
* Creates an Xai chat model for text generation.
|
|
314
392
|
*/
|
|
315
|
-
chat: (modelId: XaiChatModelId) =>
|
|
393
|
+
chat: (modelId: XaiChatModelId) => LanguageModelV4;
|
|
316
394
|
/**
|
|
317
|
-
* Creates an Xai responses model for
|
|
395
|
+
* Creates an Xai responses model for text generation.
|
|
318
396
|
*/
|
|
319
|
-
responses: (modelId: XaiResponsesModelId) =>
|
|
397
|
+
responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
|
|
320
398
|
/**
|
|
321
399
|
* Creates an Xai image model for image generation.
|
|
322
400
|
*/
|
|
323
|
-
image(modelId: XaiImageModelId):
|
|
401
|
+
image(modelId: XaiImageModelId): ImageModelV4;
|
|
324
402
|
/**
|
|
325
403
|
* Creates an Xai image model for image generation.
|
|
326
404
|
*/
|
|
327
|
-
imageModel(modelId: XaiImageModelId):
|
|
405
|
+
imageModel(modelId: XaiImageModelId): ImageModelV4;
|
|
328
406
|
/**
|
|
329
407
|
* Creates an Xai video model for video generation.
|
|
330
408
|
*/
|
|
331
|
-
video(modelId: XaiVideoModelId):
|
|
409
|
+
video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
|
|
332
410
|
/**
|
|
333
411
|
* Creates an Xai video model for video generation.
|
|
334
412
|
*/
|
|
335
|
-
videoModel(modelId: XaiVideoModelId):
|
|
413
|
+
videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
|
|
414
|
+
/**
|
|
415
|
+
* Returns the xAI files interface for uploading files.
|
|
416
|
+
*/
|
|
417
|
+
files(): FilesV4;
|
|
336
418
|
/**
|
|
337
419
|
* Server-side agentic tools for use with the responses API.
|
|
338
420
|
*/
|
|
@@ -366,4 +448,4 @@ declare const xai: XaiProvider;
|
|
|
366
448
|
|
|
367
449
|
declare const VERSION: string;
|
|
368
450
|
|
|
369
|
-
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 };
|