@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/CHANGELOG.md +319 -8
- package/README.md +2 -0
- package/dist/index.d.ts +126 -50
- package/dist/index.js +1169 -749
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +173 -381
- package/package.json +8 -10
- 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 +63 -8
- 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 +134 -48
- package/src/responses/xai-responses-options.ts +6 -0
- package/src/responses/xai-responses-prepare-tools.ts +6 -6
- package/src/xai-chat-language-model.ts +61 -25
- package/src/xai-chat-options.ts +3 -6
- package/src/xai-chat-prompt.ts +2 -1
- package/src/xai-image-model.ts +25 -8
- 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/dist/index.d.mts +0 -375
- package/dist/index.mjs +0 -3061
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,316 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.41
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f807e45]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
9
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.29
|
|
10
|
+
|
|
11
|
+
## 4.0.0-beta.40
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [350ea38]
|
|
16
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
17
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.28
|
|
18
|
+
|
|
19
|
+
## 4.0.0-beta.39
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [083947b]
|
|
24
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
25
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.27
|
|
26
|
+
|
|
27
|
+
## 4.0.0-beta.38
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [add1126]
|
|
32
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
33
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.26
|
|
34
|
+
|
|
35
|
+
## 4.0.0-beta.37
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- 8d87577: fix(xai): support encrypted reasoning round-trip for ZDR
|
|
40
|
+
|
|
41
|
+
## 4.0.0-beta.36
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
46
|
+
|
|
47
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
48
|
+
|
|
49
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
50
|
+
|
|
51
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [b3976a2]
|
|
54
|
+
- Updated dependencies [ff5eba1]
|
|
55
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
56
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.25
|
|
57
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
58
|
+
|
|
59
|
+
## 4.0.0-beta.35
|
|
60
|
+
|
|
61
|
+
### Major Changes
|
|
62
|
+
|
|
63
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [ef992f8]
|
|
68
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.24
|
|
69
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
70
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
71
|
+
|
|
72
|
+
## 4.0.0-beta.34
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
77
|
+
- Updated dependencies [90e2d8a]
|
|
78
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.23
|
|
79
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
80
|
+
|
|
81
|
+
## 4.0.0-beta.33
|
|
82
|
+
|
|
83
|
+
### Patch Changes
|
|
84
|
+
|
|
85
|
+
- Updated dependencies [3ae1786]
|
|
86
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
87
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.22
|
|
88
|
+
|
|
89
|
+
## 4.0.0-beta.32
|
|
90
|
+
|
|
91
|
+
### Patch Changes
|
|
92
|
+
|
|
93
|
+
- Updated dependencies [176466a]
|
|
94
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
95
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.21
|
|
96
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
97
|
+
|
|
98
|
+
## 4.0.0-beta.31
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [e311194]
|
|
103
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
104
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.20
|
|
105
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
106
|
+
|
|
107
|
+
## 4.0.0-beta.30
|
|
108
|
+
|
|
109
|
+
### Patch Changes
|
|
110
|
+
|
|
111
|
+
- e5bdc8d: fix (provider/xai): handle mid-stream error chunks
|
|
112
|
+
|
|
113
|
+
## 4.0.0-beta.29
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- 813851f: fix (provider/xai): add response.incomplete and response.failed streaming event handling
|
|
118
|
+
|
|
119
|
+
## 4.0.0-beta.28
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies [34bd95d]
|
|
124
|
+
- Updated dependencies [008271d]
|
|
125
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
126
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.19
|
|
127
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
128
|
+
|
|
129
|
+
## 4.0.0-beta.27
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- Updated dependencies [b0c2869]
|
|
134
|
+
- Updated dependencies [7e26e81]
|
|
135
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
136
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.18
|
|
137
|
+
|
|
138
|
+
## 4.0.0-beta.26
|
|
139
|
+
|
|
140
|
+
### Patch Changes
|
|
141
|
+
|
|
142
|
+
- Updated dependencies [816ff67]
|
|
143
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.17
|
|
144
|
+
|
|
145
|
+
## 4.0.0-beta.25
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- Updated dependencies [46d1149]
|
|
150
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
151
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.16
|
|
152
|
+
|
|
153
|
+
## 4.0.0-beta.24
|
|
154
|
+
|
|
155
|
+
### Patch Changes
|
|
156
|
+
|
|
157
|
+
- Updated dependencies [6fd51c0]
|
|
158
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
159
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
160
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.15
|
|
161
|
+
|
|
162
|
+
## 4.0.0-beta.23
|
|
163
|
+
|
|
164
|
+
### Patch Changes
|
|
165
|
+
|
|
166
|
+
- c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
|
|
167
|
+
- Updated dependencies [c29a26f]
|
|
168
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.14
|
|
169
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
170
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
171
|
+
|
|
172
|
+
## 4.0.0-beta.22
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- f51c95e: feat(provider/xai): add video extension and reference-to-video (R2V) support
|
|
177
|
+
|
|
178
|
+
## 4.0.0-beta.21
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
183
|
+
- Updated dependencies [38fc777]
|
|
184
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.13
|
|
185
|
+
|
|
186
|
+
## 4.0.0-beta.20
|
|
187
|
+
|
|
188
|
+
### Patch Changes
|
|
189
|
+
|
|
190
|
+
- Updated dependencies [2e17091]
|
|
191
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
192
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.12
|
|
193
|
+
|
|
194
|
+
## 4.0.0-beta.19
|
|
195
|
+
|
|
196
|
+
### Patch Changes
|
|
197
|
+
|
|
198
|
+
- Updated dependencies [986c6fd]
|
|
199
|
+
- Updated dependencies [493295c]
|
|
200
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
201
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.11
|
|
202
|
+
|
|
203
|
+
## 4.0.0-beta.18
|
|
204
|
+
|
|
205
|
+
### Patch Changes
|
|
206
|
+
|
|
207
|
+
- 9f20868: fix(provider/xai): correct finish reason for tool calls
|
|
208
|
+
|
|
209
|
+
## 4.0.0-beta.17
|
|
210
|
+
|
|
211
|
+
### Patch Changes
|
|
212
|
+
|
|
213
|
+
- Updated dependencies [1f509d4]
|
|
214
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
215
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
216
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.10
|
|
217
|
+
|
|
218
|
+
## 4.0.0-beta.16
|
|
219
|
+
|
|
220
|
+
### Patch Changes
|
|
221
|
+
|
|
222
|
+
- 4f91b5d: chore(provider/xai): update Grok 4.20 model IDs to their non-beta versions
|
|
223
|
+
|
|
224
|
+
## 4.0.0-beta.15
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
229
|
+
- Updated dependencies [74d520f]
|
|
230
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.9
|
|
231
|
+
|
|
232
|
+
## 4.0.0-beta.14
|
|
233
|
+
|
|
234
|
+
### Patch Changes
|
|
235
|
+
|
|
236
|
+
- Updated dependencies [3887c70]
|
|
237
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
238
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
239
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.8
|
|
240
|
+
|
|
241
|
+
## 4.0.0-beta.13
|
|
242
|
+
|
|
243
|
+
### Major Changes
|
|
244
|
+
|
|
245
|
+
- 776b617: feat(provider): adding new 'custom' content type
|
|
246
|
+
|
|
247
|
+
### Patch Changes
|
|
248
|
+
|
|
249
|
+
- Updated dependencies [776b617]
|
|
250
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
251
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
252
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.7
|
|
253
|
+
|
|
254
|
+
## 4.0.0-beta.12
|
|
255
|
+
|
|
256
|
+
### Patch Changes
|
|
257
|
+
|
|
258
|
+
- d20829e: feat(provider/xai): add moderation error, and costInUsdTicks to video model
|
|
259
|
+
- Updated dependencies [61753c3]
|
|
260
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
261
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.6
|
|
262
|
+
|
|
263
|
+
## 4.0.0-beta.11
|
|
264
|
+
|
|
265
|
+
### Patch Changes
|
|
266
|
+
|
|
267
|
+
- f7d4f01: feat(provider): add support for `reasoning-file` type for files that are part of reasoning
|
|
268
|
+
- Updated dependencies [f7d4f01]
|
|
269
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
270
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
271
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.5
|
|
272
|
+
|
|
273
|
+
## 4.0.0-beta.10
|
|
274
|
+
|
|
275
|
+
### Patch Changes
|
|
276
|
+
|
|
277
|
+
- Updated dependencies [5c2a5a2]
|
|
278
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
279
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.4
|
|
280
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
281
|
+
|
|
282
|
+
## 4.0.0-beta.9
|
|
283
|
+
|
|
284
|
+
### Patch Changes
|
|
285
|
+
|
|
286
|
+
- Updated dependencies [8f3e1da]
|
|
287
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.3
|
|
288
|
+
|
|
289
|
+
## 4.0.0-beta.8
|
|
290
|
+
|
|
291
|
+
### Patch Changes
|
|
292
|
+
|
|
293
|
+
- 4799fa5: chore(provider/xai): update provider to use v4 types
|
|
294
|
+
|
|
295
|
+
## 4.0.0-beta.7
|
|
296
|
+
|
|
297
|
+
### Patch Changes
|
|
298
|
+
|
|
299
|
+
- 0f11f10: add reasoningSummary to responses API provider options
|
|
300
|
+
- 12115e9: fix reasoning text extraction from content in responses doGenerate
|
|
301
|
+
|
|
302
|
+
## 4.0.0-beta.6
|
|
303
|
+
|
|
304
|
+
### Major Changes
|
|
305
|
+
|
|
306
|
+
- f62681f: feat(provider/xai): make responses api the default
|
|
307
|
+
|
|
308
|
+
## 4.0.0-beta.5
|
|
309
|
+
|
|
310
|
+
### Patch Changes
|
|
311
|
+
|
|
312
|
+
- aa5a583: chore(provider/xai): remove obsolete Grok 2 models now that they are shut down in their API
|
|
313
|
+
|
|
3
314
|
## 4.0.0-beta.4
|
|
4
315
|
|
|
5
316
|
### Patch Changes
|
|
@@ -536,13 +847,13 @@
|
|
|
536
847
|
Before
|
|
537
848
|
|
|
538
849
|
```ts
|
|
539
|
-
model.textEmbeddingModel(
|
|
850
|
+
model.textEmbeddingModel("my-model-id");
|
|
540
851
|
```
|
|
541
852
|
|
|
542
853
|
After
|
|
543
854
|
|
|
544
855
|
```ts
|
|
545
|
-
model.embeddingModel(
|
|
856
|
+
model.embeddingModel("my-model-id");
|
|
546
857
|
```
|
|
547
858
|
|
|
548
859
|
- 2625a04: feat(openai); update spec for mcp approval
|
|
@@ -800,13 +1111,13 @@
|
|
|
800
1111
|
Before
|
|
801
1112
|
|
|
802
1113
|
```ts
|
|
803
|
-
model.textEmbeddingModel(
|
|
1114
|
+
model.textEmbeddingModel("my-model-id");
|
|
804
1115
|
```
|
|
805
1116
|
|
|
806
1117
|
After
|
|
807
1118
|
|
|
808
1119
|
```ts
|
|
809
|
-
model.embeddingModel(
|
|
1120
|
+
model.embeddingModel("my-model-id");
|
|
810
1121
|
```
|
|
811
1122
|
|
|
812
1123
|
- 8514146: add grok-4-1 model IDs
|
|
@@ -1349,7 +1660,7 @@
|
|
|
1349
1660
|
|
|
1350
1661
|
```js
|
|
1351
1662
|
await generateImage({
|
|
1352
|
-
model: luma.image(
|
|
1663
|
+
model: luma.image("photon-flash-1", {
|
|
1353
1664
|
maxImagesPerCall: 5,
|
|
1354
1665
|
pollIntervalMillis: 500,
|
|
1355
1666
|
}),
|
|
@@ -1362,7 +1673,7 @@
|
|
|
1362
1673
|
|
|
1363
1674
|
```js
|
|
1364
1675
|
await generateImage({
|
|
1365
|
-
model: luma.image(
|
|
1676
|
+
model: luma.image("photon-flash-1"),
|
|
1366
1677
|
prompt,
|
|
1367
1678
|
n: 10,
|
|
1368
1679
|
maxImagesPerCall: 5,
|
|
@@ -1678,7 +1989,7 @@
|
|
|
1678
1989
|
|
|
1679
1990
|
```js
|
|
1680
1991
|
await generateImage({
|
|
1681
|
-
model: luma.image(
|
|
1992
|
+
model: luma.image("photon-flash-1", {
|
|
1682
1993
|
maxImagesPerCall: 5,
|
|
1683
1994
|
pollIntervalMillis: 500,
|
|
1684
1995
|
}),
|
|
@@ -1691,7 +2002,7 @@
|
|
|
1691
2002
|
|
|
1692
2003
|
```js
|
|
1693
2004
|
await generateImage({
|
|
1694
|
-
model: luma.image(
|
|
2005
|
+
model: luma.image("photon-flash-1"),
|
|
1695
2006
|
prompt,
|
|
1696
2007
|
n: 10,
|
|
1697
2008
|
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
|