@ai-sdk/xai 4.0.0-beta.0 → 4.0.0-beta.10

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,74 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 4.0.0-beta.10
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5c2a5a2]
8
+ - @ai-sdk/provider@4.0.0-beta.1
9
+ - @ai-sdk/openai-compatible@3.0.0-beta.4
10
+ - @ai-sdk/provider-utils@5.0.0-beta.2
11
+
12
+ ## 4.0.0-beta.9
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [8f3e1da]
17
+ - @ai-sdk/openai-compatible@3.0.0-beta.3
18
+
19
+ ## 4.0.0-beta.8
20
+
21
+ ### Patch Changes
22
+
23
+ - 4799fa5: chore(provider/xai): update provider to use v4 types
24
+
25
+ ## 4.0.0-beta.7
26
+
27
+ ### Patch Changes
28
+
29
+ - 0f11f10: add reasoningSummary to responses API provider options
30
+ - 12115e9: fix reasoning text extraction from content in responses doGenerate
31
+
32
+ ## 4.0.0-beta.6
33
+
34
+ ### Major Changes
35
+
36
+ - f62681f: feat(provider/xai): make responses api the default
37
+
38
+ ## 4.0.0-beta.5
39
+
40
+ ### Patch Changes
41
+
42
+ - aa5a583: chore(provider/xai): remove obsolete Grok 2 models now that they are shut down in their API
43
+
44
+ ## 4.0.0-beta.4
45
+
46
+ ### Patch Changes
47
+
48
+ - 25f1837: feat(xai): add b64_json response format, usage cost tracking, and quality/user parameters for image models
49
+
50
+ ## 4.0.0-beta.3
51
+
52
+ ### Patch Changes
53
+
54
+ - f5181ad: feat(provider/xai): support multiple input images for image editing
55
+
56
+ ## 4.0.0-beta.2
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [45b3d76]
61
+ - Updated dependencies [f7295cb]
62
+ - @ai-sdk/openai-compatible@3.0.0-beta.2
63
+
64
+ ## 4.0.0-beta.1
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [531251e]
69
+ - @ai-sdk/provider-utils@5.0.0-beta.1
70
+ - @ai-sdk/openai-compatible@3.0.0-beta.1
71
+
3
72
  ## 4.0.0-beta.0
4
73
 
5
74
  ### Major Changes
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';
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
 
6
- type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | (string & {});
6
+ type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | '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";
@@ -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,6 +91,12 @@ 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
 
@@ -99,7 +110,7 @@ type XaiVideoModelOptions = {
99
110
  [key: string]: unknown;
100
111
  };
101
112
 
102
- type XaiImageModelId = 'grok-2-image' | 'grok-2-image-1212' | 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
113
+ type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
103
114
 
104
115
  declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
105
116
  output: string;
@@ -300,39 +311,36 @@ declare const xaiTools: {
300
311
  }>;
301
312
  };
302
313
 
