@ai-sdk/xai 4.0.0-beta.6 → 4.0.0-beta.8

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 4.0.0-beta.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 4799fa5: chore(provider/xai): update provider to use v4 types
8
+
9
+ ## 4.0.0-beta.7
10
+
11
+ ### Patch Changes
12
+
13
+ - 0f11f10: add reasoningSummary to responses API provider options
14
+ - 12115e9: fix reasoning text extraction from content in responses doGenerate
15
+
3
16
  ## 4.0.0-beta.6
4
17
 
5
18
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV3, LanguageModelV3, ImageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
2
+ import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
@@ -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>;
@@ -306,36 +311,36 @@ declare const xaiTools: {
306
311
  }>;
307
312
  };
308
313
 
309
- interface XaiProvider extends ProviderV3 {
310
- (modelId: XaiResponsesModelId): LanguageModelV3;
314
+ interface XaiProvider extends ProviderV4 {
315
+ (modelId: XaiResponsesModelId): LanguageModelV4;
311
316
  /**
312
317
  * Creates an Xai language model for text generation.
313
318
  */
314
- languageModel(modelId: XaiResponsesModelId): LanguageModelV3;
319
+ languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
315
320
  /**
316
321
  * Creates an Xai chat model for text generation.
317
322
  */
318
- chat: (modelId: XaiChatModelId) => LanguageModelV3;
323
+ chat: (modelId: XaiChatModelId) => LanguageModelV4;
319
324
  /**
320
325
  * Creates an Xai responses model for text generation.
321
326
  */
322
- responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
327
+ responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
323
328
  /**
324
329
  * Creates an Xai image model for image generation.
325
330
  */
326
- image(modelId: XaiImageModelId): ImageModelV3;
331
+ image(modelId: XaiImageModelId): ImageModelV4;
327
332
  /**
328
333
  * Creates an Xai image model for image generation.
329
334
  */
330
- imageModel(modelId: XaiImageModelId): ImageModelV3;
335
+ imageModel(modelId: XaiImageModelId): ImageModelV4;
331
336
  /**
332
337
  * Creates an Xai video model for video generation.
333
338
  */
334
- video(modelId: XaiVideoModelId): Experimental_VideoModelV3;
339
+ video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
335
340
  /**
336
341
  * Creates an Xai video model for video generation.
337
342
  */
338
- videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV3;
343
+ videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
339
344
  /**
340
345
  * Server-side agentic tools for use with the responses API.
341
346
  */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV3, LanguageModelV3, ImageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
2
+ import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4 } from '@ai-sdk/provider';
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
@@ -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>;
@@ -306,36 +311,36 @@ declare const xaiTools: {
306
311
  }>;
307
312
  };
308
313
 
