@ai-sdk/xai 4.0.0-beta.5 → 4.0.0-beta.7

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.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 0f11f10: add reasoningSummary to responses API provider options
8
+ - 12115e9: fix reasoning text extraction from content in responses doGenerate
9
+
10
+ ## 4.0.0-beta.6
11
+
12
+ ### Major Changes
13
+
14
+ - f62681f: feat(provider/xai): make responses api the default
15
+
3
16
  ## 4.0.0-beta.5
4
17
 
5
18
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -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>;
@@ -307,20 +312,17 @@ declare const xaiTools: {
307
312
  };
308
313
 
309
314
  interface XaiProvider extends ProviderV3 {
310
- /**
311
- * Creates an Xai chat model for text generation.
312
- */
313
- (modelId: XaiChatModelId): LanguageModelV3;
315
+ (modelId: XaiResponsesModelId): LanguageModelV3;
314
316
  /**
315
317
  * Creates an Xai language model for text generation.
316
318
  */
317
- languageModel(modelId: XaiChatModelId): LanguageModelV3;
319
+ languageModel(modelId: XaiResponsesModelId): LanguageModelV3;
318
320
  /**
319
321
  * Creates an Xai chat model for text generation.
320
322
  */
321
323
  chat: (modelId: XaiChatModelId) => LanguageModelV3;
322
324
  /**
323
- * Creates an Xai responses model for agentic tool calling.
325
+ * Creates an Xai responses model for text generation.
324
326
  */
325
327
  responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
326
328
  /**
package/dist/index.d.ts CHANGED
@@ -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>;
@@ -307,20 +312,17 @@ declare const xaiTools: {
307
312
  };
308
313
 
309
314
  interface XaiProvider extends ProviderV3 {
310
- /**
311
- * Creates an Xai chat model for text generation.
312
- */
313
- (modelId: XaiChatModelId): LanguageModelV3;
315
+ (modelId: XaiResponsesModelId): LanguageModelV3;
314
316
  /**
315
317
  * Creates an Xai language model for text generation.
316
318
  */
317
- languageModel(modelId: XaiChatModelId): LanguageModelV3;
319
+ languageModel(modelId: XaiResponsesModelId): LanguageModelV3;
318
320
  /**
319
321
  * Creates an Xai chat model for text generation.
320
322
  */
321
323
  chat: (modelId: XaiChatModelId) => LanguageModelV3;
322
324
  /**
323
- * Creates an Xai responses model for agentic tool calling.
325
+ * Creates an Xai responses model for text generation.
324
326
  */
325
327
  responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
326
328
  /**
package/dist/index.js CHANGED
@@ -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
  /**
@@ -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.5" : "0.0.0-test";
2727
+ var VERSION = true ? "4.0.0-beta.7" : "0.0.0-test";
2719
2728
 
2720
2729
  // src/xai-video-model.ts
2721
2730
  var import_provider6 = require("@ai-sdk/provider");
@@ -2998,9 +3007,9 @@ function createXai(options = {}) {
2998
3007
  fetch: options.fetch
2999
3008
  });
3000
3009
  };
3001
- const provider = (modelId) => createChatLanguageModel(modelId);
3010
+ const provider = (modelId) => createResponsesLanguageModel(modelId);
3002
3011
  provider.specificationVersion = "v3";
3003
- provider.languageModel = createChatLanguageModel;
3012
+ provider.languageModel = createResponsesLanguageModel;
3004
3013
  provider.chat = createChatLanguageModel;
3005
3014
  provider.responses = createResponsesLanguageModel;
3006
3015
  provider.embeddingModel = (modelId) => {