303
- interface XaiProvider extends ProviderV3 {
304
- /**
305
- * Creates an Xai chat model for text generation.
306
- */
307
- (modelId: XaiChatModelId): LanguageModelV3;
314
+ interface XaiProvider extends ProviderV4 {
315
+ (modelId: XaiResponsesModelId): LanguageModelV4;
308
316
  /**
309
317
  * Creates an Xai language model for text generation.
310
318
  */
311
- languageModel(modelId: XaiChatModelId): LanguageModelV3;
319
+ languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
312
320
  /**
313
321
  * Creates an Xai chat model for text generation.
314
322
  */
315
- chat: (modelId: XaiChatModelId) => LanguageModelV3;
323
+ chat: (modelId: XaiChatModelId) => LanguageModelV4;
316
324
  /**
317
- * Creates an Xai responses model for agentic tool calling.
325
+ * Creates an Xai responses model for text generation.
318
326
  */
319
- responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
327
+ responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
320
328
  /**
321
329
  * Creates an Xai image model for image generation.
322
330
  */
323
- image(modelId: XaiImageModelId): ImageModelV3;
331
+ image(modelId: XaiImageModelId): ImageModelV4;
324
332
  /**
325
333
  * Creates an Xai image model for image generation.
326
334
  */
327
- imageModel(modelId: XaiImageModelId): ImageModelV3;
335
+ imageModel(modelId: XaiImageModelId): ImageModelV4;
328
336
  /**
329
337
  * Creates an Xai video model for video generation.
330
338
  */
331
- video(modelId: XaiVideoModelId): Experimental_VideoModelV3;
339
+ video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
332
340
  /**
333
341
  * Creates an Xai video model for video generation.
334
342
  */
335
- videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV3;
343
+ videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
336
344
  /**
337
345
  * Server-side agentic tools for use with the responses API.
338
346
  */
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
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
 
6
- type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | (string & {});
6
+ type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | '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";
@@ -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,6 +91,12 @@ 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
 
@@ -99,7 +110,7 @@ type XaiVideoModelOptions = {
99
110
  [key: string]: unknown;
100
111
  };
101
112
 
102
- type XaiImageModelId = 'grok-2-image' | 'grok-2-image-1212' | 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
113
+ type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
103
114
 
104
115
  declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
105
116
  output: string;
@@ -300,39 +311,36 @@ declare const xaiTools: {
300
311
  }>;
301
312
  };
302
313
 
303
- interface XaiProvider extends ProviderV3 {
304
- /**
305
- * Creates an Xai chat model for text generation.
306
- */
307
- (modelId: XaiChatModelId): LanguageModelV3;
314
+ interface XaiProvider extends ProviderV4 {
315
+ (modelId: XaiResponsesModelId): LanguageModelV4;
308
316
  /**
309
317
  * Creates an Xai language model for text generation.
310
318
  */
311
- languageModel(modelId: XaiChatModelId): LanguageModelV3;
319
+ languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
312
320
  /**
313
321
  * Creates an Xai chat model for text generation.
314
322
  */
315
- chat: (modelId: XaiChatModelId) => LanguageModelV3;
323
+ chat: (modelId: XaiChatModelId) => LanguageModelV4;
316
324
  /**
317
- * Creates an Xai responses model for agentic tool calling.
325
+ * Creates an Xai responses model for text generation.
318
326
  */
319
- responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
327
+ responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
320
328
  /**
321
329
  * Creates an Xai image model for image generation.
322
330
  */
323
- image(modelId: XaiImageModelId): ImageModelV3;
331
+ image(modelId: XaiImageModelId): ImageModelV4;
324
332
  /**
325
333
  * Creates an Xai image model for image generation.
326
334
  */
327
- imageModel(modelId: XaiImageModelId): ImageModelV3;
335
+ imageModel(modelId: XaiImageModelId): ImageModelV4;
328
336
  /**
329
337
  * Creates an Xai video model for video generation.
330
338
  */
331
- video(modelId: XaiVideoModelId): Experimental_VideoModelV3;
339
+ video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
332
340
  /**
333
341
  * Creates an Xai video model for video generation.
334
342
  */
335
- videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV3;
343
+ videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
336
344
  /**
337
345
  * Server-side agentic tools for use with the responses API.
338
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
  };
@@ -893,7 +893,9 @@ var xaiImageModelOptions = import_v44.z.object({
893
893
  aspect_ratio: import_v44.z.string().optional(),
894
894
  output_format: import_v44.z.string().optional(),
895
895
  sync_mode: import_v44.z.boolean().optional(),
896
- resolution: import_v44.z.enum(["1k", "2k"]).optional()
896
+ resolution: import_v44.z.enum(["1k", "2k"]).optional(),
897
+ quality: import_v44.z.enum(["low", "medium", "high"]).optional(),
898
+ user: import_v44.z.string().optional()
897
899
  });
898
900
 
899
901
  // src/xai-image-model.ts
@@ -901,8 +903,8 @@ var XaiImageModel = class {
901
903
  constructor(modelId, config) {
902
904
  this.modelId = modelId;
903
905
  this.config = config;
904
- this.specificationVersion = "v3";
905
- this.maxImagesPerCall = 1;
906
+ this.specificationVersion = "v4";
907
+ this.maxImagesPerCall = 3;
906
908
  }
907
909
  get provider() {
908
910
  return this.config.provider;
@@ -919,7 +921,7 @@ var XaiImageModel = class {
919
921
  files,
920
922
  mask
921
923
  }) {
922
- var _a, _b, _c, _d;
924
+ var _a, _b, _c, _d, _e;
923
925
  const warnings = [];
924
926
  if (size != null) {
925
927
  warnings.push({
@@ -946,22 +948,13 @@ var XaiImageModel = class {
946
948
  schema: xaiImageModelOptions
947
949
  });
948
950
  const hasFiles = files != null && files.length > 0;
949
- let imageUrl;
950
- if (hasFiles) {
951
- imageUrl = (0, import_provider_utils4.convertImageModelFileToDataUri)(files[0]);
952
- if (files.length > 1) {
953
- warnings.push({
954
- type: "other",
955
- message: "xAI only supports a single input image. Additional images are ignored."
956
- });
957
- }
958
- }
951
+ const imageUrls = hasFiles ? files.map((file) => (0, import_provider_utils4.convertImageModelFileToDataUri)(file)) : [];
959
952
  const endpoint = hasFiles ? "/images/edits" : "/images/generations";
960
953
  const body = {
961
954
  model: this.modelId,
962
955
  prompt,
963
956
  n,
964
- response_format: "url"
957
+ response_format: "b64_json"
965
958
  };
966
959
  if (aspectRatio != null) {
967
960
  body.aspect_ratio = aspectRatio;
@@ -978,8 +971,16 @@ var XaiImageModel = class {
978
971
  if ((xaiOptions == null ? void 0 : xaiOptions.resolution) != null) {
979
972
  body.resolution = xaiOptions.resolution;
980
973
  }
981
- if (imageUrl != null) {
982
- body.image = { url: imageUrl, type: "image_url" };
974
+ if ((xaiOptions == null ? void 0 : xaiOptions.quality) != null) {
975
+ body.quality = xaiOptions.quality;
976
+ }
977
+ if ((xaiOptions == null ? void 0 : xaiOptions.user) != null) {
978
+ body.user = xaiOptions.user;
979
+ }
980
+ if (imageUrls.length === 1) {
981
+ body.image = { url: imageUrls[0], type: "image_url" };
982
+ } else if (imageUrls.length > 1) {
983
+ body.images = imageUrls.map((url) => ({ url, type: "image_url" }));
983
984
  }
984
985
  const baseURL = (_a = this.config.baseURL) != null ? _a : "https://api.x.ai/v1";
985
986
  const currentDate = (_d = (_c = (_b = this.config._internal) == null ? void 0 : _b.currentDate) == null ? void 0 : _c.call(_b)) != null ? _d : /* @__PURE__ */ new Date();
@@ -994,11 +995,14 @@ var XaiImageModel = class {
994
995
  abortSignal,
995
996
  fetch: this.config.fetch
996
997
  });
997
- const downloadedImages = await Promise.all(
998
- response.data.map((image) => this.downloadImage(image.url, abortSignal))
998
+ const hasAllBase64 = response.data.every((image) => image.b64_json != null);
999
+ const images = hasAllBase64 ? response.data.map((image) => image.b64_json) : await Promise.all(
1000
+ response.data.map(
1001
+ (image) => this.downloadImage(image.url, abortSignal)
1002
+ )
999
1003
  );
1000
1004
  return {
1001
- images: downloadedImages,
1005
+ images,
1002
1006
  warnings,
1003
1007
  response: {
1004
1008
  timestamp: currentDate,
@@ -1009,7 +1013,8 @@ var XaiImageModel = class {
1009
1013
  xai: {
1010
1014
  images: response.data.map((item) => ({
1011
1015
  ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {}
1012
- }))
1016
+ })),
1017
+ ...((_e = response.usage) == null ? void 0 : _e.cost_in_usd_ticks) != null ? { costInUsdTicks: response.usage.cost_in_usd_ticks } : {}
1013
1018
  }
1014
1019
  }
1015
1020
  };
@@ -1028,10 +1033,14 @@ var XaiImageModel = class {
1028
1033
  var xaiImageResponseSchema = import_v45.z.object({
1029
1034
  data: import_v45.z.array(
1030
1035
  import_v45.z.object({
1031
- url: import_v45.z.string(),
1036
+ url: import_v45.z.string().nullish(),
1037
+ b64_json: import_v45.z.string().nullish(),
1032
1038
  revised_prompt: import_v45.z.string().nullish()
1033
1039
  })
1034
- )
1040
+ ),
1041
+ usage: import_v45.z.object({
1042
+ cost_in_usd_ticks: import_v45.z.number().nullish()
1043
+ }).nullish()
1035
1044
  });
1036
1045
 
1037
1046
  // src/responses/xai-responses-language-model.ts
@@ -1336,6 +1345,7 @@ var outputItemSchema = import_v46.z.discriminatedUnion("type", [
1336
1345
  type: import_v46.z.literal("reasoning"),
1337
1346
  id: import_v46.z.string(),
1338
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(),
1339
1349
  status: import_v46.z.string(),
1340
1350
  encrypted_content: import_v46.z.string().nullish()
1341
1351
  })
@@ -1642,6 +1652,7 @@ var xaiLanguageModelResponsesOptions = import_v47.z.object({
1642
1652
  * Possible values are `low` (uses fewer reasoning tokens), `medium` and `high` (uses more reasoning tokens).
1643
1653
  */
1644
1654
  reasoningEffort: import_v47.z.enum(["low", "medium", "high"]).optional(),
1655
+ reasoningSummary: import_v47.z.enum(["auto", "concise", "detailed"]).optional(),
1645
1656
  logprobs: import_v47.z.boolean().optional(),
1646
1657
  topLogprobs: import_v47.z.number().int().min(0).max(8).optional(),
1647
1658
  /**
@@ -1951,7 +1962,7 @@ async function prepareResponsesTools({
1951
1962
  // src/responses/xai-responses-language-model.ts
1952
1963
  var XaiResponsesLanguageModel = class {
1953
1964
  constructor(modelId, config) {
1954
- this.specificationVersion = "v3";
1965
+ this.specificationVersion = "v4";
1955
1966
  this.supportedUrls = {
1956
1967
  "image/*": [/^https?:\/\/.*$/]
1957
1968
  };
@@ -2040,8 +2051,15 @@ var XaiResponsesLanguageModel = class {
2040
2051
  } : { type: "json_object" }
2041
2052
  }
2042
2053
  },
2043
- ...options.reasoningEffort != null && {
2044
- 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
+ }
2045
2063
  },
2046
2064
  ...options.store === false && {
2047
2065
  store: options.store
@@ -2070,7 +2088,7 @@ var XaiResponsesLanguageModel = class {
2070
2088
  };
2071
2089
  }
2072
2090
  async doGenerate(options) {
2073
- 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;
2074
2092
  const {
2075
2093
  args: body,
2076
2094
  warnings,
@@ -2189,9 +2207,9 @@ var XaiResponsesLanguageModel = class {
2189
2207
  break;
2190
2208
  }
2191
2209
  case "reasoning": {
2192
- const summaryTexts = part.summary.map((s) => s.text).filter((text) => text && text.length > 0);
2193
- if (summaryTexts.length > 0) {
2194
- 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) {
2195
2213
  if (part.encrypted_content || part.id) {
2196
2214
  content.push({
2197
2215
  type: "reasoning",
@@ -2223,7 +2241,7 @@ var XaiResponsesLanguageModel = class {
2223
2241
  content,
2224
2242
  finishReason: {
2225
2243
  unified: mapXaiResponsesFinishReason(response.status),
2226
- raw: (_m = response.status) != null ? _m : void 0
2244
+ raw: (_n = response.status) != null ? _n : void 0
2227
2245
  },
2228
2246
  usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
2229
2247
  inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
@@ -2706,7 +2724,7 @@ var xaiTools = {
2706
2724
  };
2707
2725
 
2708
2726
  // src/version.ts
2709
- var VERSION = true ? "4.0.0-beta.0" : "0.0.0-test";
2727
+ var VERSION = true ? "4.0.0-beta.10" : "0.0.0-test";
2710
2728
 
2711
2729
  // src/xai-video-model.ts
2712
2730
  var import_provider6 = require("@ai-sdk/provider");
@@ -2737,7 +2755,7 @@ var XaiVideoModel = class {
2737
2755
  constructor(modelId, config) {
2738
2756
  this.modelId = modelId;
2739
2757
  this.config = config;
2740
- this.specificationVersion = "v3";
2758
+ this.specificationVersion = "v4";
2741
2759
  this.maxVideosPerCall = 1;
2742
2760
  }
2743
2761
  get provider() {
@@ -2989,9 +3007,9 @@ function createXai(options = {}) {
2989
3007
  fetch: options.fetch
2990
3008
  });
2991
3009
  };
2992
- const provider = (modelId) => createChatLanguageModel(modelId);
2993
- provider.specificationVersion = "v3";
2994
- provider.languageModel = createChatLanguageModel;
3010
+ const provider = (modelId) => createResponsesLanguageModel(modelId);
3011
+ provider.specificationVersion = "v4";
3012
+ provider.languageModel = createResponsesLanguageModel;
2995
3013
  provider.chat = createChatLanguageModel;
2996
3014
  provider.responses = createResponsesLanguageModel;
2997
3015
  provider.embeddingModel = (modelId) => {