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