309
- interface XaiProvider extends ProviderV3 {
310
- (modelId: XaiResponsesModelId): LanguageModelV3;
314
+ interface XaiProvider extends ProviderV4 {
315
+ (modelId: XaiResponsesModelId): LanguageModelV4;
311
316
  /**
312
317
  * Creates an Xai language model for text generation.
313
318
  */
314
- languageModel(modelId: XaiResponsesModelId): LanguageModelV3;
319
+ languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
315
320
  /**
316
321
  * Creates an Xai chat model for text generation.
317
322
  */
318
- chat: (modelId: XaiChatModelId) => LanguageModelV3;
323
+ chat: (modelId: XaiChatModelId) => LanguageModelV4;
319
324
  /**
320
325
  * Creates an Xai responses model for text generation.
321
326
  */
322
- responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
327
+ responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
323
328
  /**
324
329
  * Creates an Xai image model for image generation.
325
330
  */
326
- image(modelId: XaiImageModelId): ImageModelV3;
331
+ image(modelId: XaiImageModelId): ImageModelV4;
327
332
  /**
328
333
  * Creates an Xai image model for image generation.
329
334
  */
330
- imageModel(modelId: XaiImageModelId): ImageModelV3;
335
+ imageModel(modelId: XaiImageModelId): ImageModelV4;
331
336
  /**
332
337
  * Creates an Xai video model for video generation.
333
338
  */
334
- video(modelId: XaiVideoModelId): Experimental_VideoModelV3;
339
+ video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
335
340
  /**
336
341
  * Creates an Xai video model for video generation.
337
342
  */
338
- videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV3;
343
+ videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
339
344
  /**
340
345
  * Server-side agentic tools for use with the responses API.
341
346
  */
package/dist/index.js CHANGED
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  VERSION: () => VERSION,
24
24
  codeExecution: () => codeExecution,
25
25
  createXai: () => createXai,
@@ -31,7 +31,7 @@ __export(src_exports, {
31
31
  xai: () => xai,
32
32
  xaiTools: () => xaiTools
33
33
  });
34
- module.exports = __toCommonJS(src_exports);
34
+ module.exports = __toCommonJS(index_exports);
35
35
 
36
36
  // src/xai-provider.ts
37
37
  var import_provider7 = require("@ai-sdk/provider");
@@ -370,7 +370,7 @@ function prepareTools({
370
370
  // src/xai-chat-language-model.ts
371
371
  var XaiChatLanguageModel = class {
372
372
  constructor(modelId, config) {
373
- this.specificationVersion = "v3";
373
+ this.specificationVersion = "v4";
374
374
  this.supportedUrls = {
375
375
  "image/*": [/^https?:\/\/.*$/]
376
376
  };
@@ -903,7 +903,7 @@ var XaiImageModel = class {
903
903
  constructor(modelId, config) {
904
904
  this.modelId = modelId;
905
905
  this.config = config;
906
- this.specificationVersion = "v3";
906
+ this.specificationVersion = "v4";
907
907
  this.maxImagesPerCall = 3;
908
908
  }
909
909
  get provider() {
@@ -1345,6 +1345,7 @@ var outputItemSchema = import_v46.z.discriminatedUnion("type", [
1345
1345
  type: import_v46.z.literal("reasoning"),
1346
1346
  id: import_v46.z.string(),
1347
1347
  summary: import_v46.z.array(reasoningSummaryPartSchema),
1348
+ content: import_v46.z.array(import_v46.z.object({ type: import_v46.z.string(), text: import_v46.z.string() })).nullish(),
1348
1349
  status: import_v46.z.string(),
1349
1350
  encrypted_content: import_v46.z.string().nullish()
1350
1351
  })
@@ -1651,6 +1652,7 @@ var xaiLanguageModelResponsesOptions = import_v47.z.object({
1651
1652
  * Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
1652
1653
  */
1653
1654
  reasoningEffort: import_v47.z.enum(["low", "medium", "high"]).optional(),
1655
+ reasoningSummary: import_v47.z.enum(["auto", "concise", "detailed"]).optional(),
1654
1656
  logprobs: import_v47.z.boolean().optional(),
1655
1657
  topLogprobs: import_v47.z.number().int().min(0).max(8).optional(),
1656
1658
  /**
@@ -1960,7 +1962,7 @@ async function prepareResponsesTools({
1960
1962
  // src/responses/xai-responses-language-model.ts
1961
1963
  var XaiResponsesLanguageModel = class {
1962
1964
  constructor(modelId, config) {
1963
- this.specificationVersion = "v3";
1965
+ this.specificationVersion = "v4";
1964
1966
  this.supportedUrls = {
1965
1967
  "image/*": [/^https?:\/\/.*$/]
1966
1968
  };
@@ -2049,8 +2051,15 @@ var XaiResponsesLanguageModel = class {
2049
2051
  } : { type: "json_object" }
2050
2052
  }
2051
2053
  },
2052
- ...options.reasoningEffort != null && {
2053
- reasoning: { effort: options.reasoningEffort }
2054
+ ...(options.reasoningEffort != null || options.reasoningSummary != null) && {
2055
+ reasoning: {
2056
+ ...options.reasoningEffort != null && {
2057
+ effort: options.reasoningEffort
2058
+ },
2059
+ ...options.reasoningSummary != null && {
2060
+ summary: options.reasoningSummary
2061
+ }
2062
+ }
2054
2063
  },
2055
2064
  ...options.store === false && {
2056
2065
  store: options.store
@@ -2079,7 +2088,7 @@ var XaiResponsesLanguageModel = class {
2079
2088
  };
2080
2089
  }
2081
2090
  async doGenerate(options) {
2082
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2091
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
2083
2092
  const {
2084
2093
  args: body,
2085
2094
  warnings,
@@ -2198,9 +2207,9 @@ var XaiResponsesLanguageModel = class {
2198
2207
  break;
2199
2208
  }
2200
2209
  case "reasoning": {
2201
- const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
2202
- if (summaryTexts.length > 0) {
2203
- const reasoningText = summaryTexts.join("");
2210
+ const texts = part.summary.length > 0 ? part.summary.map((s) => s.text) : ((_m = part.content) != null ? _m : []).map((c) => c.text);
2211
+ const reasoningText = texts.filter((text) => text && text.length > 0).join("");
2212
+ if (reasoningText) {
2204
2213
  if (part.encrypted_content || part.id) {
2205
2214
  content.push({
2206
2215
  type: "reasoning",
@@ -2232,7 +2241,7 @@ var XaiResponsesLanguageModel = class {
2232
2241
  content,
2233
2242
  finishReason: {
2234
2243
  unified: mapXaiResponsesFinishReason(response.status),
2235
- raw: (_m = response.status) != null ? _m : void 0
2244
+ raw: (_n = response.status) != null ? _n : void 0
2236
2245
  },
2237
2246
  usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
2238
2247
  inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
@@ -2715,7 +2724,7 @@ var xaiTools = {
2715
2724
  };
2716
2725
 
2717
2726
  // src/version.ts
2718
- var VERSION = true ? "4.0.0-beta.6" : "0.0.0-test";
2727
+ var VERSION = true ? "4.0.0-beta.8" : "0.0.0-test";
2719
2728
 
2720
2729
  // src/xai-video-model.ts
2721
2730
  var import_provider6 = require("@ai-sdk/provider");
@@ -2746,7 +2755,7 @@ var XaiVideoModel = class {
2746
2755
  constructor(modelId, config) {
2747
2756
  this.modelId = modelId;
2748
2757
  this.config = config;
2749
- this.specificationVersion = "v3";
2758
+ this.specificationVersion = "v4";
2750
2759
  this.maxVideosPerCall = 1;
2751
2760
  }
2752
2761
  get provider() {
@@ -2999,7 +3008,7 @@ function createXai(options = {}) {
2999
3008
  });
3000
3009
  };
3001
3010
  const provider = (modelId) => createResponsesLanguageModel(modelId);
3002
- provider.specificationVersion = "v3";
3011
+ provider.specificationVersion = "v4";
3003
3012
  provider.languageModel = createResponsesLanguageModel;
3004
3013
  provider.chat = createChatLanguageModel;
3005
3014
  provider.responses = createResponsesLanguageModel;