@ai-sdk/xai 2.0.43 → 2.0.45

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,11 +1,23 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 2.0.45
4
+
5
+ ### Patch Changes
6
+
7
+ - 9d16e4e: fix (provider/xai): use correct format for function tools
8
+
9
+ ## 2.0.44
10
+
11
+ ### Patch Changes
12
+
13
+ - 08bffe4: feat (provider/xai): include cached input token metrics in responses api usage
14
+
3
15
  ## 2.0.43
4
16
 
5
17
  ### Patch Changes
6
18
 
7
- - 4953414: fix: trigger new release for `@ai-v5` dist-tag
8
- - Updated dependencies [4953414]
19
+ - 526fe8d: fix: trigger new release for `@ai-v5` dist-tag
20
+ - Updated dependencies [526fe8d]
9
21
  - @ai-sdk/openai-compatible@1.0.30
10
22
  - @ai-sdk/provider@2.0.1
11
23
  - @ai-sdk/provider-utils@3.0.20
package/dist/index.js CHANGED
@@ -1376,11 +1376,9 @@ async function prepareResponsesTools({
1376
1376
  } else {
1377
1377
  xaiTools2.push({
1378
1378
  type: "function",
1379
- function: {
1380
- name: tool.name,
1381
- description: tool.description,
1382
- parameters: tool.inputSchema
1383
- }
1379
+ name: tool.name,
1380
+ description: tool.description,
1381
+ parameters: tool.inputSchema
1384
1382
  });
1385
1383
  }
1386
1384
  }
@@ -1560,7 +1558,7 @@ var XaiResponsesLanguageModel = class {
1560
1558
  };
1561
1559
  }
1562
1560
  async doGenerate(options) {
1563
- var _a, _b, _c, _d, _e, _f, _g, _h;
1561
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1564
1562
  const {
1565
1563
  args: body,
1566
1564
  warnings,
@@ -1661,7 +1659,8 @@ var XaiResponsesLanguageModel = class {
1661
1659
  inputTokens: response.usage.input_tokens,
1662
1660
  outputTokens: response.usage.output_tokens,
1663
1661
  totalTokens: response.usage.total_tokens,
1664
- reasoningTokens: (_h = response.usage.output_tokens_details) == null ? void 0 : _h.reasoning_tokens
1662
+ reasoningTokens: (_h = response.usage.output_tokens_details) == null ? void 0 : _h.reasoning_tokens,
1663
+ cachedInputTokens: (_i = response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens
1665
1664
  },
1666
1665
  request: { body },
1667
1666
  response: {
@@ -1713,7 +1712,7 @@ var XaiResponsesLanguageModel = class {
1713
1712
  controller.enqueue({ type: "stream-start", warnings });
1714
1713
  },
1715
1714
  transform(chunk, controller) {
1716
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i;
1715
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1717
1716
  if (options.includeRawChunks) {
1718
1717
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
1719
1718
  }
@@ -1804,9 +1803,10 @@ var XaiResponsesLanguageModel = class {
1804
1803
  const response2 = event.response;
1805
1804
  if (response2.usage) {
1806
1805
  usage.inputTokens = response2.usage.input_tokens;
1806
+ usage.cachedInputTokens = (_c = response2.usage.input_tokens_details) == null ? void 0 : _c.cached_tokens;
1807
1807
  usage.outputTokens = response2.usage.output_tokens;
1808
1808
  usage.totalTokens = response2.usage.total_tokens;
1809
- usage.reasoningTokens = (_c = response2.usage.output_tokens_details) == null ? void 0 : _c.reasoning_tokens;
1809
+ usage.reasoningTokens = (_d = response2.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens;
1810
1810
  }
1811
1811
  if (response2.status) {
1812
1812
  finishReason = mapXaiResponsesFinishReason(response2.status);
@@ -1829,15 +1829,15 @@ var XaiResponsesLanguageModel = class {
1829
1829
  "x_semantic_search",
1830
1830
  "x_thread_fetch"
1831
1831
  ];
1832
- let toolName = (_d = part.name) != null ? _d : "";
1833
- if (webSearchSubTools.includes((_e = part.name) != null ? _e : "")) {
1832
+ let toolName = (_e = part.name) != null ? _e : "";
1833
+ if (webSearchSubTools.includes((_f = part.name) != null ? _f : "")) {
1834
1834
  toolName = webSearchToolName != null ? webSearchToolName : "web_search";
1835
- } else if (xSearchSubTools.includes((_f = part.name) != null ? _f : "")) {
1835
+ } else if (xSearchSubTools.includes((_g = part.name) != null ? _g : "")) {
1836
1836
  toolName = xSearchToolName != null ? xSearchToolName : "x_search";
1837
1837
  } else if (part.name === "code_execution") {
1838
1838
  toolName = codeExecutionToolName != null ? codeExecutionToolName : "code_execution";
1839
1839
  }
1840
- const toolInput = part.type === "custom_tool_call" ? (_g = part.input) != null ? _g : "" : (_h = part.arguments) != null ? _h : "";
1840
+ const toolInput = part.type === "custom_tool_call" ? (_h = part.input) != null ? _h : "" : (_i = part.arguments) != null ? _i : "";
1841
1841
  controller.enqueue({
1842
1842
  type: "tool-input-start",
1843
1843
  id: part.id,
@@ -1887,7 +1887,7 @@ var XaiResponsesLanguageModel = class {
1887
1887
  sourceType: "url",
1888
1888
  id: self.config.generateId(),
1889
1889
  url: annotation.url,
1890
- title: (_i = annotation.title) != null ? _i : annotation.url
1890
+ title: (_j = annotation.title) != null ? _j : annotation.url
1891
1891
  });
1892
1892
  }
1893
1893
  }
@@ -1995,7 +1995,7 @@ var xaiTools = {
1995
1995
  };
1996
1996
 
1997
1997
  // src/version.ts
1998
- var VERSION = true ? "2.0.43" : "0.0.0-test";
1998
+ var VERSION = true ? "2.0.45" : "0.0.0-test";
1999
1999
 
2000
2000
  // src/xai-provider.ts
2001
2001
  var xaiErrorStructure = {