@ai-sdk/xai 3.0.37 → 3.0.39
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 +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -2
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +70 -31
- package/package.json +2 -2
- package/src/responses/xai-responses-language-model.ts +19 -1
- package/src/xai-provider.ts +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.39
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 58800f3: fix(xai): emit reasoning-start before reasoning-end for encrypted reasoning
|
|
8
|
+
|
|
9
|
+
## 3.0.38
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 2c70b90: chore: update provider docs
|
|
14
|
+
|
|
3
15
|
## 3.0.37
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -254,31 +254,31 @@ declare const xaiTools: {
|
|
|
254
254
|
|
|
255
255
|
interface XaiProvider extends ProviderV3 {
|
|
256
256
|
/**
|
|
257
|
-
|
|
257
|
+
* Creates an Xai chat model for text generation.
|
|
258
258
|
*/
|
|
259
259
|
(modelId: XaiChatModelId): LanguageModelV3;
|
|
260
260
|
/**
|
|
261
|
-
|
|
261
|
+
* Creates an Xai language model for text generation.
|
|
262
262
|
*/
|
|
263
263
|
languageModel(modelId: XaiChatModelId): LanguageModelV3;
|
|
264
264
|
/**
|
|
265
|
-
|
|
265
|
+
* Creates an Xai chat model for text generation.
|
|
266
266
|
*/
|
|
267
267
|
chat: (modelId: XaiChatModelId) => LanguageModelV3;
|
|
268
268
|
/**
|
|
269
|
-
|
|
269
|
+
* Creates an Xai responses model for agentic tool calling.
|
|
270
270
|
*/
|
|
271
271
|
responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
|
|
272
272
|
/**
|
|
273
|
-
|
|
273
|
+
* Creates an Xai image model for image generation.
|
|
274
274
|
*/
|
|
275
275
|
image(modelId: XaiImageModelId): ImageModelV3;
|
|
276
276
|
/**
|
|
277
|
-
|
|
277
|
+
* Creates an Xai image model for image generation.
|
|
278
278
|
*/
|
|
279
279
|
imageModel(modelId: XaiImageModelId): ImageModelV3;
|
|
280
280
|
/**
|
|
281
|
-
|
|
281
|
+
* Server-side agentic tools for use with the responses API.
|
|
282
282
|
*/
|
|
283
283
|
tools: typeof xaiTools;
|
|
284
284
|
/**
|
|
@@ -288,21 +288,21 @@ interface XaiProvider extends ProviderV3 {
|
|
|
288
288
|
}
|
|
289
289
|
interface XaiProviderSettings {
|
|
290
290
|
/**
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
* Base URL for the xAI API calls.
|
|
292
|
+
*/
|
|
293
293
|
baseURL?: string;
|
|
294
294
|
/**
|
|
295
|
-
|
|
295
|
+
* API key for authenticating requests.
|
|
296
296
|
*/
|
|
297
297
|
apiKey?: string;
|
|
298
298
|
/**
|
|
299
|
-
|
|
299
|
+
* Custom headers to include in the requests.
|
|
300
300
|
*/
|
|
301
301
|
headers?: Record<string, string>;
|
|
302
302
|
/**
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
304
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
305
|
+
*/
|
|
306
306
|
fetch?: FetchFunction;
|
|
307
307
|
}
|
|
308
308
|
declare function createXai(options?: XaiProviderSettings): XaiProvider;
|
package/dist/index.d.ts
CHANGED
|
@@ -254,31 +254,31 @@ declare const xaiTools: {
|
|
|
254
254
|
|
|
255
255
|
interface XaiProvider extends ProviderV3 {
|
|
256
256
|
/**
|
|
257
|
-
|
|
257
|
+
* Creates an Xai chat model for text generation.
|
|
258
258
|
*/
|
|
259
259
|
(modelId: XaiChatModelId): LanguageModelV3;
|
|
260
260
|
/**
|
|
261
|
-
|
|
261
|
+
* Creates an Xai language model for text generation.
|
|
262
262
|
*/
|
|
263
263
|
languageModel(modelId: XaiChatModelId): LanguageModelV3;
|
|
264
264
|
/**
|
|
265
|
-
|
|
265
|
+
* Creates an Xai chat model for text generation.
|
|
266
266
|
*/
|
|
267
267
|
chat: (modelId: XaiChatModelId) => LanguageModelV3;
|
|
268
268
|
/**
|
|
269
|
-
|
|
269
|
+
* Creates an Xai responses model for agentic tool calling.
|
|
270
270
|
*/
|
|
271
271
|
responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
|
|
272
272
|
/**
|
|
273
|
-
|
|
273
|
+
* Creates an Xai image model for image generation.
|
|
274
274
|
*/
|
|
275
275
|
image(modelId: XaiImageModelId): ImageModelV3;
|
|
276
276
|
/**
|
|
277
|
-
|
|
277
|
+
* Creates an Xai image model for image generation.
|
|
278
278
|
*/
|
|
279
279
|
imageModel(modelId: XaiImageModelId): ImageModelV3;
|
|
280
280
|
/**
|
|
281
|
-
|
|
281
|
+
* Server-side agentic tools for use with the responses API.
|
|
282
282
|
*/
|
|
283
283
|
tools: typeof xaiTools;
|
|
284
284
|
/**
|
|
@@ -288,21 +288,21 @@ interface XaiProvider extends ProviderV3 {
|
|
|
288
288
|
}
|
|
289
289
|
interface XaiProviderSettings {
|
|
290
290
|
/**
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
* Base URL for the xAI API calls.
|
|
292
|
+
*/
|
|
293
293
|
baseURL?: string;
|
|
294
294
|
/**
|
|
295
|
-
|
|
295
|
+
* API key for authenticating requests.
|
|
296
296
|
*/
|
|
297
297
|
apiKey?: string;
|
|
298
298
|
/**
|
|
299
|
-
|
|
299
|
+
* Custom headers to include in the requests.
|
|
300
300
|
*/
|
|
301
301
|
headers?: Record<string, string>;
|
|
302
302
|
/**
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
304
|
+
* or to provide a custom fetch implementation for e.g. testing.
|
|
305
|
+
*/
|
|
306
306
|
fetch?: FetchFunction;
|
|
307
307
|
}
|
|
308
308
|
declare function createXai(options?: XaiProviderSettings): XaiProvider;
|
package/dist/index.js
CHANGED
|
@@ -2040,6 +2040,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2040
2040
|
}
|
|
2041
2041
|
if (event.type === "response.reasoning_summary_part.added") {
|
|
2042
2042
|
const blockId = `reasoning-${event.item_id}`;
|
|
2043
|
+
activeReasoning[event.item_id] = {};
|
|
2043
2044
|
controller.enqueue({
|
|
2044
2045
|
type: "reasoning-start",
|
|
2045
2046
|
id: blockId,
|
|
@@ -2132,9 +2133,22 @@ var XaiResponsesLanguageModel = class {
|
|
|
2132
2133
|
const part = event.item;
|
|
2133
2134
|
if (part.type === "reasoning") {
|
|
2134
2135
|
if (event.type === "response.output_item.done") {
|
|
2136
|
+
const blockId = `reasoning-${part.id}`;
|
|
2137
|
+
if (!(part.id in activeReasoning)) {
|
|
2138
|
+
activeReasoning[part.id] = {};
|
|
2139
|
+
controller.enqueue({
|
|
2140
|
+
type: "reasoning-start",
|
|
2141
|
+
id: blockId,
|
|
2142
|
+
providerMetadata: {
|
|
2143
|
+
xai: {
|
|
2144
|
+
...part.id && { itemId: part.id }
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2135
2149
|
controller.enqueue({
|
|
2136
2150
|
type: "reasoning-end",
|
|
2137
|
-
id:
|
|
2151
|
+
id: blockId,
|
|
2138
2152
|
providerMetadata: {
|
|
2139
2153
|
xai: {
|
|
2140
2154
|
...part.encrypted_content && {
|
|
@@ -2329,7 +2343,7 @@ var xaiTools = {
|
|
|
2329
2343
|
};
|
|
2330
2344
|
|
|
2331
2345
|
// src/version.ts
|
|
2332
|
-
var VERSION = true ? "3.0.
|
|
2346
|
+
var VERSION = true ? "3.0.39" : "0.0.0-test";
|
|
2333
2347
|
|
|
2334
2348
|
// src/xai-provider.ts
|
|
2335
2349
|
var xaiErrorStructure = {
|